简体   繁体   English

Cordova - 未找到 Android SDK

[英]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 6.5.0 并且 Android Studio 也安装了 Android 6.0 (API 23) 和 Android 4.4 (API 19),我正在尝试运行:

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:我设置了 ANDROID_HOME 和 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:我也在platforms/project.properties里面改变了这一行:

target=android-23

And inside platforms/android/AndroidManifest.xml the line:platforms/android/AndroidManifest.xml里面有一行:

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

And inside platforms/android/CordovaLib/AndroidManifest.xml the same line above.platforms/android/CordovaLib/AndroidManifest.xml 中,上面的同一行。

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.由于cordova已更新,您可以跳过此答案并查看其他答案。


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.原因不仅是最近的Android SDK工具去掉了android命令,还有android studio安装的SDK的文件结构也发生了变化。 You can wait for the fix, or do a temporary fix by you self.您可以等待修复,也可以自行进行临时修复。

1,Delete all contents of ~/Library/Android/sdk 1、删除~/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 2、下载https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip ,解压到~/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) 3、在命令行中打开sdk manager( ~/Library/Android/sdk/tools/android sdk ),安装~/Library/Android/sdk/tools/android sdk你可能需要安装5.5.1(API22)和6.0(API23)

That's all.就这样。

You should update the android platform of your cordova project.您应该更新您的cordova 项目的android 平台。 Check the blog of cordova official site ( HERE! ) to learn the last released version of android for cordova.查看cordova官方网站的博客(这里!以了解cordova的最新发布的android版本 Example: If the last released version of android is 6.2.1, Then you should update the platform to 6.2.1.示例:如果最近发布的 android 版本是 6.2.1,那么您应该将平台更新到 6.2.1。

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

I solved this problem updating cordova:我解决了更新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.错误原因:最新的 Android SDK 工具 (25.3.1) 对android命令产生了影响,cordova 的所有底层功能都依赖于该命令。

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.如果您将 EXPORTs 放入 .profile,请记住注销,再次登录,以便 .profile 可以执行其操作。

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-android平台之前没有ANDROID_HOME,那么之后的设置将不起作用,除非你重新安装cordova-android平台。

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

cordova platform update android@latest

Check the permission in your ../Android/Sdk/tools检查您的 ../Android/Sdk/tools 中的权限

Maybe you need to use也许你需要使用

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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