简体   繁体   中英

Cordova - Android SDK not found

I saw a lot of thread in here related to this, but any of them helped me.

With Cordova 6.5.0 installed and Android Studio also installed with Android 6.0 (API 23) and Android 4.4 (API 19), I'm trying to run:

cordova requirements

I got the following 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.

Ok. I set up the ANDROID_HOME and the PATH:

export ANDROID_HOME=/Users/USER/Library/Android/sdk
export PATH=${PATH}:/Users/USER/Library/Android/sdk/platform-tools:/Users/italoborges/Library/Android/sdk/tools

I also changed inside platforms/project.properties the line:

target=android-23

And inside platforms/android/AndroidManifest.xml the line:

<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="23" />

And inside platforms/android/CordovaLib/AndroidManifest.xml the same line above.

Right now I'm stuck because I have tried all the possibilities that I found.

Thanks.

Cause the cordova updated, you may skip this answer and see others.


The reason is not only The recent Android SDK tools removed the android command, but also the file structure of the SDK ,installed by android studio ,has been changed. You can wait for the fix, or do a temporary fix by you self.

1,Delete all contents of ~/Library/Android/sdk

2,Download https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip ,and unzip it to ~/Library/Android/sdk/tools

3,Open sdk manager in command line ( ~/Library/Android/sdk/tools/android sdk ),and install the SDKs.You may need to install 5.5.1(API22) and 6.0(API23)

That's all.

You should update the android platform of your cordova project. Check the blog of cordova official site ( HERE! ) to learn the last released version of android for cordova. Example: If the last released version of android is 6.2.1, Then you should update the platform to 6.2.1.

On Windows : cordova platform update android@6.2.1 --save

I solved this problem updating cordova:

cordova platform rm android
cordova platform add android@latest

and then:

cordova run android

I had the same problem.

Succeeded with:

    cordova platform rm android
    cordova platform add android@5.2.2

I found a workaround to fix the error:

https://github.com/apache/cordova-android/pull/367#issuecomment-286166329

Reason of the error: The latest Android SDK Tools (25.3.1) turfed the android command, which all of cordova's underlying functionality relied on.

If you encounter this problem, the process should be as follows:

1, cordova platform rm android
2, export ANDROID_HOME=/Users/USER/Library/Android/sdk
   export PATH=${PATH}:/Users/USER/Library/Android/sdk/platform-tools:/Users/italoborges/Library/Android/sdk/tools
3, cordova platform add android@5.2.2

(or the one you need)

If you are putting the EXPORTs to the .profile, remember to unlogin, login again so the .profile can take its action.

Reason : if you do not have ANDROID_HOME before setting cordova-android platform, then setting it afterwards will not work, unless you reinstall cordova-android platform.

我解决了将cordova更新到最新版本的问题。

cordova platform update android@latest

Check the permission in your ../Android/Sdk/tools

Maybe you need to use

> /Android/Sdk$ chmod -R u+x tools

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