One or more issues found when checking AAR metadata values: - android

Hey I am trying to run my application and I am getting this error
build.gradle
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
}
android {
compileSdk 30
configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.7.0-alpha01' }
}
defaultConfig {
applicationId "com.example.listadapter"
minSdk 21
targetSdk 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
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'
implementation "com.squareup.retrofit2:converter-moshi:2.5.0"
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation "com.squareup.moshi:moshi:1.12.0"
implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0"
implementation "android.arch.lifecycle:extensions:1.1.1"
implementation 'androidx.fragment:fragment-ktx:1.3.6'
}
I tried this All Example from this link it's not working
getting error after installing the application. I just created a new application. I don't understand why this is causing it. Does anyone know how to solve this problem? Thanks in adavance.
One or more issues found when checking AAR metadata values:
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.lifecycle:lifecycle-viewmodel-ktx:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/b7f9608e476cb2e496993f185af8912c/transformed/jetified-lifecycle-viewmodel-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
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.lifecycle:lifecycle-runtime-ktx:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/538fea46e89a6c8a3e3eec533224abb8/transformed/jetified-lifecycle-runtime-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
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.lifecycle:lifecycle-livedata-ktx:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/6a1f77e99280b09902894e4ae8301047/transformed/jetified-lifecycle-livedata-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
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.lifecycle:lifecycle-viewmodel:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/41cf6125c3fd7a33d28222cf07d20520/transformed/lifecycle-viewmodel-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
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.lifecycle:lifecycle-runtime:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/655163560a267a5b16e2f66044d78641/transformed/lifecycle-runtime-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
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.lifecycle:lifecycle-livedata:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/1ca84d966e72f2f06b580da1765a55a5/transformed/lifecycle-livedata-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
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.lifecycle:lifecycle-livedata-core-ktx:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/3ed4d52253be7f6d85cbabee72c886d3/transformed/jetified-lifecycle-livedata-core-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
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.lifecycle:lifecycle-livedata-core:2.4.0.
AAR metadata file: /Users/vmodi/.gradle/caches/transforms-3/4e8a32482e233cfbbc450e03aabed8dd/transformed/lifecycle-livedata-core-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
If i change my compileSdk 31 it gives me another error.
Could not resolve all files for configuration ':app:androidApis'.
Failed to transform android.jar to match attributes {artifactType=android-mockable-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime, returnDefaultValues=false}.
Execution failed for MockableJarTransform: /Users/vmodi/Library/Android/sdk/platforms/android-31/android.jar.
Cannot create mockable android.jar
/Users/vmodi/Library/Android/sdk/platforms/android-31/android.jar

