我正在使用 Ubuntu Gnome 14.04 64 位(目前)和内核 3.19.0-33-generic。
我创建了一个新的应用程序(一个干净的应用程序,没有插件,没有包含内容的 www 文件夹)来尝试构建它。 在 bash 中输入“cordova build android”后 我收到此错误:
Running command: /home/aby/Desktop/testApp/platforms/android/cordova/build
[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.]
ERROR building one of the platforms: Error:/home/aby/Desktop/testApp/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/aby/Desktop/testApp/platforms/android/cordova/build: Command failed with exit code 2
现在如果你printenv | grep android
你会得到
ANDROID_HOME=/opt/android-sdk-linux
ANDROID_PLATFORM_TOOLS=/opt/android-sdk-linux/platform-tools
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools:/home/aby/bin:/home/aby/opt/jdk8/jdk1.8.0_45/bin:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools
ANDROID_SDK=/opt/android-sdk-linux
你可以看到变量存在,事实上,在我运行 cordova build android
之前,我不得不使用 cordova platform add android
并且它的工作没有问题。
所以我找到了这个Bug ,并尝试了一些解决方案,如更新 android(project) 或删除并再次安装它但没有成功。
我重新安装了 Andoroid SDK,并用环境值更新了“/.bashrc”、“/.profile”和“~/.pam_enviroment”,这也没有帮助。
那么我该如何解决这个问题呢?我怎样才能毫无错误地构建我的应用程序?我缺少什么?(如果您认为您需要其他信息,请告诉我)。
提前致谢。
最佳答案
最后,当我将“所有者”/“组”更改为 android sdk 文件夹并将权限更改为“/tools/android”时,我可以解决我的问题。
Here指向我之前问题的链接,以及解决此错误的解决方案(至少对我而言)。
关于android - 尝试构建 Android 应用程序时 Cordova 失败并出现错误 "Command failed with exit code 2"Linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33647214/