When building my project in Android Studio, I get the following error.
Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.16.
I have tried changing the Kotlin version in my project-level gradle file to almost every single stable release available without much success. The one or two stable releases of Kotlin that do make this error go away generate their own errors.
The current Gradle version 5.6.4 is not compatible with the Kotlin Gradle plugin. Please use Gradle 6.1.1 or newer, or the previous version of the Kotlin plugin.
jav.lang.noClassDefFoundError
Build file 'C:\Users\pictu\Downloads\ble-starter-android-master\ble-starter-android-master\app\build.gradle' line: 18
A problem occurred evaluating project ':app'.
> org/gradle/api/services/BuildService
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:227)
at
...
org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
... 130 more
Caused by: java.lang.ClassNotFoundException: org.gradle.api.services.BuildService
... 160 more
I've tried using multiDex, I've tried changing the Kotlin version, I've tried changing the compileSdkVersion + minSdkVersion + targetSdkVersion, but none of them worked. I've also looked at several SO posts, but I haven't found any that help my specific issue.
UPDATE 1: The error message points out this line specifically.
apply plugin: 'kotlin-android'
UPDATE 2: The answer to this SO post helped me get a little further. Now I am getting this cryptic stack trace that mentions something about a circular reference. I haven't been able to find out what a circular reference is in this context.
Invoke-customs are only supported starting with Android O (--min-api 26)
Stack trace:
com.android.tools.r8.a: Invoke-customs are only supported starting with Android O (--min-api 26)
at com.android.tools.r8.dex.r.a(:289)
at com.android.tools.r8.dex.r.a(:98)
at com.android.tools.r8.dex.r.b(:188)
at com.android.tools.r8.dex.b.a(:63)
at
...
Caused by: [CIRCULAR REFERENCE: com.android.tools.r8.a: Invoke-customs are only supported starting with Android O (--min-api 26)]
These are the two Stack Overflow posts that led me to my answer (1, 2).
You need to update your Gradle settings. I updated mine to Gradle version 6.1.1 using the chart in the answer to the first SO post I referenced.
The second thing you need to do is specify sourceCompatibility and targetCompatibility as JavaVersion.VERSION_1_8 in the compileOptions section of the app level Gradle file.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 11 months ago.
Improve this question
am having these errors after implementing facebook login in flutter. my code cant execute
e: C:/Users/HP/.gradle/caches/transforms-2/files-2.1/0c02c09b68f8e9b24bbbea025e769c0c/jetified-facebook-core-12.2.0-api.jar!/META-INF/facebook-core_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/HP/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/HP/.gradle/caches/transforms-2/files-2.1/38f92314671ee5340cbd0a5f71832b19/jetified-kotlin-stdlib-jdk7-1.5.10.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/HP/.gradle/caches/transforms-2/files-2.1/54f0714bcfdfdf9279ff034535934d1c/jetified-facebook-common-12.2.0-api.jar!/META-INF/facebook-common_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/HP/.gradle/caches/transforms-2/files-2.1/77bab1911042ab2c6d5cc0b2e2ee053c/jetified-kotlin-stdlib-common-1.5.10.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
Compilation error. See log for more details
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 1m 11s
Exception: Gradle task assembleDebug failed with exit code 1
. The binary version of its metadata is 1.5.1, expected version is 1.1.15
If you're copy pasting the code from your existing project instead of doing that write the code again. Also fiddle with the kotlin version in project level build.gradle and change the kotlin version to 1.5.31 . This is a kotlin version issue and not necessary due to the facebook SDK integration
Do these:
Make sure that the Kotlin version of your IDE is the same as the version declared in your gradle.build file.
in flutter_app/android/build.gradle change `ext.kotlin_version = '1.5.31' or whatever is suitable
You can fix this by changing kotlin version at build.gradle
from :
ext.kotlin_version = '1.3.50'
to :
ext.kotlin_version = '1.6.0'
or whatever the latest version of kotlin that you can see here and make sure to update Kotlin version to the latest in android studio as well
I updated Android Gradle Plugin to v3.6.2 and Grade to v6.3 in Android Studio. When I run a build with the compiler option --warning-mode all, I get the following two deprecation warnings:
1:
Configure project :app
Internal API constructor DefaultDomainObjectSet(Class<T>) has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use ObjectFactory.domainObjectSet(Class<T>) instead. See https://docs.gradle.org/6.3/userguide/custom_gradle_types.html#domainobjectset for more details.
at build_gklh609eby8f87cnghyses56.run(E:\Mahalaya\app\build.gradle:1)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
2:
Querying the mapped value of map(property(interface org.gradle.api.file.Directory, property(interface org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, E:\Mahalaya\app\build\generated\ap_generated_sources\debug\out)))) before task ':app:compileDebugJavaWithJavac' has completed has been deprecated. This will fail with an error in Gradle 7.0. Consult the upgrading guide for further information: https://docs.gradle.org/6.3/userguide/upgrading_version_6.html#querying_a_mapped_output_property_of_a_task_before_the_task_has_completed
It hasn't been a long time since I have started programming in Android, and I have no idea about what to do about these warnings. I can't understand what is being said in the links. Any help is appreciated.
Update: Gradle v6.5 shows the same warnings.
I think it is caused by one of these plugins. I have it too:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
And i also think they will update these plugins as well. So that the deprecation would not be a problem.
My flutter project was working properly, but when i tried to start the project recently, i got the android error below.
WARNING: The specified Android SDK Build Tools version (25.0.0) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3.0.1.
Android SDK Build Tools 26.0.2 will be used.
To suppress this warning, remove "buildToolsVersion '25.0.0'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
:app:properties FAILED
1 actionable task: 1 executed
FAILURE: Build failed with an exception.
*What went wrong:
null value in entry: outputFile=null
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I checked my app/build.gradle file but could not find buildToolsVersion '25.0.0'.My compileSdkVersion and targetSdkVersion are both 27.
I tried adding buildToolsVersion '26.0.2' , 27.0.3 and 28.0.1 which have already been installed, but i still get the same 25.0.0 error.
I can't tell what i'm doing or did wrong. Any help will be greatly appreciated.Thank you.
Really dumb suggestion, but have you tried a File->Invalidate Caches/Restart?
The error is in this bit:
FAILURE: Build failed with an exception.
*What went wrong:
null value in entry: outputFile=null
This likely has to do with updating the Gradle version in the project (perhaps unintentionally by click the "Upgrade gradle now" button), which caused a different parse of your Gradle script due to some form of backwards incompatibility.
If the project has source code control this would be pretty easy to check.
I'm using Android Studio 3.2 Canary 14 and am trying to migrate an existing project to use AndroidX. It sounds from https://developer.android.com/topic/libraries/support-library/androidx-rn that I have to have set android.enableJetifier=true (this was done automatically for me when selecting "Refactor to AndroidX.." option). I've also updated target API level to 28. Anyone else seeing this issue?
Failed to transform
'/Users/jooreill/.gradle/caches/modules-2/files-2.1/com.google.firebase/firebase-perf/15.0.0/6e68f6e44b0c9d91756f903547ee3853349ae666/firebase-perf-15.0.0.aar' using Jetifier. Reason: null. (Run with --stacktrace for more
details.) To disable Jetifier, set android.enableJetifier=false in
your gradle.properties file.
The above error occurs when I run "Clean". In general am getting multiple errors like following if a do gradle sync:
Unable to resolve dependency for
':app-instant#debug/compileClasspath': Failed to transform file
'play-services-measurement-base-15.0.2.aar' to match attributes
{artifactType=jetified-aar} using transform JetifyTransform
For those experiencing the same issue with Android Studio 3.2 Canary 15 (or later) after using "Refactor to AndroidX...":
I had to update some dependencies manually, i.e. change
classpath 'io.fabric.tools:gradle:1.25.1'
to
classpath 'io.fabric.tools:gradle:1.27.0'
in my project's build.gradle file.
If you're using dagger you have to upgrade to version 2.20 or later.
This is because some libraries are not yet compatible with the AndroidX refactor as mentioned under Known issues in the AndroidX release notes.
I had been experiencing this problem while running assembleAndroidTest on Jenkins.
The weirdest part was that this task ran sans any issues on my mac's terminal without any issues, but failed on Jenkins with-
Failed to transform file 'cucumber-java-1.2.5.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
Had been looking for solutions for a couple of days now, having worked though different suggestions - none of which worked.
Finally, disabling Jetifier in gradle.properties resolved it for me.
android.enableJetifier=false
I was able to work around a similar problem by excluding a certain library from being jetified, which can be done by adding to gradle.properties:
android.jetifier.blacklist = ...
Note that this option was added in Android Gradle plugin 3.3.0-rc01 as a temporary workaround.
See https://issuetracker.google.com/issues/119135578#comment5 for more details.
As per a statement on the AndroidX refactor made by a Google Engineer (Support Library) during the I/O session "What's New in Support Library?", Google already discovered bugs related to Jetifier in Android Studio 3.2 Canary 14.
Thus, it is advised to wait until Canary 15 (to be released the coming week) before starting the AndroidX migration process.
I had this same error after adding JDK 11 to my machine. It set itself as default JDK and this error started happening.
After setting JDK 8 as default, it was fixed.
I am working in an android project with Android Studio 2.2 that uses OpenCV 3.1.0 library. I imported the library according to this answer. The situation is the following:
When I compile the project for a device with API >= 21 (exactly API 23), everything goes well.
When I compile the project for a device with API < 21 (exactly API 19, the minimum API that I want to support), I get the following compilation error:
Gradle log
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithInstantRunForDebug'.
> java.lang.ClassNotFoundException: android.hardware.camera2.CameraAccessException
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithInstantRunForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)...
I found these similar questions:
Error: package android.hardware.camera2 does not exist OpenCV
Can't import import android.hardware.camera2 classes
In both of them the solution was to set the compileSdkVersion to minimum 21 (the version where camera2 API was introduced) and make sure that build.gradle files of the project and OpenCV match.
Unfortunately, it does not work for me. I still get the same error. Any idea?
My code is available here: Github repository.
Thanks for your help!
Finally, I found a temporal solution thanks to #JavierMollá.
Switching off Instant Run solved the issue. Go to File > Settings > Build, Execution, Deployment > InstantRun and uncheck Enable Instant Run to hot swap code....
Instant Run is a major feature of Android Studio, but unfortunately it seems that it is still work-in-progress... As #AndreKR suggests, it can be related with this issue #212672.