Change your compileSdk 30 to 31.
It worked for me!
compileSdk 31
defaultConfig {
applicationId "com.example.lifecycle"
minSdk 21
targetSdk 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

In the new version of apps:
Just change the compileSdk from 32 to 33.

compileSdk and targetSdk both should be 31. Have you tried?

Dependency: androidx.lifecycle:lifecycle-runtime-ktx:2.4.0.
The issue is with this dependency, there may be some transitive dependency error. I would suggest use the alpha version of this dependency, worked for me.
Replace with this dependency : androidx.lifecycle:lifecycle-*:2.4.0-alpha03

This is because you just upgraded Kotlin.
Open SDK Manager, install Android 12 (API 31) or above, then change compileSdkVersion to 31 (or above) and change targetSdkVersion to 31 (or above).
Then you will need to change minSdkVersion to 19 as well.

For me setting these two values to API 31 worked
commonCompileSdkVersion = 31
commonTargetSdkVersion = 31

Try to downgrade Kotlin library. I have changed
implementation 'androidx.core:core-ktx:1.9.0'
to
implementation 'androidx.core:core-ktx:1.8.0'
and this resolved my error.

Just remove one dependencies from your Gradle Scripts, then it will be solved.
Open your build.gradle(:app)
Go to dependencies
Remove implementation 'androidx.appcompat:appcompat:1.6.0'
After doing this the problem was solved for me.

If someone is still facing this error, change their compileSdk to 33.

Actually I had a problem : Every time I run my application the AAR metadata will give me an error , so I did this an it worked
go to the left side of the screen and there's an option called "Gradle Scripts "
click on it and there will be many options so click on the second one that says "build.gradle module" click on it and go to the last method named "dependencies"
and in the method there is a line :
implementation 'androidx.appcompat:appcompat:1.5.1'
so delete the " :1.5.1 "
so the line become : implementation 'androidx.appcompat:appcompat'
and it worked for me , I hope it'll work also for you

This WORKED for meset compile sdk from 31 to 33
compileSdk 33
defaultConfig {
applicationId "com.example.happybirthday"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Related

How can I resolve the error "The minCompileSdk (31) specified in a dependency's AAR metadata" in Kotlin?

One or more issues found when checking AAR metadata values:
The minCompileSdk (33) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-32).
Dependency: androidx.core:core:1.9.0.
my gradle module is:
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.aboutme"
minSdk 19
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Increase compileSdk value from 32 to 33:
android {
compileSdk 33
//...
}
Note that updating a library or application's compileSdk (which allows newer APIs to be used) can be done separately from updating targetSdk (which opts the app in to new runtime behavior).

Kotlin library was complied with a newer Kotlin compiler and can't be read

Hello I tried to run Kotlin file on Android Studio (version 4.1) and I got an error:
Kotlin library {0} was compiled with a newer Kotlin compiler and can't be read. Please update Kotlin plugin.
Even I got this error I'm able to run kotlin files but Ide don't gives me tips when I use kotlin functions and methods are marked by red colour. Kotlin version in gradle is 1.6.0, if I'm return to older version I can see tips about method names and red colour is not showed.
Gradle build(app):
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.kotlin_udemy4"
minSdkVersion 26
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Gradle build:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.6.0"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Does anyon know how to resolve that issue ?
Besides Kotlin version 1.6.21 ...
That version of Android Studio appears rather outdated; eg. the current version "Chipmunk" uses:
com.android.tools.build:gradle:7.2.1
jcenter() should be replaced with mavenCentral().
And also, use JavaVersion.VERSION_11.
I have similar problem. To solve this, I do the following things:
I try to Rebuild the project, then this error log appear:
The minCompileSdk (32) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-31).
Dependency: androidx.appcompat:appcompat-resources:1.5.0.
AAR metadata file: C:\Users..........
Lower androidx.appcompat:appcompat version to 1.4.0, and then sync gradle. That's it.
Maybe you can try this way.
Next to isssue popup i selected "Details" link and there was information about expected version. Probably because I'm using older Android studio I got the problem. I updated Kotlin in gradle build to: 1.4.32 according to message.

After update lifecyle to version 2.4.0 Make build error AAR metadata file: **/aar-metadata.properties

After update lifecycle version to 2.4.0 i cant build my app the error code is :
One or more issues found when checking AAR metadata values:
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.lifecycle:lifecycle-viewmodel-ktx:2.4.0.
AAR metadata file: **/transformed/jetified-lifecycle-viewmodel-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
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.lifecycle:lifecycle-livedata-ktx:2.4.0.
AAR metadata file: **/transformed/jetified-lifecycle-livedata-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
added this code but its not work for me
configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
}
Change compileSdk to 31 and targetSdk 31
if use AGP 7.* or above
android {
compileSdk 30
defaultConfig {
...
targetSdk 30
...
}
...
}
if use AGP Below 7
android {
compileSdkVersion 30
defaultConfig {
...
targetSdkVersion 30
...
}
}

> Task :app:checkDebugAarMetadata FAILED when run react-native run-android

