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.
I am getting below error while importing android project.
Error:The module 'app' is an Android project without build variants, and cannot be built.
Please fix the module's configuration in the build.gradle file and sync the project again.
Gradle file code.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.djalel.android.bilal"
minSdkVersion 9
targetSdkVersion 25
versionCode 4
versionName "1.3"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
aaptOptions {
cruncherEnabled = false
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:25.3.1'
implementation 'com.android.support:support-v4:25.3.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
implementation 'com.jakewharton.timber:timber:3.1.0'
}
repositories {
mavenCentral()
}
I checked with working gradle file as well but getting same error in this project.
Above gradle file code seems to be perfect. Probably its nothing to do with app/build.gradle (Module:app). Just open other build.gradle (Project:Android) file in Project window and verify your Android Studio version it must be same as yours.
I replaced from:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
to my Android Studio v3.0.1 in my case:
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Press "Try Again" to Sync gradle file. This resolved my problem with a successful build.
For me, this issue appeared when I updated Android Studio to version 3.3.
Disabling experimental feature "Only sync the active variant" fixes it:
Try use command line to run gradlew tasks to see why the build would fail.
In my case:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
platforms;android-27 Android SDK Platform 27
build-tools;27.0.3 Android SDK Build-Tools 27.0.3
So I just ran Go to Android\sdk\tools\bin sdkmanager --licenses to accept licenses and then the build passed in command line.
I think Android Studio is crying for the wrong issue. So you may check the real output in command line and find what is happening.
Just install the Android SDK platform package through SDK Manager in Android Studio, relevant to your Compile SDK version. It will prompt you to install the package as well as to accept the license. After that just sync the gradle, it will resolve the issue.
You must update your dependencies in build.grade in the buildscript block:
classpath 'com.android.tools.build:gradle:3.1.0'
to:
classpath 'com.android.tools.build:gradle:3.4.2'
If this error occurs for other module than 'app'
Remove gradle variable from that module's build.gradle like
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
& replace it actual value
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.71"
Clean Project -> Rebuild Project
I had this issue in my library project. I solved it by adding
buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
To the beginning of build.gradle
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
I am building a small library project along wit a sample project to illustrate the use. I can't manage to run the sample in Android Studio. I have created the project from scratch. I am experienced with Eclipse but it's my first try at Android Studio & Gradle.
The error given:
Gradle: Execution failed for task ':demo:dexDebug'.
Running C:\DevTools\Android\android-studio\sdk\build-tools\android-4.2.2\dx.bat
failed. See output
I have the following folder structure:
- demo
- build
- libs
- android-support-v4.jar
- src
- main
- java
- res
- build.gradle
- library
- build
- libs
- android-support-v4.jar
- src
- main
- java
- res
- build.gradle
- build.gradle
- settings.gradle
Build.gradle at project root:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
Settings.gradle at project root:
include ':library', ':demo'
Build.gradle for the library module:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android-library'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
Build.gradle for the sample module:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile project(':library')
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
Specifying compile files('libs/android-support-v4.jar') means that every library includes support v4. What you want to do is just specify that every library depends on it:
dependencies {
compile 'com.android.support:support-v4:13.0.0'
}
This will allow gradle to detect all dependencies and include this only once.
Note: You have to first use the SDK Manager and download and install two Maven repositories: "Android Support Repository" and "Google Repository".
I found the problem:
I removed that line from the sample gradle file.
compile files('libs/android-support-v4.jar')
However, I have no idea why this does not work (if I have 2 or 3 external libraries that all depend on the support library, how are we supposed to do, without touching their gradle files?
You should navigate to your libs folder in the IDE, right click on the jar and select to add the library to the project, it still needs to establish the dependency even though the jar appears to be there. Also look at your gradle built script to make sure the dependency appears there. If that still doesnt work just run a gradle clean on the project. Intellij documentation will give you more details on what clean does. see:
stackoverflow gradle build
This error could be encountered while migrating from Groovy to kotlin DSL as well and here are the steps to get rid of it:
If you are still in the process of migrating please complete the migration of gradle files first, use kts syntax and then sync gradle files.
Use this dependency inside your build.gradle(app level):
implementation("androidx.legacy:legacy-support-v4:1.0.0")
Remove id("kotlin-android-extensions") from plugins block inside build.gradle.kts (app level).
That's it! 3rd Point solved the issue for me but trying all the points should definitely fix the issue.
In my Case replace this line
classpath "com.android.tools.build:gradle:7.0.2"