I'm new to react native. I develop a mobile app using expo. Then I tried to build my app with eas build. It build normally. But after install the apk on my mobile, It stop running on splash screen.
Because of that reason, I moved to development build. It gives me this error.
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':react-native-community_slider:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':react-native-community_slider: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:
C:\Users\thara\AppData\Local\Android\sdk\platforms\android-34\core-
for-system-modules.jar.
> Error while executing process C:\Program Files\Java\jdk-21\bin\jlink.exe with arguments {--module-path C:\Users\thara\.gradle\
caches\transforms-
3\89db9bcd56ab5312cc04ec9440ec4d21\transformed\output\temp\jmod --add-
modules java.base --output C:\Users\thara\.gradle\caches\transforms-3\89db9bcd56ab5312cc04ec9440ec4d21\transformed\output\jdkImage --
disable-plugin system-modules}
* 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.
I tried these things which were found from the stackoverflow.
android/app/build.gradle
android {
.........
defaultConfig {
........
minSdkVersion rootProject.ext.minSdkVersion
(In a same question, there are the answers says to add minSdkVersion 21, But my config is different. So i go to root build.gradle(android/build.gradle) and changed the minSdkVersion to 21)
Then i delete the build file and run npx expo build:android
again.
But issue is not solved.
android/app/build.gradle
android {
ndkVersion rootProject.ext.ndkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion
namespace 'com.tharanga_sandun.MonkeyRepellent'
defaultConfig {
applicationId 'com.tharanga_sandun.MonkeyRepellent'
minSdkVersion rootProject.ext.minSdkVersion
multiDexEnabled true
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0.0"
buildConfigField("boolean", "REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS", (findProperty("reactNative.unstable_useRuntimeSchedulerAlways") ?: true).toString())
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
shrinkResources (findProperty('android.enableShrinkResourcesInReleaseBuilds')?.toBoolean() ?: false)
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
packagingOptions {
jniLibs {
useLegacyPackaging (findProperty('expo.useLegacyPackaging')?.toBoolean() ?: false)
}
}
}
// Apply static values from `gradle.properties` to the `android.packagingOptions`
// Accepts values in comma delimited lists, example:
// android.packagingOptions.pickFirsts=/LICENSE,**/picasa.ini
["pickFirsts", "excludes", "merges", "doNotStrip"].each { prop ->
// Split option: 'foo,bar' -> ['foo', 'bar']
def options = (findProperty("android.packagingOptions.$prop") ?: "").split(",");
// Trim all elements in place.
for (i in 0..<options.size()) options[i] = options[i].trim();
// `[] - ""` is essentially `[""].filter(Boolean)` removing all empty strings.
options -= ""
if (options.length > 0) {
println "android.packagingOptions.$prop += $options ($options.length)"
// Ex: android.packagingOptions.pickFirsts += '**/SCCS/**'
options.each {
android.packagingOptions[prop] += it
}
}
}
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation 'com.android.support:multidex:1.0.3'
implementation("com.facebook.react:react-android")
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
My root file android/build.gradle
buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0'
minSdkVersion = 21
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.8.10'
ndkVersion = "25.1.8937393"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath('com.android.tools.build:gradle')
classpath('com.facebook.react:react-native-gradle-plugin')
}
}
In MacOS, I solved it by
Ensure openjdk version 17 is selected
as noted here