Android Studio stuck at "Analyzing..." - android-studio

In my Android project (Android 4.2 Canary 15), completion does not work anymore, and neither does syntax highlighting. This is happening in one Android project only (the others work well).
I have tried to clean, rebuild the project, create a new project and import files, but no changes... I have tried to delete .idea directory and all .iml files, but not better...
In the "File" menu, I've just tried the option "Invalidate caches / restart" and now all classes in my project are blocked at the state "Analyzing..." and completion still does not work...
Build and run project work, and my application starts well on my phone, but all intellij features
are inactive.

It appears that the Kotlin plugin was, indeed, the culprit.
Today (24 May 2021), a new version was released 1.5.10, and as soon as I installed it, everything went back to normal.
Synopsis: After upgrading from version 1.4.32 of Kotlin plugin to 1.5.0, code inspection, completion, linking to sources, javadocs, etc. all stop working (stuck at "Analyzing..." as the images here and here show), and only return for a few seconds/minutes when sth triggers a new analysis (eg. a gradle build, commit, loading new files, etc).
History of the plugin updates for reference can be found here

you can just change the Kotlin version to something else and then gradle sync again
This will solve the issue
you will find it in build.gradle file(project)
ext.kotlin_version = "1.5.10" //I used this
you can also roll back to your previous version. If you want this should not recreate the issue.

Android Studio -> File -> Invalidate Caches and Restart
Nothing else helped me.

Try it:
File --> settings --> Plugins --> Android ButterKnife Zelezny --> disenable

From my project I deleted the files
.idea/gradle.xml
.idea/workspace.xml
and it solved it for me.
Seems to be that I had previously configured the project's gradle incorrectly and even after several reinstalls I wasn't getting any luck.

I just update the Koltin version to 1.5.20 and it works!!

Kotlin version 1.4.10 magically stopped working in the IDE.
The problems are not related to the IDE version but rather to the integration of the kotlin plugin and the IDE.
kotlinVersion = '1.5.10'
classpath 'com.android.tools.build:gradle:4.2.2'
Then Sync Project and Compile.
Finally you can see that the problem of Analyzing disappears and the IDE becomes intelligent again.
It is possible that after updating kotlin you have minimal errors in other libraries so you also have to update or fix them (I happened with Room)
GL

This is a looming AS IDE issue correlated with the Kotlin plugin, Have tried literally every answer here with tooth and nail, but nothing worked. There were chains of errors. Finally, removing the AS cache folder manually worked for me -
%USERPROFILE%\AppData\Local\Google\AndroidStudio2020.3\caches
Artic fox sucks!
You may also try to update the Kotlin plugin to the latest if possible and see if it makes any difference.

The one solution that worked for me (working in Canary 2021.1.1) was to completely uninstall the Kotlin plugin from Android Studio, restart, let Android Studio install it automatically, and then everything worked again.
The root cause of this issue was that Android Studio "accidentally?" updated Kotlin plugin to an M1 version (I'm on x64), namely 211-1.5.30-M1-release-141-AS7442.40, when updating the plugin. I'm not sure why, but from now a check of what is going to be updated in Canary seems mandatory to avoid these kind of stuff to happen.

this issue comes from plugins
1- update plugins
2- step by step disable plugins to find incorrect plugin
3- as advance people please report issue to providers for solve the problem

in Arctic Fox version (2020.3.1) I fixed it by updating Gradle Plugin version 7.0.0.

This solution is 100% working for the above issue
ext.kotlin_version = "1.5.21"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

In my case, I just update the dependency "androidx.core:core-ktx:1.3.2" to "androidx.core:core-ktx:1.6.0". And it's gone, working normally

After many hours, I finally uninstalled Android Studio, delete all Android directory, clean registry and reinstall Android Studio stable version.

disable Compose plugin. the only way work for me.

If you are using
Jetpack Compose 1.0.5 (haven't tested with 1.0.0-1.0.4 but they should work too)
Java 11
Kotlin 1.5.31 (tested 1.5.10 working too)
the other answers don't work
What works is the following in your project build.gradle:
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "11"
useIR = true
freeCompilerArgs += [
"-Xallow-jvm-ir-dependencies",
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true"
]
}
}
(compose compiler was blocking Kotlin compiler from completing jobs)
and Invalidate Caches & Restart

