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

Categories

0 votes
686 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...