react-native-async-storage / async-storage

An asynchronous, persistent, key-value storage system for React Native.
https://react-native-async-storage.github.io/async-storage/
MIT License
4.61k stars 458 forks source link

Execution failed for task ':react-native-async-storage_async-storage:compileDebugJavaWithJavac' #1057

Closed mehmettasan closed 4 months ago

mehmettasan commented 4 months ago

What happened?

when i install this package i get this error:

`FAILURE: Build failed with an exception.

BU�LD FAILED in 13s error Failed to install the app. Command failed with exit code 1: gradlew.bat 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: C:\Users\mehmet\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\mehmet.gradle\caches\transforms-4\f4982565bdb55b9941b39bd9a33cd0b1-894473a1-c334-41eb-958c-d197a337126f\transformed\output\temp\jmod --add-modules java.base --output C:\Users\mehmet.gradle\caches\transforms-4\f4982565bdb55b9941b39bd9a33cd0b1-894473a1-c334-41eb-958c-d197a337126f\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. BU�LD FAILED in 13s.`

Version

1.21.0

What platforms are you seeing this issue on?

System Information

System:
  OS: Windows 11 10.0.22621
  CPU: (8) x64 Intel(R) Core(TM) i5-10300H CPU @ 2.50GHz
  Memory: 3.89 GB / 15.84 GB
Binaries:
  Node:
    version: 18.16.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn: Not Found
  npm:
    version: 9.6.5
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK:
    API Levels:
      - "31"
      - "33"
      - "34"
    Build Tools:
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 33.0.1
      - 33.0.2
      - 34.0.0
    System Images:
      - android-31 | Google APIs Intel x86 Atom_64
      - android-33 | Google APIs Intel x86_64 Atom
      - android-34 | Intel x86_64 Atom
      - android-34 | Google APIs Intel x86_64 Atom
    Android NDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: AI-222.4459.24.2221.9971841
  Visual Studio: Not Found
Languages:
  Java: 21.0.2
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.3
    wanted: 0.73.3
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Steps to Reproduce

when i install this package

krizzu commented 4 months ago

Latest RN (0.73.3) is using Gradle 8.3, which is not compatible with JDK 21.

This is not related to Async Storage, but your setup - best to downgrade JDK, 17 is fine

AnshIcode commented 4 months ago

@krizzu Thanks for the solution its working fine!

H4D3ZS commented 3 months ago

for someone like me who encountered this error, i have a jdk version 21 installed, instead of deleting that, you can use sdkmanager or we can use brew.

brew install openjdk@17

after that see where it outputs

Matching Java Virtual Machines (2): 21.0.2 (arm64) "Oracle Corporation" - "Java SE 21.0.2" /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home 17.0.10 (arm64) "Homebrew" - "OpenJDK 17.0.10" /opt/homebrew/Cellar/openjdk@17/17.0.10/libexec/openjdk.jdk/Contents/Home /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home

link it with this sudo ln -sfn /opt/homebrew/opt/openjdk\@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

and you're good to go now.

System: OS: macOS 14.3.1 CPU: (8) arm64 Apple M1 Memory: 118.47 MB / 8.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 21.7.1 path: /usr/local/bin/node Yarn: version: 1.22.22 path: /usr/local/bin/yarn npm: version: 10.5.0 path: /usr/local/bin/npm Watchman: version: 2024.03.18.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.15.2 path: /Users/hades/.rvm/gems/ruby-3.0.0/bin/pod SDKs: iOS SDK: Platforms:

AnshIcode commented 3 months ago

@H4D3ZS yes by downgrading the java version to 20 or 17 it will works fine , thats fine approach.

FadiAboMsalam commented 3 months ago

for me i was missing

brew tap homebrew/cask-versions
brew install --cask zulu17

# Get path to where cask was installed to double-click installer
brew info --cask zulu17

then adding java home

After you install the JDK, update your JAVA_HOME environment variable. If you used above steps, JDK will likely be at /Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home

paicolman commented 2 months ago

I need some help here...

I still have this issue, although I (guess) have JDK17 installed, when I type java -version I get the following:

java version "17.0.10" 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 17.0.10+11-LTS-240)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.10+11-LTS-240, mixed mode, sharing)

running /usr/libexec/java_home -V yields:

Matching Java Virtual Machines (3):
    22 (x86_64) "Oracle Corporation" - "Java SE 22" /Library/Java/JavaVirtualMachines/jdk-22.jdk/Contents/Home
    17.0.10 (x86_64) "Oracle Corporation" - "Java SE 17.0.10" /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
    1.8.0_211 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-22.jdk/Contents/Home

Am I missing something?

AnshIcode commented 2 months ago

@paicolman try with 20 or 11 also