for me file analysis is only getting stuck in kotlin files with co-routines. upgrading co-routines version to the latest helped me.

Sometimes some files are stucking to me at analazying, I resolve that issue by:
Just copy / paste that file with the different name
Then remove the original file and rename the copied file with the original name.

Related

Android Studio won't identify Gradle's Version Catalog nested dependency

I've heard recently about Gradle's Version Catalog and decided to give it a try... Everything setup, Gradle wrapper set to gradle-7.0-rc-2 and everything runs fine and I am able to build.
Android Studio, however won't identify nested dependencies, showing this exception:
Cannot access class 'org.gradle.accessors.dm.LibrariesForLibs.AndroidxLibraryAccessors'. Check your module classpath for missing or conflicting dependencies
app/build.gradle.kts
implementation(libs.androidx.coreKtx)
gradle/libs.versions.toml
androidx_coreKtx = "androidx.core:core-ktx:1.5.0-beta03"
How may I get rid of that AS error?
It looks like issue was fixed by IntellIJ team (https://youtrack.jetbrains.com/issue/KTIJ-1221) a while ago, but stable Android Studio uses fairly old IntelliJ platform.
On the bright side, it appears to be fixed in the new Android Studio Canary (Android Studio Arctic Fox | 2020.3.1 Canary 15 works fine).
I've created an issue on Google's bugtracker. I know the chance is slim, but maybe they notice it and backport the fix to 4.2:
https://issuetracker.google.com/issues/187326581
Have you tried to rename androidx_coreKtx to androidx-coreKtx? After that change you should be able to use implementation(libs.androidx.coreKtx)
Make sure that you have enableFeaturePreview("VERSION_CATALOGS") in your settings.gradle(.kts)

could not find extension implementation class org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRootsManager

My project works and builds successfully on my Mac but I cloned from github and although Android Studio appears to work normally, the project wouldn't build. I setup this project using Kotlin DSL.
Gradle sync failed: could not find extension implementation class org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRoot
Tried invalidate cache, removed all .gitignore rules but it's still the same.
Any ideas?
I had the same issue (Note : Running Linux/Ubuntu 20.04 LTS and Android Studio 4.1.1).
Things I tried that did NOT work and error persisted :
Invalidate Caches / Restart
Reboot
Nuking the .gradle and .m2 folders
Android Studio re-install
Downgrade kotlin gradle plugin from 1.4.21 to 1.4.10
What did work :
Moving the project to a different folder/location on disk and open Android Studio
As soon as I moved the project back to the original location I would start getting the same error. This lead me to believe it was some sort of caching issue, separate from the caches "invalidated".
Solution :
Android Studio / Intellij creates a hidden folder called :
On Linux :
AS : ~/.cache/Google/AndroidStudioX.X
IJ : ~/.cache/Jetbrains/IntelliJIdea2020.X
On Mac :
AS : ~/Library/Caches/Google/AndroidStudioX.X
IJ : ~/Library/Caches/Jetbrains/IntelliJIdea2020.X
On Windows:
AS : %HOME%\AppData\Local\Google\AndroidStudioX.X
IJ : %HOME%\AppData\Local\Jetbrains\IntelliJIdea2020.X
Inside this folder are other various folders, however I removed the relevant workspace file (workspace/[project name].[hashed value].xml) after which problem went away when opening the project again, from its original location.
So it appears that "Invalidate Caches / Restart" does not "Invalidate" all caches!
I hope this resolves you problem!
Update
As this answer has had quite a few upvotes it would appear that this might be a ongoing bug with Intellij. If anyone has this problem, before resolving with the suggested solution consider checking there isn't an open issue on the bug tracker and submitting a new issue : https://youtrack.jetbrains.com/issues
Feel free to edit this update with issue if one is opened.
Update 2
Issue opened by #GeniusRUS :
https://youtrack.jetbrains.com/issue/KT-44937
For Mac users delete the following file:
~/Library/Caches/Google/AndroidStudio4.1/workspace/<your_project_name>.58dfbe93.xml
PS: Thanls #Mark Keen for solution.
basically i deleted .idea folder and then invalidate and restart ... error goes away and built successfull.
This probably isn't the "correct" solution, however, it worked for me. I had to download a newer (Canary) Version of Android Studio to get this error message to go away and to finally build my Android project once again. I found this YouTrack JetBrains issue where people also suggested reverting to previous, known working, versions of Android Studio to get their projects to build again.
This is a SUPER frustrating issue and I hope that one of the approaches resolves your build issues for you!
Here are the Android Studio Versions Download page for convenience.
After moving projects and files around I had also the honor to enjoy this error in Android Studio 4.1.1 (under Windows 10). Unfortunately, none of the above solutions worked for me but they helped me to narrow down the issue.
So, I found that there is a folder with workspaces under:
%HOME%\AppData\Local\Google\AndroidStudio4.1\workspace\
There are a couple of *.xml files named like the android projects. I deleted the one that didn't work.
Then switched back to Android Studio and used the Files > Invalidate Caches / Restart... feature. Android Studio restarted and the problem was fixed.
Bonus: How I found the workspace folder?
I used the Procmon.exe from Sysinternals where I filtered by the Process Name = studio64.exe. I then used the elephant-with-the-arrow button (Sync Project with Gradle Files) in Android Studio. At the end of the recording there was the workspace folder that Android Studio used just before Gradle failed.
I added a "problem" ticket to YouTrack, where I described my case in detail.
The support agent said the issue has already been fixed in the IDEA 2021.1 platform.
And also gave recommendations for this case
Link to issue
https://youtrack.jetbrains.com/issue/KT-44937
I fixed the issue by changing the root project directory name. You can try that.

Error related to resources_ap after upgrading to Android Studio 3.4

I upgraded Android Studio 3.4 today. I am no longer able to run the the app. I have cleaned the project, restarted Android studio many times. I have also invalidated cache to no avail.
I am getting the following error when installing the app:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexWithInstantRunSlicesApkForDebug'.
> java.lang.RuntimeException: java.io.FileNotFoundException: E:\...\app\build\intermediates\instant_run_split_apk_resources\debug\instantRunSplitApkResourcesDebug\out\slice_1\resources_ap
Could anyone offer a tip on how to remedy this?
Edit:
I have two projects with different behaviors related to this issue:
Project A initially had this issue. I disabled Instant Run per the answer, the problem was solved. I enabled Instant Run later, and Project A is still working fine.
Project B also had this problem that has been remedied by turning of Instant Run. However, its problem will occur as soon as Instant Run is turned on. I do not what difference between these two projects results in this. One suspect is library C project. Library C is a part of Project A (i.e. its source code, resources are in Project A). However, Project B uses the aar of Library C as a module.
Issue should be fixed in Android Studio 3.4.2.
EDIT: Here is my old answer on how to fix it in Android Studio 3.4.0 and 3.4.1:
Using Gradle 5.4 instead of 5.1.1 helped me with this error.
Update gradle-wrapper.properties file with:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-all.zip
Please note I haven't tested older Gradle versions, so it's possible even (for example) 5.2 version will work. You can see all Gradle releases here - https://gradle.org/releases/
Switching off Instant Run as a workaround (File/Settings/Instant Run) seems to eliminate the problem.
According to OP it is possible to turn Instant Run back on without the problem recurring for some projects.
There is no need to turn off Instant Run.
Just delete the '.gradle' directory in the project and build directory inside the 'app' module.
Perform Clean Project and Rebuild Project.
This will solve the issue.
This is caused by "instant run" feature in android studio 3.4 , you can disable it by:
Open the Settings or Preferences dialog. Navigate to Build, Execution, Deployment > Instant Run. Uncheck the box next to Enable Instant Run
Enjoy...!
Go to your project folder and move everything from ...\app\build\ to some other folder outside project. (to clear build folder with back up)
In my case clearing the build folder solved the probem, till then i was disableing the instant Run option for every new install.
I tried both "Gradle 5.4" and "Switching off Instant Run" solutions but they didnt work until I turned on "Wait for Debugger" option until "Developer Options" in my phone (Huawei Mate 10). I have confirmed that this is only working with "Instant Run" off as well.
This problem happened to me on Windows. I solved it by disabling instant run.
I also have the same Android Studio version on Linux and it works fine with instant run enabled.
This is fixed in 3.4.2. Just update to the latest version of Studio. https://androidstudio.googleblog.com/2019/07/android-studio-342-available.html
This same error happened when I updated to Android Studio 3.4.2, I updated the tools-build-gradle to 3.4.2 and the problem disappear.
Switching off Instant Run as a workaround (File/Settings/Instant Run) seems to eliminate the problem.

Could not find a JavaToKotlinConversionProvider

I'm not able to create a new project in the android studio. I am getting a warning message
java.lang.RuntimeException: Could not find a
JavaToKotlinConversionProvider, even though one should be bundled with
Studio at
com.android.tools.idea.npw.model.JavaToKotlinHandler.getJavaToKotlinConversionProvider(JavaToKotlinHandler.java:56)
at
com.android.tools.idea.npw.template.TemplateValueInjector.addKotlinVersion(TemplateValueInjector.java:410)
Go to Preferences -> Plugins -> Kotlin and update the Kotlin plugin to the last version even though you don't write your code in Kotlin.
I have the same error, I've juste disabled the kotlin plugin and after restarting the IDE, just re-enable it. After that final restart, every thing works fine.
Go to file and the plugin in android studio and update your Kotlin plugin...
I opened an old project (by old I mean another project) and did everything Android Studio said to give me a successful build (I faced some errors when I tried to build the project that I could build couple weeks ago and actually I fixed them, updating gradle and stuff like that, not code issues of course).
After that I could create new project same as before.
Update seems like in order to keep Android Studio happy we have to keep Kotlin plugin enabled, interesting.
I solved this problem by doing this:
File->Settings->Plugins
Click the Installed tab at the top.
Search "kotlin" and click the result that shows up.
Click Enable at the top right
settings>plugins>check Kotlin >Apply then Ok solved it for me.
It occurred due to migration from Android Studio 3.2 to 3.3
Goto File-->Invalidate Caches/Restart
This will solve the problem.

Android Studio not showing properties

I am experiencing a strange problem with Android Studio 2.2.3. No matter which widget is selected in Design View, the Properties View doesn't show the properties - it simply appears as shown below. If I click "View all properties" it goes completely empty.
How can I show the properties?
Restarting doesn't help. But after searching other Android Studio problems I found something that does work: File -> Invalidate Caches and Restart.
I have seen the same issue, Here is the fix: GOTO File > Invalidate Caches > Restart. After restart note that it takes a little more time to start but this will surely fix your issue.
One way I find to solve the problem, go to the little setting button on top right corner of "Attributes"->> "Attached side"->> "none", and everything shows. Try it!!
So after some trail and error,
I have found the solution of this problem, just update gradle version 3.0.1 and used sdk version 26, this worked for me :)
I have tried all the suggestions posted here and none of them worked. Even just reinstalling Android Studio didn't work.
You could try this:
uninstall Android Studio
delete the C:/Users/xxx/.gradle and
C:/Users/xxx/.AndroidStudiox.x folders which the installer left out
reinstall Android Studio.
It works and everything's back to normal now.
Window -> Restore Default Layout
Try this:
gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
File->> Sync Project With Gradle Files
Worked for me
Just go to Tool menu and here you see xml Action menu and just click Genrate Schema from xml file so it can solve your problem
To solve this problem, I did not need to reinstall Android Studio. Invalidating cache/restarting did not work. So I ended up deleting C:\Users\{your user here}\.AndroidStudio{version}. I had two AndroidStudio folders with different versions and deleted both of them. After starting Android studio all settings will be restored to default and you will have to select theme and etc. You do not need to delete gradle folder.
Close android studio
C:\Users\user name.AndroidStudio4.0\system\caches
delete everything inside the project cashes folder
I had the same problem when I installed android studio in my new PC and I found the solution.
My NDK was not completely installed or maybe it was corrupted so most of attributes were missing.
I reinstalled my NDK and the problem was fixed.
(compileSdk and targetSdk in gradle) You may have increased the values. Specify a lower version. And File > Invalidate Caches > invalidate and restart
After I did all the suggestions.
I fixed this by clicking "Help" -> "Check for updates" and just update.
Hope this helps :)

Resources