且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Cordova:未找到 Android SDK.确保它已安装.如果不在默认位置,请设置 ANDROID_HOME 环境变量

更新时间:2022-03-15 21:40:46

最近的Android SDK 工具删除了 android 命令.

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 是更改的幕后推手,并且似乎有人在致力于此:https://issues.apache.org/jira/browse/CB-12554

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

您还可以将您的工具降级到 android 仍然可用的版本.

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

尽管如此,我还是找到了一种无需降级 SDK 工具即可运行 Android 应用程序的方法.我会 (1) 运行 cordova prepare,然后 (2) 从 Android Studio 运行我需要的命令.就我而言,在模拟器上运行它就足够了.

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.

更新:问题 CB-12554 现已解决并发布cordova-android@6.2.0 版本.

UPDATE: The issue CB-12554 is resolved now and was released with the cordova-android@6.2.0 release.

更新:后续做了几个相关补丁,最新版本是cordova-android@6.2.3.运行 cordova platform rm android;cordova 平台添加 android@6.2.3 来解决问题.

UPDATE: There were several related subsequent patches done and the newest version is cordova-android@6.2.3. Run cordova platform rm android; cordova platform add android@6.2.3 to fix the issues.