Tran Duc Hoa
Tran Duc Hoa

Reputation: 141

Execution failed for task ':expo-modules-core:compileDebugJavaWithJavac'

How can I fix this error? Please help me. Thank you first.

Upvotes: 3

Views: 9431

Answers (5)

Nelson Frank
Nelson Frank

Reputation: 333

I found out java version and javac version are vary in my setup. So java and javac are treated differently. you have to make sure their version match.

In my case i was using java version 17 but javac version 11

i correct it by install javac version 17

Install javac

sudo apt-get install openjdk-17-jdk 

If you install more than one you can change using the command below

sudo update-alternatives --config javac

check javac version

javac -version

Extra: you can manage java version using command below

sudo update-alternatives --config java

check java version

java -version

Upvotes: 0

ChasingBoy
ChasingBoy

Reputation: 1

While java -version and echo $JAVA_HOME showed the correct OpenJDK version managed by jenv, the React Native build was still failing. This indicated an incompatibility likely between how jenv managed the JDK and how Gradle/React Native expected it to be configured.

Resolving this, I reinstalled OpenJDK manually and set the environment variables directly without using jenv. This circumvented any potential issues and allowed the build to succeed, confirming it was an interaction problem rather than an invalid JDK setup.

Going forward, when seeing similar errors despite a correct JDK configuration via jenv, I will investigate possible jenv-specific incompatibilities with the build tools used.

Upvotes: 0

Camilo Gomez
Camilo Gomez

Reputation: 195

In my case I just install: Java-11-openjdk-amd64

But in your case install: Java-17-openjdk-amd64

Upvotes: 0

Tran Duc Hoa
Tran Duc Hoa

Reputation: 141

I tried a ton of ways. Finally, I find out where is the problem from. It's come from javac, I don't have a Java compiler yet. I reinstall Java follow this instruction: https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-22-04

Boom, the problem is resolved. I hope this help other people who have the same problem as me.

Upvotes: 8

M Ashhal
M Ashhal

Reputation: 467

Check if this helps!

https://github.com/expo/expo/issues/17609#issuecomment-1189770234

Try upgrading your gradle version using the upgrade assistant or use the instructions in the mentioned link above.

Upvotes: 0

Related Questions