I have o change the mincompilesdkversion to 30 and then again to 29 now I am getting this error.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (30) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-29).
Dependency: androidx.appcompat:appcompat:1.4.0-alpha03.
AAR metadata file: C:\Users\dell.gradle\caches\transforms-2\files-2.1\75e2de9081ba66388e83ea28d3fd2da1\appcompat-1.4.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (30) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-29).
Dependency: androidx.appcompat:appcompat-resources:1.4.0-alpha03.
AAR metadata file: C:\Users\dell.gradle\caches\transforms-2\files-2.1\290cdab22c9c5b1b7c3f8650a9e9566d\jetified-appcompat-resources-1.4.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (30) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-29).
Dependency: androidx.emoji2:emoji2-views-helper:1.0.0-alpha03.
AAR metadata file: C:\Users\dell.gradle\caches\transforms-2\files-2.1\c885669bddbda30b297932769f58904c\jetified-emoji2-views-helper-1.0.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (30) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-29).
Dependency: androidx.emoji2:emoji2:1.0.0-alpha03.
AAR metadata file: C:\Users\dell.gradle\caches\transforms-2\files-2.1\078363885b7b4397f6f0ba1e544abc8e\jetified-emoji2-1.0.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (30) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-29).
Dependency: androidx.core:core:1.7.0-alpha01.
AAR metadata file: C:\Users\dell.gradle\caches\transforms-2\files-2.1\805c250fb9ce03c9ddefabde06af7912\core-1.7.0-alpha01\META-INF\com\android\build\gradle\aar-metadata.properties.
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 8s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
Multiple task action failures occurred:
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (30) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-29).
Dependency: androidx.appcompat:appcompat:1.4.0-alpha03.
AAR metadata file: C:\Users\dell.gradle\caches\transforms-2\files-2.1\75e2de9081ba66388e83ea28d3fd2da1\appcompat-1.4.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (30) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-29).
Dependency: androidx.appcompat:appcompat-resources:1.4.0-alpha03.
AAR metadata file: C:\Users\dell.gradle\caches\transforms-2\files-2.1\290cdab22c9c5b1b7c3f8650a9e9566d\jetified-appcompat-resources-1.4.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (30) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-29).
Dependency: androidx.emoji2:emoji2-views-helper:1.0.0-alpha03.
AAR metadata file: C:\Users\dell.gradle\caches\transforms-2\files-2.1\c885669bddbda30b297932769f58904c\jetified-emoji2-views-helper-1.0.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (30) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-29).
Dependency: androidx.emoji2:emoji2:1.0.0-alpha03.
AAR metadata file: C:\Users\dell.gradle\caches\transforms-2\files-2.1\078363885b7b4397f6f0ba1e544abc8e\jetified-emoji2-1.0.0-alpha03\META-INF\com\android\build\gradle\aar-metadata.properties.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (30) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-29).
Dependency: androidx.core:core:1.7.0-alpha01.
AAR metadata file: C:\Users\dell.gradle\caches\transforms-2\files-2.1\805c250fb9ce03c9ddefabde06af7912\core-1.7.0-alpha01\META-INF\com\android\build\gradle\aar-metadata.properties.
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
If you are coming here after Nov 4/22 where react native released 0.71.0-rc0 and you are unable to build your android project as i was follow this.
📢 Patches for >= 0.63
Releases for all the main versions of react-native with an hotfix:
🛳 0.70.5: https://github.com/facebook/react-native/releases/tag/v0.70.5
🛳️ 0.69.7: https://github.com/facebook/react-native/releases/tag/v0.69.7
🛳 0.68.5: https://github.com/facebook/react-native/releases/tag/v0.68.5
🛳️ 0.67.5: https://github.com/facebook/react-native/releases/tag/v0.67.5
🛳️ 0.66.5: https://github.com/facebook/react-native/releases/tag/v0.66.5
🛳️ 0.65.3: https://github.com/facebook/react-native/releases/tag/v0.65.3
🛳️ 0.64.4: https://github.com/facebook/react-native/releases/tag/v0.64.4
🛳️ 0.63.5: https://github.com/facebook/react-native/releases/tag/v0.63.5
By updating to these patch versions, your Android build should start working again.
To do so, in your package.json change react-native's version to the relevant new patch (ex. if you are on 0.64.3, change to 0.64.4) and run yarn install. No other changes should be necessary, but you might want to clean your android artifacts with a cd android && ./gradlew clean before trying to re-run your Android app.
Fix for older react-native (< 0.63)
The fix above only works on gradle 6.2 and higher. Older react-native used older gradle.
You may determine your gradle version by looking in your /android/gradle/wrapper/gradle-wrapper.properties file.
If you are on an older version of react-native (for example 0.63 or earlier) that uses gradle version 6.1 or below, you must use a different workaround as gradle 6.1 does not support exclusiveContent.
Add this in the allprojects area of your android/buld.gradle file.
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.65+, as a proper fix is included in react-native itself.
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
More detailed info about the problem and the fix here: https://github.com/facebook/react-native/issues/35210
change these two lines and its now working
this was solution for react-native version .67 and lower
from
compileSdkVersion = 29
targetSdkVersion = 29
to
compileSdkVersion = 30
targetSdkVersion = 30
for latest version here are the changes
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 33 // with 31 was working fine
targetSdkVersion = 31
if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = "24.0.8215888"
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = "21.4.7075529"
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.2.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:5.0.1")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
latest updated on react-native version .70 and above
compileSdkVersion = 33
targetSdkVersion = 33
I fixed it by adding this code to the android/app/build.gradle
dependencies{
...other dependencies,
implementation ("androidx.browser:browser:1.3.0"){
force = true
}
}
I found it after 4 hour of searching and testing several answers.
If you don't want to upgrade to SDK 31, add in android/app/build.gradle
android {
...
defaultConfig {
...
configurations.all {
resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
}
}
}
Taken form this GutHub answer.
I was facing same issue too.
There was an issue with the library of core-ktx and then I replaced it with this:
implementation("androidx.core:core-ktx:1.6.0")
Change your versions to 30 in app build.gradle:
compileSdkVersion = 30
targetSdkVersion = 30
My issue is resolved may be it helps in your case too.
compileSdkVersion = 31
targetSdkVersion = 31
I'm using RN 0.64.2 version and the react-native-firebase library transitively pulled in the newer version of androidx.browser:browser:1.4.0-alpha01 and androidx.appcompat:appcompat:1.4.0-alpha03.
in my app/build.gradle I forced the androidx.browser:browser and androidx.appcompat:appcompat versions to an earlier ones.
runtimeOnly(group: 'androidx.browser', name: 'browser', version: '1.3.0') {
force = true
}
runtimeOnly(group: 'androidx.appcompat', name: 'appcompat', version: '1.3.1') {
force = true
}
from
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
to
buildToolsVersion = "30.0.0"
minSdkVersion = 16
compileSdkVersion = 30
targetSdkVersion = 30
react-native run-android
I have solved the issue by upgrading buildToolsVersion, compileSdkVersion and targetSdkVersion to 31 from 29
Just add this code block to the end of build.gradle file in app level
configurations.all {
resolutionStrategy {
force 'androidx.core:core-ktx:1.6.0'
}
}
In our case: we re-created our react native app
We had a React Native app react-native#0.65.1 with this config
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
We created a new app react-native#0.70.5 and imported the code. the new config was
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
We faced the same problem (run android failed), so we changed compileSdkVersion from 31 into 33 and it worked, here is the new config
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 31
Changing compileSdkVersion 28 to compileSdkVersion 30
and targetSdkVersion 28 to targetSdkVersion 30 solved my problem
How you solved this issue
Change like this. Updated.
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.theblog"
minSdk 28
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 31
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.google.firebase:firebase-database:20.0.3'
implementation 'com.google.firebase:firebase-auth:21.0.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
The error may also be here.
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
}
Check build error description here

