. Advertisement .
..3..
. Advertisement .
..4..
It is crucial for developers to test their apps for errors before publishing. One of the most common errors that you’re going to run into is the execution failed for task “:app:checkDebugAarMetadata”. This can be a bit confusing for non-technical people and you’re not alone if you’re having trouble fixing this error. Read on to know how to fix this!
How Does The Error “Execution failed for task ‘:app:checkDebugAarMetadata’” Happen?
When trying to run my app in Android using react-native run-android, you may get the following error:
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'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
How To Solve The Error “Execution failed for task ‘:app:checkDebugAarMetadata’”
Option 1: Modify the compileSdkVersion
Simply modify the compileSdkVersion in the build.gradle file to fix your problem. Look at these steps below:
- Open the build.gradle file in Android.
- Modify the value of compileSdkVersion to 30.
- Set targetSdkVersion to 30 instead of 29.
- Now, run once more time.
After doing that, your error will be completely resolved.
Option 2: Include 1.7.0-alpha01
Include the following code to android’s build.gradle file.
configurations.all {
resolutionStrategy {
force 'androidx.core:core-ktx:1.6.0'
}
}
Next, use this:
implementation 'androidx.core:core-ktx:1.7.0-alpha01'
Option 3: Include ResolutionStrategy
To fix the problem, add ResolutionStrategy to the build.gradle file. Here’s an illustration. to the build.gradle file, include the following line:
configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.6.0 }
}
Option 4: Add to build.repositories jcenter() and to allprojects.repositories jcenter()
Besides the options mentioned above, there is another way to fix the error “Execution failed for task ‘:app:check Debugar Metadata’”. If you have already had the targetSdkVersion and the compileSdkVersion on version 30, let’s add to build.repositories
jcenter()
and to allprojects.repositories
jcenter()
, then you need to create the react-native app and it will run well. Look at the example of build.gradle below:
// Top-level build file where you can supplement configuration general options to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "20.1.5948944"
}
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.1")
// NOTE: Do not put 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 set up from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is set up from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
It is a simple method, but its efficiency is very enormous. It will help your poblem resolved and your program will run well without any erors. Let’s do it to get your desired results.
Conclusion
We hope you enjoyed our article about Java. With this knowledge, we know that you can fix your “Execution failed for task ‘:app:checkDebugAarMetadata’” error quickly by following these steps! If you still have any other questions about fixing this syntax error, please leave a comment below. Thank you for reading!
Read more
Leave a comment