Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
755 views
in Technique[技术] by (71.8m points)

react native - Android SDK location not found with environment variable set

I am developing a react native app using yarn and whenever I try to run my app on an android device, I get the following error:

SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'mobile/android/local.properties'.

The weird thing is that I have installed the sdk (using brew install --cask android-sdk) and set an export on my ./zshrc (using export ANDROID_SDK_ROOT=/usr/local/share/android-sdk) which gets correctly printed out to the screen if I type echo $ANDROID_SDK_ROOT on my terminal.

To no avail, I have also tried a different approach I read about here, which was to create a file named local.properties and set the variable there by doing something like sdk.dir = /usr/local/share/android-sdk.

Any ideas why gradle cannot properly find the sdk?

question from:https://stackoverflow.com/questions/65853717/android-sdk-location-not-found-with-environment-variable-set

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Open the terminal and run the command: nano $HOME/.bashrc aggregate the follow line:

export ANDROID_HOME=$HOME/Android/Sdk
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools

Ctrl+o save and ctrl+x close.

And run the command:

source $HOME/.bashrc

echo $ANDROID_SDK_ROOT

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...