I added the stripe sdk to my kotlin app and can no longer build my application.
Addition to grade file:
implementation 'com.stripe:stripe-android:16.8.2'
Build error:
/Users/username/.gradle/caches/transforms-2/files-2.1/6fabb8e15860d0b2ea75a56e95ee9aa5/jetified-kotlin-stdlib-common-1.5.0.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.16.
Removing the stripe dependency fixes the issue. I also tried deleting the cache folder referenced in the error message and it was just recreated and the issue persisted.
The problem seems to be a mismatch between the kotlin library used in your project and the version of the plugin that is not compatible.
Upgrade your Gradle version by going to File>Project Structure.
Ps:(also try downgrading your kotlin version to one of the 1.4.x versions)
Another developer ran into this same issue and solved it by upgrading Gradle
I updated my gradle like this
// id 'org.jetbrains.kotlin.android.extensions' deprecated
id 'kotlin-parcelize'
and in project gradle add this
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32"
so now it works.
Related
Android Studio Upgrade Assistant recommends to update Android Gradle Plugin from version 7.0.0. to x.x.x. However, the problem is that it alerts "Cannot find AGP version in build files". I'm struggling with this message and I found the empty AGP version in my project structure. I've already checked
gradle-7.3-bin
inside
C:\Users\abc.gradle\wrapper\dists' and allocated 'Gradle user home'
as 'C:\Users\abc\.gradle.
That dropdown button below the 'Android Gradle Plugin Version' has nothing and I want to find out why and how to fix it. Is this related with the AGP upgrade?
I got the same error when in Android Studio I tried to use Tools > AGP Upgrade Assistant.
For those who don't know, the Android Gradle Plugin is the dependency com.android.tools.build:gradle: specified in the project-level build.gradle (to be clear, not my module-level build.gradle).
In my case, the problem was that my project-level build.gradle file specified the version of the Android Gradle Plugin using a variable rather than hardcoding the version.
My project had the following variable in my gradle.properties and referenced it in my build.gradle file:
gradle_version=7.2.2
It referenced it in the project-level build.gradle file like this:
classpath "com.android.tools.build:gradle:$gradle_version"
To fix the problem, I changed my project-level build.gradle file from this:
classpath "com.android.tools.build:gradle:$gradle_version"
To this:
classpath 'com.android.tools.build:gradle:7.3.1'
After that change, Tools > AGP Upgrade Assistant stopped complaining "Cannot find AGP version in build files". Furthermore, I was able to use AGP Upgrade Assistant to upgrade from com.android.tools.build:gradle:7.2.2 to com.android.tools.build:gradle:7.3.1.
I recently downloaded Android Studio Bumblebee and it helpfully asked whether I wanted to upgrade to Android Gradle Plugin 7.1.0, the version that shipped alongside Android Studio Bumblebee.
After upgrading, I get a build error:
Unable to load class 'com.android.build.api.extension.AndroidComponentsExtension'.
This is an unexpected error. Please file a bug containing the idea.log file.
And looking at the idea.log file, I see:
A problem occurred evaluating project ':main'.
at org.gradle.initialization.exception.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:103)
...
Caused by: org.gradle.api.GradleScriptException: A problem occurred evaluating project ':main'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
...
Caused by: java.lang.NoClassDefFoundError: com/android/build/api/extension/AndroidComponentsExtension
at androidx.navigation.safeargs.gradle.SafeArgsPlugin.apply(SafeArgsPlugin.kt:73)
at androidx.navigation.safeargs.gradle.SafeArgsPlugin.apply(SafeArgsPlugin.kt:42)
...
Caused by: java.lang.ClassNotFoundException: com.android.build.api.extension.AndroidComponentsExtension
Which means I can't run my app and I need to downgrade the AGP 7.0 to get things working again. How do I fix this and upgrade to Android Gradle Plugin 7.1.0?
Updating Navigation Safe Args
These lines are the important ones to look at:
Caused by: java.lang.NoClassDefFoundError: com/android/build/api/extension/AndroidComponentsExtension
at androidx.navigation.safeargs.gradle.SafeArgsPlugin.apply(SafeArgsPlugin.kt:73)
at androidx.navigation.safeargs.gradle.SafeArgsPlugin.apply(SafeArgsPlugin.kt:42)
This indicates that the error is coming from the Navigation Safe Args plugin.
As per the Android Gradle Plugin 7.1.0 release notes:
AGP APIs that the Navigation Safe Args Gradle plugin depend on have been removed. AGP 7.1 does not work with Navigation Safe Args versions 2.4.0-rc1 or 2.4.0, but will work with versions 2.5.0-alpha01 and 2.4.1. In the meantime, as a workaround, you can use AGP 7.1 with a snapshot build of Navigation Safe Args, Navigation 2.5.0-SNAPSHOT. To use the snapshot build, follow the snapshot instructions with build id #8054565.
As Navigation 2.4.1 is now available, you can upgrade to that version of Navigation to gain the fix:
Backported from Navigation 2.5.0-alpha01: Safe Args now depends on Android Gradle Plugin version 7.0.4. This means that Navigation Safe Args will no longer be compatible with Android Studio versions prior to 7.0, but is now compatible with Android Gradle Plugin 7.1.0 and higher.
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0'
// Update this line to use 2.4.1
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.4.1"
}
Note that you should always use the same version of the Navigation library as the Safe Args plugin (i.e., your app should also use Navigation 2.4.1): you should not try to use the Navigation 2.4.1+ Safe Args plugin with an earlier version of Navigation (such as 2.3.5).
Note on Firebase Perf Plugin
Note that you might see this same error when you are using:
classpath "com.google.firebase:perf-plugin:1.4.0"
With an idea.log of that states:
Caused by: java.lang.NoClassDefFoundError: com/android/build/api/extension/AndroidComponentsExtension
at com.google.firebase.perf.plugin.FirebasePerfClassVisitorFactory.registerForProject(FirebasePerfClassVisitorFactory.java:54)
at com.google.firebase.perf.plugin.FirebasePerfPlugin.perform(FirebasePerfPlugin.java:145)
at com.google.firebase.perf.plugin.FirebasePerfPlugin.lambda$apply$0(FirebasePerfPlugin.java:107)
As per the Firebase Perf Plugin 1.4.1 Release Notes:
Migrated away from the deprecated Android Gradle plugin APIs.
So you should upgrade to 1.4.1:
classpath "com.google.firebase:perf-plugin:1.4.1"
In my case, the problem was with hilt version. I've updated to the last 2.40.5 and it's work.
If you don't have hilt dependency in your project the best way to find a library that throws the exception during gradle sync it's to check idea.log file.
And find something like that.
Caused by: java.lang.NoClassDefFoundError: com/android/build/api/extension/AndroidComponentsExtension
at dagger.hilt.android.plugin.HiltGradlePlugin.configureBytecodeTransformASM(HiltGradlePlugin.kt:257)
Have a good coding :)
Update: the issue is now fixed in AGP 7.1.2.
Firebase perf plugin 1.4.1 will only work with AGP 7.1 if your project doesn't depend on any library that uses multi-release JARs, aka MRJARs.
A popular dependency that uses MRJARs is moshi.
The root cause of the issue lies in the Android Gradle Plugin.
The Firebase Perf team made the following statement:
Here are some updates:
AGP v7.2.0-beta01 was made available last week and will work with the latest perf plugin v1.4.1.
AGP v7.2 RC1 is scheduled to release on the 1st of March and AGP v7.2 final is scheduled on the 9th of March.
In the meantime, here are some workarounds worth trying out:
Use perf plugin v1.3.5 with AGP v6.8.3. Perf plugin v1.3.5 and below is not compatible with AGP v7.0.0+; in order for the perf plugin to be compatible with AGP v7.0.0+, we have to use the new transform API, which introduces the build failure where even if the perf plugin filters out classes in the META-INF/ directory from instrumentation, AGP still tries to visit the class to collect information about it. However, AGP is working on a more permanent fix for this where we will have an option to filter out failed classes completely.
Wait until March 9 to integrate the latest perf plugin version and AGP.
Try a beta version of AGP with the latest perf plugin version and move to the production version after March 9th.
Stack trace:
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.lambda$apply$0(DefaultScriptPluginFactory.java:133)
at ...
Caused by: java.lang.NoClassDefFoundError: com/android/build/api/extension/AndroidComponentsExtension
at com.google.firebase.perf.plugin.FirebasePerfClassVisitorFactory.registerForProject(FirebasePerfClassVisitorFactory.java:54)
at com.google.firebase.perf.plugin.FirebasePerfPlugin.perform(FirebasePerfPlugin.java:145)
at com.google.firebase.perf.plugin.FirebasePerfPlugin.lambda$apply$0(FirebasePerfPlugin.java:107)
at org.gradle.api.internal.plugins.DefaultPluginManager$2.execute(DefaultPluginManager.java:258)
at ...
You can do this thing. Perfectly working for me
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
id "com.google.dagger.hilt.android" version '2.41' apply false
id 'androidx.navigation.safeargs.kotlin' version '2.4.0' apply false // use this one
// classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.4.0" (will not work now)
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Updating Hilt to '2.40.5' and firebase:perf-plugin to '1.4.1' worked for me.
In my case I faced issue on secrets-gradle-plugin. Initially I used version 2.0.1(latest). After I downgrade into 1.3.0. It worked for me.
In project's root build.gradle file:
dependencies {
classpath 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:1.3.0'
}
In app-level build.gradle file:
plugins {
id 'com.android.application'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}
I fixed the issue by downgrading the version of navigation to 2.3.5
def nav_version = "2.3.5"
after testing, use navigation 2.4.0 and AGP 7.0.4 work fine
In my case i had to update Maps plugin..
Upgrade your navigation safeargs version to latest and everything will be fine. It worked for me. Here is [the link ] (https://developer.android.com/jetpack/androidx/releases/navigation "Navigation safeargs google documentation")! to get latest safeargs version.
In my React Native app, I got an error about incompatibilities with gradle 6, so I looked in my project structure to find out which version of gradle I was running in my project. I found this line in gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
and this line in build.gradle
classpath("com.android.tools.build:gradle:3.4.2")
What I Want To Know: What's the difference between the reference to gradle in each of these files? In other words, how is version 5.5 being used in my project, and how is 3.4.2 being used?
distributionUrl represents Gradel Version where as classpath represents Android Gradle plugin version.
Gradel vs Android Gradle plugin: Reffer this difference between android gradle plugin and gradle
Gradle is the build system.
You can use it with a lot of plugins. One of these is the plugin for Android.
It is used to provide processes and configurable settings that are specific to building and testing Android applications.
For greater details and mapping of the above two type of versions refer the following URLs
https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
https://developer.android.com/studio/releases/gradle-plugin#updating-plugin
I hope this answer has cleared your doubts.
I added
apply plugin: 'com.google.firebase.firebase-perf'
and when I ran build script I got
/transforms/FirebasePerformancePlugin/dev/debug/174/module-info.class:
D8: Unsupported source file type
What kind of problem it could be?
I updated all plugins, play services, and Android Studio, but with no luck
I Solve This issue by updating gradle version
classpath 'com.android.tools.build:gradle:3.5.3'
Update: Android Gradle Plugin 3.5.0 fixes this. See this issue and this one issue, both fixed.
(Unfortunately, in my project, this other issue still remains even in 3.5.3.)
I started getting the same error after updating a (company internal) library dependency, but then I kept getting it even after reverting that update. Very strange!
> Task :app:transformClassesAndResourcesWithR8ForBetaRelease FAILED
R8 is the new Android code shrinker. If you experience any issues, please file a bug at
https://issuetracker.google.com, using 'Shrinker (R8)' as component name. You can
disable R8 by updating gradle.properties with 'android.enableR8=false'.
.../transforms/FirebasePerformancePlugin/beta/release/66/module-info.class:
D8: Unsupported source file type
The only thing I found that helped was to do what the Gradle build output says and temporarily switch back to ProGuard, with:
android.enableR8=false
in gradle.properties.
This issue was fixed somewhere between Android Studio 3.5 Beta 2 and Android Studio 3.6 Canary 5, there were a bunch of similar issues with module-info.class.
In my case to fix issue I had not only update Android Studio, but also update gradle plugin.
Steps is:
Install new version alongside your stable version (You also can configure current version to use updates from canary chanel)
More info here
Download link (I downloaded 3.6 Canary 5)
After you installed new Android Studio update grade plugin:
in
gradle/wrapper/gradle-wrapper.properties
chande distributionUrl to
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
Don't forget Build->Clean Project
Turn off Firebase-performance plugin.
Android Studio 3.6 Canary 1 has this issue too.
I didn't find another way to release build my project.
i solve this problem with 3 steps:
1.update the "distributionUrl=https://services.gradle.org/distributions/gradle-5.6.4-all.zip"
2.update the "classpath "com.android.tools.build:gradle:3.6.3"
3.update the Studio 3.6.3
in other way(i don't like it)
//apply plugin: 'com.google.firebase.firebase-perf'
...
//classpath "com.google.firebase:perf-plugin:1.3.1"
I'm trying to execute gradle wrapper for an Android project, and this error is raised:
A problem occurred evaluating root project 'myapp'.
> Gradle version 1.10 is required. Current version is 1.12. If using the gradle wrapper, try editing the distributionUrl in /Users/dude/myapp/gradle/wrapper/gradle-wrapper.properties to gradle-1.10-all.zip
My wrapper task in build.gradle looks like this:
task wrapper(type: Wrapper) {
gradleVersion = "1.12"
}
I recently updated to Gradle v1.12 via Homebrew. Is it not supported or something? If so, where can I check this sort of thing?
A particular version of the Gradle Android plugin requires a particular version of Gradle (at least for now), and it seems that your version of the Gradle Android plugin requires Gradle 1.10. You might find more information on this in the documentation for the Gradle Android plugin.
PS: The wrapper task above creates the files necessary to run Gradle with the (generated) gradlew script, which is the preferred way to run Gradle (no manual install, every build can specify in its gradle-wrapper.properties which Gradle version it needs).
The version of Android gradle plugin needs to be compatible with the version of Gradle. Checkout the version compatibility mapping table hereļ¼
http://tools.android.com/tech-docs/new-build-system/version-compatibility
I had the same problem. It turned out that the old Android Studio created gradle related files one level above my application folder. In my case, the path was in ~/git/, and my project was at ~/git/myproject. I used Android Studio RC2 now, and no matter how I changed the config within the project, gradle still wanted to use the old 1.10 version. Therefore, I re-checked out the project a new path, and updated the gradle version reference within the project, then it compiled.