Android Jetifier fails to convert data binding generated support library to AndroidX

I have an Android project that has been migrated to AndroidX. At some point, I want to add a new library.
This library is using a support library with data binding.
I have enabled Android Jetifier in my gradle.properties. I am using Android Gradle build tool v.3.3.2 and Gradle v.4.10.1.
Here is my gradle.properties:
org.gradle.jvmargs=-Xmx1536m
kotlin.code.style=official
android.useAndroidX=true
android.enableJetifier=true
Here is my build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.test"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dataBinding {
enabled = true
}
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '28.0.0'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation <library with AndroidX and data binding>
}
I got the following error on compile time.
Task :app:compileDebugJavaWithJavac FAILED
GallerypickerBinding.java:22: error: package android.support.constraint does not exist
private final android.support.constraint.ConstraintLayout mboundView0;
GallerypickerBinding is the generated class from data binding of the newly added library.
When I checked this file, it uses androidx.databinding.ViewDataBinding from AndroidX, but in the same file, it still uses android.support.constraint.ConstraintLayout from support library.
I expect Android Jetifier to convert all support libraries including to AndroidX, but it seems like it fails to convert the ConstraintLayout generated from data binding to AndroidX.
You have to change package name in java file as well as in xml file.
com.android.support.constraint to androidx.constraintlayout
For Kotlin, replace this dependency:
implementation "androidx.appcompat:appcompat:1.0.0-beta01"
with these (not sure if the second one is even required, but it is quite essential):
implementation "androidx.appcompat:appcompat:1.0.2"
implementation "androidx.core:core-ktx:1.0.1"
And for that data-binding error... either clean the project - or try to add the old one com.android.support.constraint package into the dependencies once, to make it stop complaining (only for a test, it will get it's namespace rewritten). If this not helps, please add Gallerypicker.java and it's XML into the question, for further review.
#Suraj Singh might be right about the resource - if so, his answer should be the accepted one.

Categories

Resources