Android Studio 3.1: Erroneous unresolved links in the editor

I am using Ubuntu 17.10 and I just updated Android Studio from version 3.0.1 to 3.1. Here is the version information in Help → About:

Android Studio 3.1 Build #AI-173.4670197, built on March 22, 2018 JRE: 1.8.0_152-release-1024-b01 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains sro Linux 4.13.0-37-generic 

Unfortunately, although earlier in my (first-ever) Kotlin project, the IDE could resolve links related to Android, in the new version it was not able to. Here is a screenshot showing what I mean:

Android Studio 3.1 claims that the basic Android functions, such as setContentView() , do not exist, and constantly encourages me to create an abstract function for it, which I clearly do not want to do. However, if I press the build button, I will get BUILD SUCCESSFUL in 8s .

Does anyone know why my editor does this, and how can I get the functions and classes related to Android for the correct resolution again?

Edit: Refresh: I have more information on this issue, but it is still not resolved:

  • Build -> Clean, and then Build -> Rebuild does not help.
  • File -> Invalidate Caches and Restart doesn't help either
  • Also, manual Gradle synchronization is not performed.
  • Another project written in Java instead of Kotlin is working fine.
  • Link to the project I'm having problems with (open source)
+45
source share
5 answers
  • Exit Studio.
  • Delete .idea / (it seems to me that this is most important), build /, app / build directories.
  • Launch Studio
  • Set settings -> Build -> Gradle settings back (the last stable local distribution of Gradle in my case).
  • Cleaning and restoration project.

Helps me.

+63
source

Delete {projectDir}/.idea/libraries , then go to File → Sync Project with Gradle Files.

+67
source

I had the same issue on Android Studio 3.2.1.

The solution was to use stable com.android.tools.build:gradle{.2.1, rather than alpha ...

In the build.gradle project, change the version as shown below (or if there is a newer stable version)

 dependencies { classpath 'com.android.tools.build:gradle:3.2.1' } 

If this does not solve your problem, than in File >> select Invalidate caches / Restart ... and in the next dialog box select Invalidate and Restart

1 step

2 step

+3
source

For me, this step works:

I) Delete .idea folder from android studio

II) Go to File> Invalid Caches / Restarts

Iii) He will ask you to confirm and click on cancel and restart.

Iv) Go to Build> Clean Project

V) Go to Build> Rebuild project

Try it out.

Good coding!

0
source

I tried all the solutions suggested here, but they did not work. What helped me was to disable and then enable the Kotlin plugin again.

0
source

Source: https://habr.com/ru/post/1276145/


All Articles