i am working with react native and am trying to use expo in a bare project but whenever i try to run the app with the command npm run android, i get this error :
Execution failed for task ':expo-modules-core:compileDebugJavaWithJavac'. > Could not resolve all files for configuration ':expo-modules-core: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: /home/dukizwe/Android/Sdk/platforms/android-31/core-for-system-modules.jar. > jlink executable /usr/lib/jvm/java-14-openjdk-amd64/bin/jlink does not exist. I am using the linux OS, Android studio and JDK are correctly installed.
Inside /usr/lib/jvm/ folder, the structure look like this:
- java-1.11.0-openjdk-amd64
- java-1.14.0-openjdk-amd64
- java-11-openjdk-amd64
- java-14-openjdk-amd64
- jdk-18
i don't know why it's looking in the java-14-openjdk-amd64 folder because in that folder there's no jlink executable.
In android studio the SDK Location si pointed to java-11-openjdk. Any help please ?
12 Answers
I also faced same issue when I did run my React Native app on my new Ubuntu 22.x machine. I fixed it with installing JRE along with JDK.
Step 1 sudo apt install default-jre followed by java -version
should display -
Output openjdk version "11.0.14" 2022-01-18 OpenJDK Runtime Environment (build 11.0.14+9-Ubuntu-0ubuntu2) OpenJDK 64-Bit Server VM (build 11.0.14+9-Ubuntu-0ubuntu2, mixed mode, sharing)
Followed by - sudo apt install default-jdk
Check - javac -version to get output as -
Output javac 11.0.14
Hope it helps!
3You need to install the development package for Java. On debian, this is the openjdk-11-jdk package.
It appears that you need to set the JAVA_HOME environment variable to the parent of the jlink binary. Android Studio includes its own jlink binary. On Linux (or Mac) you can use:
export JAVA_HOME="$HOME/android-studio/jbr" what comes after $HOME would depend on where you have Android Studio installed.
a more permanent solution is to edit your ~/.bashrc file, append the command provided above (with the path modifications if any) to the end of the said file and save changes. All done, open a new terminal and try compiling again.
On Windows you need to add the JAVA_HOME to your path
0For IntelliJ IDEA, go to: File > Project Structure and in Project tab change SDK to any SDK that uses JDK 11 or 8.
I've just copied jlink, javac and jmod from this path:
/home/USER/android-studio/jre/bin/
to the following path:
/usr/lib/jvm/java-11-openjdk-11.0.15.0.10-1.fc36.x86_64/bin
Note: It's important to use Terminal as root
OS Used: Linux Fedora 36
4I upgrade from Gradle 7 to 8 and I had to also upgrade android Gradle plugin to 8.0.0, My jvmTarget was equal to 1.8 and JavaVersion.VERSION_1_8 was being used for target and source compatability
But after upgrading to gradle 8, It requires Java version to be atleast 17, I tried setting only source compatability but that didn't work, so I had to change all three, source, target & jvmTarget to 17
My application worked fine on Desktop (jvmMain), But on Android I would get jlink executable doesn't exist. Since Its kotlin multiplatform.
What didn't work
Downloading Coretto 17 and using that
Removing all sdks in project structure and using only jdk 17 from jbr
using
jvmToolchain(17)in kotlin block inside android blockinvalidateCachesAndRestartplus deleting the .idea folder
What worked
Using Android JDK, I removed all jdks in
project structure-> sdks, Then added android jdk found in the jbr folder of android studio installationalso selected this jdk in
project structure -> project -> Sdk fieldYou must also change the jdk in
File -> Settings -> BuildTools -> Gradle
So It appears that the problem is that jbr jdk relly is missing the jlink executable since Android Studio jdk is working fine. I am going to redownload the jbr 17 sdk and I am pretty sure it should work , and should contain jlink executable, I think during updates somehow jlink executable got deleted.
This work for me you can try this out clean the gradlew then run this command ....
sudo apt install openjdk-11-jdk-headless JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64" I had the same error, I've installed java-17-openjdk on Fedora it turns out that I also need to install java-17-openjdk-devel.
sudo dnf install java-17-openjdk java-17-openjdk-devel In my gradle file I had:
compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } kotlin { jvmToolchain(8) } Setting the same java version for compileOptions and kotlin closures fixed the issue:
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlin { jvmToolchain(8) } In my case, JDK was missing for Java 17. I installed it using sudo pacman -Syu jdk17-openjdk, and it worked.
You probably do not have JDK installed. You can install it from your distro's repository. For Arch Linux, check this doc.
I tried to build react native app using OpenJdk 17 but didnt work. I was getting continuous error as below
* What went wrong: Execution failed for task ':app:compileReleaseJavaWithJavac'.
Could not resolve all files for configuration ':app: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: /home/neeraj/Android/Sdk/platforms/android-33/core-for-system-modules.jar. > jlink executable /usr/lib/jvm/java-17-openjdk-17.0.8.0.7-1.fc39.x86_64/bin/jlink does not exist. I installed OpenJdk 11 and this fixed my problem. I have OpenJdk 17 also installed on my machine which I switch as and when needed.
I am using fedora 39.
If you are on Manjaro or Archlinux, you have to copy jlink from the default-runtime(/usr/lib/jvm/default-runtime) to the Java 17 runtime(/usr/lib/jvm/java-17-openjdk) or your active runtime. You have to be root for you to do this. You can run this in your terminal.
cp /usr/lib/jvm/default-runtime/bin/jlink /usr/lib/jvm/java-17-openjdk/bin
You can check your active runtime using archlinux-java status.