简体   繁体   中英

Properly configure JDK to run react native project

I am trying to run a react native app on a m1 mac, generated with react-native-starter-kit. enter link description here . When I run the app with npx react-native run-android , I get the following error

error Failed to install the app. Please accept all necessary Android SDK licenses using Android SDK Manager: "$ANDROID_HOME/tools/bin/sdkmanager --licenses".

I tried to run the sdkmanager as following

export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
cd ~/Library/Android/sdk/tools/bin/   
./sdkmanager --licenses 

I get an Error

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema

Then I tried this JAVA_HOME

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
cd ~/Library/Android/sdk/tools/bin/   
./sdkmanager --licenses 

And it works, All SDK package licenses accepted.======] 100% Computing updates...

But when I run npx react-native run-android after that, I still have a licence error

Failed to install the app. Please accept all necessary Android SDK licenses using Android SDK Manager 

I have the feeling I am accepting the licenses in the wrong JDK. Any idea?

You should make sure that you set up you development envoirement the correct way.

The Official Guide explains it step by step.

For you paragraph 2 (Install the Android SDK) should be helpful

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM