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
743 views
in Technique[技术] by (71.8m points)

Cordova: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable

I am having problem to build android with Cordova, when I execute cordova build android, I receive this error:

Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.

I have do this to fix it:

sudo nano  ~/.bash_profile

and add this line:

export PATH=${PATH}:/Users/myname/Library/Android/sdk/platform-tools:/Users/myname/Library/Android/sdk/tools

then this:

source ~/.bash_profile

but I get again that error when I build, how can I fix it?

UPDATE:

This is the line I Added in the bash:

export PATH=${PATH}:/Users/myname/Library/Android/sdk/platform-tools:/Users/myname/Library/Android/sdk/tools
export ANDROID_HOME=/Users/myname/Library/Android/sdk
See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

The recent Android SDK tools removed the android command.

$ android -v
The android command is no longer available.
For manual SDK and AVD management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager

cordova is behind the change and someone seems to be working on it: https://issues.apache.org/jira/browse/CB-12554

You can also downgrade your tools to a version where the android was still available.

Nevertheless, I found a way to run the Android app without having to downgrade my SDK tools. I would (1) run cordova prepare, then (2) run the command I need from Android Studio. In my case, running it on the emulator was enough.

UPDATE: The issue CB-12554 is resolved now and was released with the [email protected] release.

UPDATE: There were several related subsequent patches done and the newest version is [email protected]. Run cordova platform rm android; cordova platform add [email protected] to fix the issues.


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

...