当前位置: 首页 > 知识库问答 >
问题:

未设置ANDROID_HOME,并且“Android”命令不在PATH Phonegap中

娄阳舒
2023-03-14

我已经安装了android bundle,我已经在。bashrc文件中配置了所有的东西,甚至当我在命令行中说android时…我得到了Android管理器..但是当我说ionic platform add android时,我总是得到错误:“error:ANDROID_HOME没有设置,并且”android“命令不在您的路径中。您必须至少满足以下条件之一。”.我试了很多方法,但问题没有解决。

我的平台:

    export HOME="/home/system"
    export ANDROID_HOME="$HOME/adt-bundle-linux-x86_64-20140702/sdk/tools"
    export ANDROID_PLATFORM_TOOLS="$HOME/adt-bundle-linux-x86_64-20140702/sdk/platform-tools"
    export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH"
    export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
    export ANT_HOME="/usr/share/ant"
    export PATH="$ANT_HOME/bin:$PATH"
    export ANDROID_HOME="/home/system/adt-bundle-linux-x86_64-20140702/sdk/tools"
    system@system-H81M-S1:/usr/share/nginx/www/myApp# ionic platform add android
    npm http GET https://registry.npmjs.org/cordova-android/3.6.3
    npm http 200 https://registry.npmjs.org/cordova-android/3.6.3
    npm http GET https://registry.npmjs.org/cordova-android/-/cordova-android-3.6.3.tgz
    npm http 200 https://registry.npmjs.org/cordova-android/-/cordova-android-3.6.3.tgz
    Creating android project...

    /system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:126
    throw e;
    ^
    Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
    at /system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/lib/check_reqs.js:158:19
    at _fulfilled (/system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:798:54)
    at self.promiseDispatch.done (/system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:827:30)
    at Promise.promise.promiseDispatch (/system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:760:13)
    at /system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:821:14
    at flush (/system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:419:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)
    at node.js:906:3

    Error: /system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/
    create: Command failed with exit code 8 at ChildProcess.whenDone  (/usr/lib/node_modules/cordova/node_modules/
    cordova-lib/src/cordova/superspawn.js:135:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Process.ChildProcess._handle.onexit (child_process.js:823:5)

共有1个答案

廖鸿达
2023-03-14

我也遇到过同样的问题,现在已经解决了。

我认为这是最新的cordova与最新的Android的兼容性的问题。以及你在android主页上的问题。

在.bashrc文件中

export HOME="/home/indranil"
export ANDROID_HOME="$HOME/software/adt-bundle-linux-x86_64-20140702/sdk"
export PATH="$HOME/software/adt-bundle-linux-x86_64-20140702/sdk/tools:$ANDROID_HOME/platform_tools:$PATH"
npm uninstall -g cordova  (If linux use sudo npm uninstall -g cordova)
sudo chown -R `whoami` ~/.npm
sudo chown -R `whoami` /usr/local/lib/node_modules
sudo chown -R `whoami` /usr/local
npm install -g cordova@3.5.0-0.2.7

下载android(4.4.2)后,使用以下命令创建一个android虚拟设备:

android avd
 类似资料: