Could not find a JavaToKotlinConversionProvider - android-studio

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.

Related

Android Studio stuck at "Analyzing..."

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.

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.

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 :)

Auto complete not working in android studio

I am a starter in android development and I started off with eclipse.. But it started giving lot of problems. So I switched to android studio. Got it set up successfully and for couple of weeks it was ok. Now, for some reason, the auto complete feature is not working. It is not giving any choices while typing, so I tried ctrl-enter. It says no suggestions. I browsed through similar queries and tried the following.
Disabling Power Save in File menu.
Checking basic complete and smart type completion in IDE settings (editor)
Invalidate caches and restart.
But non of these seems to work.
Try with CTRL + space and you will get the drop down .
I had the same issue and solved it.
Go File> Invalidate Caches / Restart... > Click at Invalidate and Restart
Then you can also check if Power Save Mode on File menu is disabled.
Source: Android Studio - Auto complete and other features not working
These following steps are working for me:
Close android studio
Go to path/.AndroidStudio3.5/system/ delete caches folder
Start Android Studio
You should Try this way File->Invalidate Caches/Restart or you can find solution by using below link
https://stackoverflow.com/a/58214439/11404883
In my case on Android Studio Artic Fox edition there were strange problems with autocompletion and suggestions because of old version of Gradle plugin. I have updated to
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21'
and it worked as expected. Hope it will be helpful for new visitors like in my case it would.
In Ubuntu 21 I had tried
$ rm -rf ~/.cache/Google/AndroidStudio2020.3/caches/
I followed all the steps from various answers and sources, still didn't get it to work. Code completion and Syntax Highlighting was not working.
I restarted using Invalidate Caches and did Gradle Sync atleast 10 times.
It was working in main flavor, but not in other flavors! In this project we have multiple flavors.
So finally the solution was found using
Android Studio product flavors only recognized one out of two flavours
Just selecting the correct Build Variant solved my issue.
Delete everything inside caches folder
C:\Users\<user_name>\AppData\Local\Google\AndroidStudio<version_x>\caches
and restart android studio

In android studio,cannot load 2 facets-unknown facet type:android and android-gradle

When I open android studio I am getting an error- "Error loading project: Cannot load 2 facets. When I clicked to see the error the following appeared
"2 facets cannot be loaded. You can mark them them as ignored to suppress this error notification.
Unknown facet type:'android', Unknown facet type:'android-gradle'
I tried to add facets ( In Project Structure > Project settings > Modules > clicked project name, then clicked Android as well as Android-Gradle) But both showed as "cannot load facet, unknown facet type." Under Project settings > Facets > both Android and Android-Gradle are displayed as 'Invalid facets'.
My project was running smoothly. This problem occured when I force-closed my laptop before exiting android studio as everything got stuck. After that whenever I open the android studio this problem occurs. I am not able to run my project. Can anyone please help me to solve this?
Just enable Android Support plugin.
Click Ctrl+Alt+S in Windows or Meta+Comma in Mac.
In top search bar type "plugin".
On right side it will show a list of plugins, find Android Support plugin, check it and click OK at the bottom of screen.
This is how it looks:
In Android Studio go to
File -> Settings - > Plugins -> Enable "Android Support" Plugin.
File, Then Settings->Plugin->Enable/Renable Plugin --> Apply --> Restart
This problem occured when i'd updated Android Studio.
In case nothing from other answers works, you don't have another option, except removing broken settings and making clean setup.
So what i am suggesting:
Use Settings Repository Feature to store personal IDE settings
close studio
remove .AndroidStudioX folder from user folder
re-launch studio, do not copy settings from previous version (because settings probably broken and auto-import couldn't import it well)
import personal settings from Settings Repository
For me I went to Settings -> Plugins and de-selected Gradle then immediately re-selected it. Android Studio then asked if I wanted to enable Groovy so I said yes and let it restart and now everything is happy again! (it was checked, but clearly somewhere deep down not truly enabled, so toggling the check-box sorted it)
Not sure if my cause was installing Flutter, but I did have to disable the Flutter plugin before I could build again.
I had the same problem with an ever-increasing number of facets - first 2, then 4, then 5 - and none of the above solutions worked. My solution (Android Studio 3.3, OS X) was to delete ~/Library/Preferences/AndroidStudio3.3/disabled_plugins.txt, which contained org.jetbrains.android and org.jetbrains.maven
I imagine if you have deliberately disabled plugins then you'll have to disable them again manually, but I was able to load all facets again.
Go To ->File->Settings->Plugins->disable/enable Android Support Plugins->Press Ok
Just re-enable Android Support plugin. Then it will ask to restart.
Restart them thats it
I faced this issue in Android Studio 3.2.1 I had to re-import my project after that it works.
I was facing this problem, I tried everything but nothing worked but then I remembered that I updated Android Studio just few hours back and then I enabled the plugins in the Android Studio and restarted it and it worked.
File -> Settings -> Plugin and then just press ok. It will ask to restart the android studio and please restart it.
For me I had to uncheck the plugin Android APK Support. I clicked Apply and then Ok to close the window. Android Studio prompted me to restart the program, and the program restarted. I checked the Android APK Support plugin again and restarted the program. And then I selected File -> Sync Project with Gradle Files
Then it worked just fine.

Resources