react-native-async-storage/async-storage

react-native-async-storage_async-storage:compileDebugJavaWithJavac FAILED

Bhavesh1236 opened this issue · 8 comments

npx react-native run-android
version info
"@react-native-async-storage/async-storage": "^1.21.0",
"react": "18.2.0",
"react-native": "0.73.1",

Task :react-native-async-storage_async-storage:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

@Bhavesh1236 Hi, how did you solve this issue?

"dependencies": {
"@react-native-async-storage/async-storage": "^1.21.0",
"@react-native-community/netinfo": "^11.2.1",
"@react-navigation/bottom-tabs": "^6.5.11",
"@react-navigation/native": "^6.1.9",
"@react-navigation/native-stack": "^6.9.17",
"@walletconnect/react-native-compat": "^2.11.0",
"@web3modal/wagmi-react-native": "^1.1.1",
"react": "18.2.0",
"react-native": "0.73.2",
"react-native-gesture-handler": "^2.14.1",
"react-native-get-random-values": "^1.10.0",
"react-native-modal": "^13.0.1",
"react-native-safe-area-context": "^4.8.2",
"react-native-screens": "^3.29.0",
"react-native-svg": "^14.1.0",
"viem": "^1.21.4",
"wagmi": "^1.4.13"
}

Same issue when it try to install and run "@react-native-async-storage/async-storage". its run on IOS without error but return error on Android side.

Task :react-native-async-storage_async-storage:compileDebugJavaWithJavac FAILED
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/armup/Library/Android/sdk/platforms/android-34/core-for-system-modules.jar.
         > Error while executing process /opt/homebrew/Cellar/openjdk/21.0.1/libexec/openjdk.jdk/Contents/Home/bin/jlink with arguments {--module-path /Users/armup/.gradle/caches/transforms-3/ab2fc22cb32e16b9d572bdcb2e01e34e/transformed/output/temp/jmod --add-modules java.base --output /Users/username/.gradle/caches/transforms-3/ab2fc22cb32e16b9d572bdcb2e01e34e/transformed/output/jdkImage --disable-plugin system-modules}

Why is this closed? At the very least, I think should be documented as in 0.73 this is now the suggested in module by RN docs for AsyncStorage.

I managed to get this working while running directly in Android Studio with JDK 17:
Screenshot 2024-02-02 at 19 20 41
But the same config fails when running in CLI. How do I set the JDK there? Otherwise this could probably do with being reopened as it's not operational with expo >= 49

Yep, figured it out. So whilst he's running a sandboxed version of java in Android Studio, the CLI is, of course, using what's installed on the local machine. Version 21 of java breaks stuff here, so I had to downgrade to version 17. In my case I used this to downgrade: https://sdkman.io/

dzpt commented

face the same issue on java 22, gotta move back to 17 and the error is vanished.