Related
I'm trying to build a project in my M1,
but I got this error when I run npx react-native run-android
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.work:work-runtime:2.7.0-beta01.
AAR metadata file: /Users/macpro/.gradle/caches/transforms-3/999e9d813832e06d8f1b7de52647a502/transformed/work-runtime-2.7.0-beta01/META-INF/com/android/build/gradle/aar-metadata.properties.
Android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "30.0.0"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath('com.android.tools.build:gradle:4.1.2')
classpath('com.google.gms:google-services:4.3.0')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
The error is being caused because one of your dependencies is internally using WorkManager 2.7.0-beta01 that was released today (which needs API 31). In my case it was CheckAarMetadata.kt.
You can fix it by forcing Gradle to use an older version of Work Manager for the transitive dependency that works with API 30. In your build.gradle file add:
dependencies {
def work_version = "2.6.0"
// Force WorkManager 2.6.0 for transitive dependency
implementation("androidx.work:work-runtime-ktx:$work_version") {
force = true
}
}
This should fix it.
This is because in work-runtime:2.7.0-beta01 the compileSdkVersion was updated to 31
you could either update your compileSdkVersion to 31
or use an older version of work-runtime that doesn't include this change
It is mentioned in the release notes of Version 2.7.0-beta01
Note: WorkManager Version 2.7.0 is required for apps targeting Android 12 (S).
for example, adding this to your build.gradle should fix it
api(group: "androidx.work", name: "work-runtime") {
version {
strictly "2.7.0-alpha04"
}
}
I had the same problem and I was able to solve it by changing the version of appcompat in the dependencies
What I had:
implementation 'androidx.appcompat:appcompat:1.4.0'
I changed it to:
implementation 'androidx.appcompat:appcompat:1.3.1'
Note that I am using java.
I experienced the same thing but was actually caused by work manager dependency that I upgraded to version 2.7.0
I simply downgraded it back to 2.6.0
dependencies{
implementation 'androidx.work:work-runtime-ktx:2.6.0'
}
I was also having the same issue in my project and now that issue is being resolved. The issue was because of the dependency androidx.work:work-runtime
But I would like to first mention that I was not using that dependency in my project directly (not added in my app level gradle), probably some other dependency was using that internally.
So what I did is forcefully downgraded its version by adding this
configurations.all {
resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
}
inside
android {
defaultConfig {
//here
}
}
and it resolved my issue.
In my flutter application, changed the compileSdkVersion and targetSdkVersion in android\app\build.gradle
android {
compileSdkVersion 31 // Changed to 31
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "com.example.blah_blah"
minSdkVersion 16
targetSdkVersion 31 //Changed to 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
And also, changed the kotlin version to '1.6.10' in android\build.gradle
buildscript {
ext.kotlin_version = '1.6.10' //change here
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
For those others facing the below error from last 36hrs (due to an update on androidx-core):
Error:
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.core:core-ktx:1.7.0-alpha02.
you can try to force use androidx to older version:
place it under android/app/build.gradle (under dependencies {} preferably or outside android {})
configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
}
Check the message
you can see the module used that has minCompileSdk (31) specified
Dependency: androidx.appcompat:appcompat:1.4.0.
To fix this issue momentarily you have to downgrade the dependency defined into your build.gradle, for example from appcompat:1.4.0 to appcompat:1.3.0 :
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
...
...
...
/* The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.appcompat:appcompat:1.4.0. */
}
I have changed this
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
to this
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
and it worked for me, also i was using Kotlin
In my case what worked for me was to change compileSdk version to 31
A similar issue on 4Nov, 2022. If someone is stuck due to this build issue please checkout
https://github.com/facebook/react-native/issues/35210
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
configurations.all {
resolutionStrategy {
// Remove this override in 0.66, as a proper fix is included in react-native itself.
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
}
Something in my project auto-updated causing a cascading effect. After first it was giving errors that I had intent-filters missing android:export="true/false" when targeting SDK 31. But my targets were set for SDK 30. I then setting targets to SDK 31 causing more issues. So I backed them out...but as a result of setting to SDK 31, other dependencies were trying to use BETA releases versus the stable version.
In my case, after rolling back to SDK 30, I then started getting an error similar to the OPs minCompileSdk (31) specified in a dependency's androidx.appcompat:appcompat-resources:1.4.0-beta01 - the stable version for appcompat is 1.3.1.
In my /<project>/platforms/android/project.properties file my appcompat dependency was set to:
cordova.system.library.19=androidx.appcompat:appcompat:1+
This was causing version 1.4.0-Beta01 to be updated/loaded. So I had to pin it back to:
cordova.system.library.19=androidx.appcompat:appcompat:1.3.1
I had similar problem and I updated one of the Gradle Script and it fix the problem;
// build.gradle (Module:testApp)
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "myproject.name.testApp"
minSdkVersion 16 // <--- must be same as under dependencies section
targetSdkVersion 30
versionCode 1
versionName "1.0"
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.6.0' // <--- Was showing 1.7, it fix problem
implementation 'androidx.appcompat:appcompat:1.3.1'
To solve this issu follow these steps
Go to SDK manager in android studio and install 'Android api 31'
Go to build.gradle file and change complie SDK version 'x' to compile SDK
version 31 and change target SDK version also to 31
Now synk
go to manifest.xml and write this line to inside your activity which is linked with intent filter
'android: export="true"
Now build the project. It will definitely solve this problem
Note also that the latest Google Ads SDK dependencies (currently v20.5.0) may lead to the minCompileSDK (31) error in the following circumstance:
your project is setup to use a compileSDK and targetSDK of 29/30
The Google Ads (or any) dependency version included in the implementation section of your build.gradle is intended for use with Apps compiling against API 31 / Android 12
For example your build.gradle may contain:
compileSdkVersion 29
targetSdkVersion 29
implementation 'com.google.android.gms:play-services-ads-lite:20.5.0'
As mentioned in other answers the way to resolve this is that you need to apply a force resolutionStrategy to ensure that the latest versions of the androidx.work:work-runtime and androidx.core:core-ktx are not picked up as required build dependencies.
The following works for me
configurations.all {
resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
}
NOTE: Once you have migrated to compiling against API 31, the resolutionStrategy lines should be removed to ensure that you are using the latest versions of the core Android platform dependencies
I had this problem and was getting no solutions from any of the Stack Overflow threads. Disabling Hyper V and running basic diagnostics were still not helpful. I was getting stop codes each time I tried to run my VM.
I fixed this issue by going into the SDK manager and updating the SDK Platform and SDK tools. Start by opening the SDK Manager from the Tools menu, and each option with a hyphen in the Platform/Tools panes click to change into a check mark, hit apply and accept the changes. The stop codes went away for me.
BROTHER MY ERROR HAS BEEN RESOLVED BY DOWNLOADING THE SDK TOOL OF 31 FROM SETTINGS -> APPERENCE AND BEHAVIOUR-> ANDROID SDK - AND THE 2ND ONE IN THE LIST
as in the image instead of 28 in the second column there will be 31 So u need to download that and then rebuild your project
That's it !
I solved the issue by adding this piece of code at the end of dependencies inside android/app/build.gradle :
android/app/build.gradle
dependencies {
....
....
api(group: "androidx.work", name: "work-runtime") {
version {
strictly "2.7.0-alpha04"
}
}
}
And this is android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "21.4.7075529"
androidXCore = "1.7.0" // <-- Add this. Check versions here: https://developer.android.com/jetpack/androidx/releases/core
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
maven { url 'https://www.jitpack.io' }
}
}
I had to update from RN 0.66.4 to 0.66.5.
https://github.com/facebook/react-native/releases/tag/v0.66.5
The description:
🚨 IMPORTANT: This is an exceptional release on an unsupported version. We recommend you upgrade to one of the supported versions, listed here.
Hotfix
This version is a patch release addressing the Android build issue that has been ongoing since Nov 4th 2022. If you are on 0.66.x, update to this version to fix it.
If you are on an older version of React Native, refer to this issue for details and the workaround you can apply in your project.
After bumping it worked for me.
In my case, on of the module's version has + on its versioning, specifying the version which suits to your sdk version will solve it
I have the following dependency in one module -
implementation "androidx.core:core-ktx:+"
but others module including app module has following dependency
implementation "androidx.core:core-ktx:1.6.0"
You need change + to version
implementation "androidx.core:core-ktx:+" ->
implementation "androidx.core:core-ktx:1.6.0"
I had the same error and it worked when I modified the following:
implementation 'androidx.core:core-ktx:1.7.0' and `api 'com.google.android.material:material:1.4.0-alpha07'`
to
implementation 'androidx.core:core-ktx:1.6.0' and api 'com.google.android.material:material:1.4.0-alpha06'
I was having the same problem the minCompileSdk (31) specified in a dependency's AAR metadata when I created an activity from the templates with ViewModel and LiveData it add the latest versioned dependencies like
then I downgraded the version to 1.6.0 as
I also had this probem in a jetpack compose project.
I was using paging and the problem was because of both paging and some other dependencies.
I could solve the problem by using the following version of paging instead :
implementation "androidx.paging:paging-compose:1.0.0-alpha10"
and I replaced the old dependencies with the following :
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
Changing
implementation 'androidx.core:core-ktx:1.7.0'
to
implementation 'androidx.core:core-ktx:1.6.0'
worked for me.
Because you use gradle>7.0, you can chan gradle-6.7.1-all and com.android.tools.build:gradle:4.0.0. :3
I was facing same issue for the last few weeks, now in Dec 2021 first week the official sdk of 31 is released,
Now change the compilesdk to 31 and targetsdk to 30
Download the latest sdk from android studio,
Click Tools > SDK Manager.
In the SDK Platforms tab, select Android 12.
In the SDK Tools tab, select Android SDK Build-Tools 31.
Click OK to install the SDK.
The latest lib wants the compilesdk of 31,
Once you do this all issues resolved.
#Kishan Solanki answer worked for me. I am using Flutter.
So what I did is forcefully downgraded its version by adding this
configurations.all {
resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
}
inside
android {
defaultConfig {
//here
}
}
I got this error when trying to target API 30 in a Java project. It was caused by appcompat version 1.4.1 requiring a target API of 31 or higher. If you downgrade to version 1.3.1 it will support a target API of 30 or higher.
To target API 30, you need to downgrade both androidx.appcompat:appcompat and com.google.android.material:material to older versions.
Change the versions from:
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
To:
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
Ionic user with Cordova
I would have loved to give an answer to the following question, but since it have been closed..
This is a pure copy of the following answer but it should make the trick
"This issue is related to androidx.appcompat:appcompat 1.4.0-beta01 released on September 29, 2021.
As plugin.xml defines ANDROIDX_VERSION as major version 1 (1.+), 1.4.0-beta01 was used instead of 1.3.0. Unfortunately you cannot simply use cordova plugin add cordova.plugins.diagnostic --variable ANDROIDX_VERSION=1.3.+ to overwrite the value, as the same version would be used for androidx.legacy:legacy-support-v4 which exists as version 1.0.0 only.
I successfully used cordova plugin add cordova.plugins.diagnostic --variable ANDROIDX_VERSION="[1.0, 1.4[" to get my builds fixed." - Vivek Kachhwaha
For me, I had to uninstall the java version which is currently the latest (java 17) and install java 11.
I'm using expo react native. I tried to use expo run:android or eas build --profile development --platform android. The error I got from these two was solved by simply doing the above.
Suddenly when Syncing Gradle, I get this error:
WARNING: API 'variant.getJavaCompile()' is obsolete and has been
replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance
Affected Modules: app
I've got this build.gradle for the app module:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
buildToolsVersion "28.0.2"
defaultConfig {
applicationId "..."
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "..."
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
versionNameSuffix = version_suffix
[...]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
[...]
}
debug {
[...]
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.61"
implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "com.android.support:preference-v7:28.0.0"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'com.google.android.material:material:1.0.0-rc02'
[...]
}
I can compile the app correctly, but it's a bit bothering, and as I see it, something will stop working at the end of 2019. Any ideas of what is it and how to solve it?
I face this issue after updating to 3.3.0
If you are not doing what error states in gradle file, it is some plugin that still didn't update to the newer API that cause this. To figure out which plugin is it do the following (as explained in "Better debug info when using obsolete API" of 3.3.0 announcement):
Add 'android.debug.obsoleteApi=true' to your gradle.properties file which will log error with a more details
Try again and read log details. There will be a trace of "problematic" plugin
When you identify, try to disable it and see if issue is gone, just to be sure
go to github page of plugin and create issue which will contain detailed log and clear description, so you help developers fix it for everyone faster
be patient while they fix it, or you fix it and create PR for devs
Hope it helps others
This issue is fixed now with update Fabric Gradle version 1.30.0:
Update release: March 19, 2019
Please see this Link: https://docs.fabric.io/android/changelog.html#march-15-2019
Please update your classpath dependency in project level Gradle:
buildscript {
// ... repositories, etc. ...
dependencies {
// ...other dependencies ...
classpath 'io.fabric.tools:gradle:1.30.0'
}
}
In my case, it was caused from gms services 4.3.0. So i had to change it to:
com.google.gms:google-services:4.2.0
I have found this by running:
gradlew sync -Pandroid.debug.obsoleteApi=true
in terminal. Go to view -> tool windows -> Terminal in Android Studio.
This is just a warning and it will probably be fixed before 2019 with plugin updates so don't worry about it. I would recommend you to use compatible versions of your plugins and gradle.
You can check your plugin version and gradle version here for better experience and performance.
https://developer.android.com/studio/releases/gradle-plugin
Try using the stable versions for a smooth and warning/error free code.
I also faced the same issue. And after searching for a while, I figured it out that the warning was arising because of using the latest version of google-services plugin (version 4.3.0). I was using this plugin for Firebase functionalities in my application by the way.
All I did was to downgrade my google-services plugin in buildscript in the build.gradle(Project) level file as follows:
buildscript{
dependencies {
// From =>
classpath 'com.google.gms:google-services:4.3.0'
// To =>
classpath 'com.google.gms:google-services:4.2.0'
}
}
1) Add android.debug.obsoleteApi=true to your gradle.properties. It will show you which modules is affected by your the warning log.
2) Update these deprecated functions.
variant.javaCompile to variant.javaCompileProvider
variant.javaCompile.destinationDir to
variant.javaCompileProvider.get().destinationDir
Change your Google Services version from your build.gradle:
dependencies {
classpath 'com.google.gms:google-services:4.2.0'
}
This is a warning spit out by build tools for two reasons.
1. One of the plugin is relying on Task instead of TaskProvider, there is nothing much we can do.
2. You have configured usage of task, where as it supports TaskProvider.
WARNING: API 'variant.getGenerateBuildConfig()' is obsolete and has been replaced with 'variant.getGenerateBuildConfigProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance
WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance
WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance
Look out for snippets as below & update.
android {
<library|application>Variants.all { variant ->
/* Disable Generating Build config */
// variant.generateBuildConfig.enabled = true // <- Deprecated
variant.generateBuildConfigProvider.configure {
it.enabled = true // Replacement
}
}
}
Similarly, find usages of 'variant.getJavaCompile()' or 'variant.javaCompile', 'variant.getMergeResources()' or 'variant.mergeResources'. Replace as above.
More information at Task Configuration Avoidance
Downgrading the version of Gradle worked for me:
classpath 'com.android.tools.build:gradle:3.2.0'
Upgrading the Kotlin (Plugin and stdLib) version to 1.3.1 solved that warning in my case. Update the Kotlin version in whole project by replacing existing Kotlin version with :
ext.kotlin_version = '1.3.50'
Go back from classpath 'com.android.tools.build:gradle:3.3.0-alpha13' to classpath 'com.android.tools.build:gradle:3.2.0'
this worked for me
Updating gradle to gradle:3.3.0
The default 'assemble' task only applies to normal variants. Add test variants as well.
android.testVariants.all { variant ->
tasks.getByName('assemble').dependsOn variant.getAssembleProvider()
}
also comment apply fabric
//apply plugin: 'io.fabric'
Update fabric plugin to the latest in project level Gradle file (not app level). In my case, this line solved the problem
classpath 'io.fabric.tools:gradle:1.25.4'
to
classpath 'io.fabric.tools:gradle:1.29.0'
In my case
build.gradle(Project)
was
ext.kotlin_version = '1.2.71'
updated to
ext.kotlin_version = '1.3.0'
looks problem has gone for now
In my case, I had to comment out com.google.firebase.firebase-crash plugin:
apply plugin: 'com.android.application'
// apply plugin: 'com.google.firebase.firebase-crash' <== this plugin causes the error
It is a bug since Android Studio 3.3.0
When the plugin detects that you're using an API that's no longer supported, it can now provide more-detailed information to help you determine where that API is being used. To see the additional info, you need to include the following in your project's gradle.properties file:
android.debug.obsoleteApi=true
if I remove this row from application gradle:
apply plugin: 'io.fabric'
error will not appear anymore.
Reference link github
Migrate your project to androidX.
dependencies are upgraded to androidX. so if you want to use androidX contents migrate your project to androidX.
With Android Studio 3.2 and higher, you can quickly migrate an existing project to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.
Downgrading dependencies may fix your problem this time - but not recommended
This fixed my problem.. All I needed to do was to downgrade my google-services plugin in buildscript in the build.gradle(Project) level file as follows
buildscript{
dependencies {
// From =>
classpath 'com.google.gms:google-services:4.3.0'
// To =>
classpath 'com.google.gms:google-services:4.2.0'
// Add dependency
classpath 'io.fabric.tools:gradle:1.28.1'
}
}
Here a temporary workaround, If you are using room just upgrade to 1.1.0 or higher
implementation "android.arch.persistence.room:runtime:1.1.0"
it removes this warning for me.
keep you Project(not app) Build.gradle dependncies classpath version code is new
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0-beta01'
classpath 'com.novoda:bintray-release:0.8.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
This is a popular question. If you do not use these methods, the solution is updating the libraries.
Please update your kotlin version, and all your dependencies like fabric, protobuf etc. If you are sure that you have updated everything, try asking the author of the library.
Upgrading protobuf-gradle-plugin to version 0.8.10 solved my problem. Replace your existing protobuf with
classpath 'gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.8.10'
That's mostly due to libraries which are obsolete. To check for new updates manually, you should navigate to
Analyze > "Run Inspection By Name"
That should be enough. Another option is to run a gradle dependency update using
./gradlew dependencyUpdates
that will produce a report like this:
:dependencyUpdates
------------------------------------------------------------
: Project Dependency Updates (report to plain text file)
------------------------------------------------------------
The following dependencies are using the latest milestone version:
- com.github.ben-manes:gradle-versions-plugin:0.15.0
The following dependencies have later milestone versions:
- com.google.auto.value:auto-value [1.4 -> 1.4.1]
- com.google.errorprone:error_prone_core [2.0.19 -> 2.0.21]
- com.google.guava:guava [21.0 -> 23.0-rc1]
- net.ltgt.gradle:gradle-apt-plugin [0.9 -> 0.10]
- net.ltgt.gradle:gradle-errorprone-plugin [0.0.10 -> 0.0.11]
...
upgrading the google services in project-level build.gradle solved my problem.
After upgrading:
dependencies {
...
classpath 'com.google.gms:google-services:4.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
I had same problem and it solved by defining kotlin gradle plugin version in build.gradle file.
change this
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
to
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50{or latest version}"
In my case I followed this.
Summary, in gradle app level: change this :
variant.outputs.all { output ->
variant.assemble.doLast {
....
}
}
to
variant.outputs.all { output ->
variant.getAssembleProvider().configure() {
it.doLast {
....
}
}
I created a new android project with the following gradle file:
android {
...
dexOptions {
javaMaxHeapSize "4g"
}
...
}
dependencies {
...
compile 'com.linkedin.dexmaker:dexmaker-mockito:2.16.0'
...
}
But when I build my app I get:
Conflict with dependency 'com.android.support:multidex' in project
':app'. Resolved versions for app (1.0.3) and test app (1.0.1) differ.
See http://g.co/androidstudio/app-test-app-conflict for details.
How can I solve this issue?
The error says you are using 2 versions of com.android.support:multidex.Check this
https://stackoverflow.com/a/37357786/3111083 So in your case it should be
android {
configurations.all {
resolutionStrategy.force 'com.android.support:multidex:1.0.3'
}
}
After changing this Clean and rebuild.
Mockito depends only on a specific version, so the dependency conflict should be on your side. Do you have any dependencies that depend on specific version? i.e.in your build.gradle file. If so, you can try using a ResolutionStrategy to force 1.0.3 on them.
I am trying to integrate Google sign in, in my app, I added these libraries:
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-plus:8.1.0'
Also add this to project build gradle:
classpath 'com.google.gms:google-services:1.4.0-beta3'
Also add plugin to app build gradle:
apply plugin: 'com.google.gms.google-services'
then add required permissions
but when I try to run my app, received this error:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0\bin\java.exe'' finished with non-zero exit value 2
Try adding multiDexEnabled true to your app build.gradle file.
defaultConfig {
multiDexEnabled true
}
EDIT:
Try Steve's answer first. In case it happens frequently or first step didn't help multiDexEnabled might help. For those who love to dig deeper here is couple similar issues (with more answers):
:app:dexDebug ExecException finished with non-zero exit value 2
Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException
Another thing to watch for, is that you don't use
compile 'com.google.android.gms:play-services:8.3.0'
That will import ALL the play services, and it'll only take little more than a hello world to exceed the 65535 method limit of a single dex APK.
Always specify only the services you need, for instance:
compile 'com.google.android.gms:play-services-identity:8.3.0'
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
I just had to Clean my project and then it built successfully afterwards.
This error began appearing for me when I added some new methods to my project. I knew that I was nowhere near the 65k method limit and did not want to enable multiDex support for my project if I could help it.
I resolved it by increasing the memory available to the :app:transformClassesForDexForDebug task. I did this by specifying javaMaxHeapSize in gradle.build.
gradle.build
android {
...
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
}
}
I tried this after having had no success with other common solutions to this problem:
Running a project clean
Manually deleting the /app/build and /build directories from my project
Invalidating Gradle Cache and restarting Android Studio
Error
Error:Execution failed for task
> ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
'/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java''
finished with non-zero exit value 1
Note: increasing the memory available to the DEX task can cause performance problems on systems with lower memory - link.
I also faced similar issue in Android Studio 1.5.1 and gradle 1.5.0.
I just have to remove unwanted libraries from dependencies which may be automatically added in my app's build.gradle file.
One was : compile 'com.google.android.gms:play-services:8.4.0'.
So for best practices try to only include specific play services library like for ads include only
dependencies {
compile 'com.google.android.gms:play-services-ads:8.4.0'
}
Although
defaultConfig {
multiDexEnabled true
}
this will also solve the issue, but provides with a lot of Notes in gradle console, making it confusing to find the other real issues during build
you can see the documentation of Android
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
I'm using AS 1.5.1 and encountered the same problem. But just cleaning the project just wont do, so I tried something.
clean project
restart AS
Sync Project
This worked with me, so I hope this helps.
At my case change buildToolsVersion from "24" to "23.0.2", solve the problem.
In my case the Exception occurred because all google play service extensions are not with same version as follows
compile 'com.google.android.gms:play-services-plus:9.8.0'
compile 'com.google.android.gms:play-services-appinvite:9.8.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
It worked when I changed this to
compile 'com.google.android.gms:play-services-plus:9.8.0'
compile 'com.google.android.gms:play-services-appinvite:9.8.0'
compile 'com.google.android.gms:play-services-analytics:9.8.0'
I resolved it with the next:
I configured
multidex
In build.gradle you need to add the next one.
android {
...
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
...
}
dexOptions {
incremental true
maxProcessCount 4 // this is the default value
javaMaxHeapSize "2g"
}
...
}
dependencies {
...
compile 'com.android.support:multidex:1.0.1'
...
}
Add the next one in local.properties
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
After that into Application class you need to add the Multidex too.
public class MyApplication extends MultiDexApplication {
#Override
public void onCreate() {
super.onCreate();
//mas codigo
}
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Don't forget add the line code into Manifest.xml
<application
...
android:name=".MyApplication"
...
/>
That's it with this was enough for resolve the bug:
Execution failed for task ':app:transformClassesWithDexForDebug.
Check very well into build.gradle with javaMaxHeapSize "2g" and the local.properties org.gradle.jvmargs=-Xmx2048m are of 2 gigabyte.
I had same problem when i rolled back to old version via git, and that version had previous .jar library of one 3rd party api, and for some reason turned out that both jar of the same sdk, just different versions were in /libs folder.
First Delete intermediates files
YOUR APP FOLDER\app\build\intermediates
OR
Clean your project and then rebuild.
Thent add
multiDexEnabled true
i.e.
defaultConfig {
multiDexEnabled true
}
It's work for me
I solved this issue by change to use latest buildToolsVersion
android {
//...
buildToolsVersion '26.0.2' // change from '23.0.2'
//...
}
A helpful answer if all above didn't work for you.
Go to your app gradle file,
Check all the dependency versions are mentioned with proper version code rather than any relative value like (com.example.demo:+)
Previous - implementation 'com.google.api-client:google-api-client-android:+'
After - implementation 'com.google.api-client:google-api-client-android:1.30.0'
If you are using the latest gradle version ie classpath 'com.android.tools.build:gradle:1.5.0' and classpath 'com.google.gms:google-services:1.4.0-beta3', then try updating the latest support respository from the SDK manager and rebuild the entire project.
If you need add this reference for cordova plugin add next line in your plugin.xml file.
<framework src="com.android.support:support-v4:+" />
If the different dependencies have a same jar also cause this build error.
For example:
compile('com.a.b:library1');
compile('com.c.d:library2');
If "library1" and "library2" has a same jar named xxx.jar, this will make such an error.
It happened to me because of Eclipse memory leak. I had to restart my computer.
I changed a couple of pngs and the build number in the gradle and now I get this. No amount of cleaning and restarting helped. Disabling Instant Run fixed it for me. YMMV
I had the same option and as soon as I turned off Instant run, it worked fine on my API16 device, but on the API24 device it worked fine with Instant run.
Hope this helps someone having the same issue
Simply go to Build - Edit Build Types - Properties Tab - Build Type Version and downgrade it to ver 23.0.1. Click ok.
This works for android studio 1.5.
It worked for me.
the write answer is in gradle put
defaultConfig {
multiDexEnabled true
}
then application name in manifest
android:name="android.support.multidex.MultiDexApplication"
wish this answer is hellpful to some one
this code solved problem
defaultConfig {
multiDexEnabled true
}
For easiest way to implement google sign in visit: google sign in android
Also try
dexOptions {
javaMaxHeapSize "4g"
}
Also keep same version number for different services.
I solved this issue by adding:
In build.gradle:
defaultConfig {
multiDexEnabled true
}
in local.properties ,
org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m
mention dependency:
compile 'com.android.support:multidex:1.0.1'
Clean and Rebuild.
Incase 'Instant Run' is enable, then just disable it.
I installed Android Studio and when I try to import a project from gradle this resolve error shows up:
Unable to load class
'org.codehaus.groovy.runtime.typehandling.ShortTypeHandling'.
I deleted the files in my Users .gradle folder and tried different gradle versions. I don't know how to fix this.
This page might help solve the problem. What they say is:
So we leveraged this version to add a new artifact, named
groovy-backports-compat23. This artifact shouldn’t be necessary for
most of you, but if you face an error like:
Caused by: java.lang.ClassNotFoundException:
org.codehaus.groovy.runtime.typehandling.ShortTypeHandling at
java.net.URLClassLoader$1.run(URLClassLoader.java:372)
in your project, then it means that a class has been compiled with
Groovy 2.3+ but that you are trying to use it with an older version of
Groovy. By adding this jar on classpath, you give a chance to your
program to run. This may be particularily interesting for Gradle users
that want to use a plugin built on Gradle 2+ on older versions of
Gradle and face this error. Adding the following line to their build
files should help:
buildscript {
// ...
dependencies {
classpath 'some plugin build on gradle 2'
classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'
} }
Note that for now, this jar only contains the ShortTypeHandlingClass.
Future versions may include more.
- See more at: http://glaforge.appspot.com/article/groovy-2-3-5-out-with-upward-compatibility#sthash.mv7Y8XQv.dpuf
I can fix this error message using these three methods.
use latest gradle version
use latest android SDK and tools.
use proguard-rules.pro
build.gradle (Project:xxxxx)
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
allprojects {
repositories {
mavenCentral()
}
}
build.gradle (Module:app)
apply plugin: 'android'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
I had the same problem. I ran gradle from command line and that did work.
After that, I found File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle. There "Use local gradle distribution" was active. Changed it to "Use default gradle wrapper (recommended)" and it worked.
I have had a same problem. And I have found a solution.
Cause
This problem is caused by android gradle plugin does not match for gradle version.
Solution
Edit build.gradle in project. gradle plugin version must be satisfied requirements for android studio.
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
And edit distrubutionUrl in gradle/wrapper/gradle-wrapper.properties. version of gradle must be satisfied requirements for gradle plugin.
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
You can find version compatibilities between android studio, android gradle plugin and gradle in this page
https://stackoverflow.com/a/29695756/3675925