6

Similar problems

Android Studio inline compiler showing red errors, but compilation with gradle works fine Android Studio Marks syntax as error, but gradle compiles

My project broke after upgrading my Gradle version by editing build.gradle and gradle-wrapper.properties. However I can run it on virtual device without errors.

Neither Sync with Gradle files, Invalidate Caches nor rolling back to old commits solve the problem. My workspace snapshot workspace Classes League and Match are in the same package but they can't see each other. Using classes with full path doesn't solve the issue, because my packages aren't visible e.g. Cannot resolve symbol 'model'. Also rolling back to previous commits doesn't fix the problem.

Initially I wanted to make New Relic work which required new version of gradle. This caused bigger problem. Can you help me find the solution?

EDIT

I think I figured it out. I created new project an copied only java source and xml res files from the old one and the red lines disappeared. Left screen is old project.

left-old; right-new

Community
  • 1
  • 1
gkiko
  • 2,283
  • 3
  • 30
  • 50

1 Answers1

4

I had the same issue, and I still haven't figured out why it happened..

Anyways I resolved it by deleting the .idea folder and rebuilding the project from build.gradle.

Once you delete the .idea folder and restart Android Studio it will tell you it found an un-linked Gradle project (if you miss this message popup you can find it in the EventLog in the bottom right section), follow the directions to join the projects and it will fix itself.

nana
  • 4,426
  • 1
  • 34
  • 48
  • I followed your steps but after restart it didn't allow me to open the project telling that `.idea` was missing. So I had to select `Import project(Eclipse ADT, Gradle, etc.)`. Same outcome :( – gkiko Feb 15 '15 at 16:06
  • I did exactly as you said and everything went as you described. Same result – gkiko Feb 15 '15 at 16:16
  • So it still can't see those classes? – nana Feb 15 '15 at 20:05
  • They are still invisible. I did something wring with [build.gradle](https://github.com/gkiko/InstantScore/blob/master/build.gradle) I think. – gkiko Feb 15 '15 at 21:06
  • I don't see anything strange in your `build.gradle` file. How about cloning your repo to a new directory and Opening new project from a new instance of AndroidStudio and choosing your `build.gradle` file as a base to build the project on? I`d do it, but I am not in front of my box right now.. – nana Feb 15 '15 at 21:31
  • I'll try that. I've already cloned the project in another computer and imported it in Android Studio, but red lines were still present. – gkiko Feb 15 '15 at 21:38
  • I actually ended up downloading JDK, Git and Android studio at the office, and cloned your project from GitHub and built it, but had the same issue. I tried to find the cause, but haven't yet. I still want to know what causes it :) – nana Feb 16 '15 at 07:19