I am developing a React Native application on a Mac and trying to build it for Android. However, when I run npm run android to launch the app on my phone, I encounter the following error:
BUILD FAILED in 3s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-async-storage_async-storage:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':react-native-async-storage_async-storage:androidJdkImage'.
> Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JdkImageTransform: /Users/marc-antoineleonelli/Library/Android/sdk/platforms/android-34/core-for-system-modules.jar.
> Error while executing process /Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home/bin/jlink with arguments {--module-path /Users/marc-antoineleonelli/.gradle/caches/transforms-3/7056ed491d13671bf4afd0abdfd4273b/transformed/output/temp/jmod --add-modules java.base --output /Users/marc-antoineleonelli/.gradle/caches/transforms-3/7056ed491d13671bf4afd0abdfd4273b/transformed/output/jdkImage --disable-plugin system-modules}
I am experiencing the same error for several other libraries, not just the one mentioned above.
Here is my build.gradle file:
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 21
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "25.1.8937393"
kotlinVersion = "1.8.0"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
maven {
url("https://maven.google.com")
}
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
apply plugin: "com.facebook.react.rootproject"
I use react-native 0.73.5 and Gradle 8.3.
I tried several solutions to resolve the issue, including trying different libraries, deleting the cache, running a clean on gradlew, and updating the Android SDK to the latest version.
I would appreciate any help in resolving this issue. Thank you!