6

I have recently upgraded my laptop and re-installed Android Studio to the latest version and imported my app. The problem I am facing now is that when Android Studio start it finishes the gradle build etc, but shows errors all over my code. I can still debug the app on my phone and all is working.

How can I get this resolved?

Thanks

  • Try Build > Clean. Failing that try restarting Android Studio. Failing that you have compile errors. – Thomas Cook Jan 30 '18 at 11:07
  • Have tried that and still not clearing the error but can still compile. –  Jan 30 '18 at 11:09
  • Post the error? – Thomas Cook Jan 30 '18 at 11:15
  • Okay have it sorted now. What i did was close android and re-opened as "Administrator" - cleaned project and closed, restarted my machine and all is working now normally. Thanks –  Jan 30 '18 at 11:16
  • When i closed Android Studio and restarted my machine same errors all over my code showed. Only by running as Administrator and then restarted it worked. Weird?? –  Jan 30 '18 at 11:17
  • Pretty weird. It's like the old joke: "man goes to doctor: 'it hurts when I lift my arm' doctor to man: 'well don't lift your arm then'" – Thomas Cook Jan 30 '18 at 11:18
  • Hahahahahaha :-) –  Jan 30 '18 at 11:19
  • Check [this](https://stackoverflow.com/a/20257448) answer, hope it will help you! – vini b Jan 13 '21 at 15:18

3 Answers3

3

I finally resolved this when it happened to me. The steps I did to resolve my problem

  • Build -> clean
  • File -> invalidate caches / restart
  • Delete .idea folder, close and reopen project

Normally one of the first two first steps is enough but today I actually had to delete the entire .idea folder and reopen the project to get rid of the "errors" (only IDE errors, project still ran for me).

Casper
  • 471
  • 7
  • 12
0

If Methods named (A) (B) (C) (D), do not help you, then the following 4 steps are AGNI ASTRA.

Step 1 : Go To App Folder In Android Studio.

Step 2 : Locate Build Folder.

Step 3 : Delete Build Folder.

Step 4 : Sync File.

I will advise to use AGNI ASTRA, after trying, Methods named (A) (B) (C) (D) .

The Methods Are :

Method (A)

  • CLICK ON FILE IN ANDROID STUDIO
  • CLICK ON SYNC PROJECT WITH GRADLE FILES

Method (B)

  • CLICK ON FILE IN ANDROID STUDIO
  • CLICK ON INVALIDATE CACHES

Method (C)

  • CLICK ON BUILD IN ANDROID STUDIO
  • CLICK ON CLEAN PROJECT

Method (D)

  • CLICK ON BUILD IN ANDROID STUDIO
  • CLICK ON REBUILD PROJECT
0

In my case (Windows), I have faced the same issue with 2 version of Android Studio,

1. Android Studio Arctic Fox | 2020.3.1 Patch 4 (My previous/normal IDE used)

2. Android Studio Dolphin | 2021.3.1 Patch 1 (My updated/current IDE used)

First, I thought this problem can be solve by Build>Clean Project, or Build>Rebuild Project, or File>Invalidate Caches..., but sadly won't work. So, I decided to update my IDE Arctic Fox to Dolphin.

Download from official site, installed with different folder (C:\Program Files\Android\Android Studio1), but project folder still same. During opening project, it won't run unless change Java version to Java 11 (File>Settings>Build, Exectuion, Deployment>Build Tools>Gradle>Gradle JDK>11 version).

Try opening several projects, however the IDE sometime still show the redline code, but the app can still debug/run as usual. Latest method I used, File>Invalidate Caches... And IDE haven't show any redline code.

*Remark: Don't know how long the latest method I used will work.

LBIRD S.E.
  • 31
  • 3