Ionic无法构建Android应用程序,未找到ANDROID_HOME,但设置为

时间:2015-08-11 10:15:34

标签: android cordova ionic-framework ionic

我为工具设置了ANDROID_HOME和PATH。

我的.bashrc

结尾
export PATH="$PATH:/home/toskan/dev/android-sdk-linux/tools:/home/toskan/dev/android-sdk-linux/platforms"
export ANDROID_HOME=/home/toskan/dev/android-sdk-linux

如果我echo $PATH

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/toskan/dev/android-sdk-linux/tools:/home/toskan/dev/android-sdk-linux/platforms

如果我echo $ANDROID_HOME

我得到了

$ echo $ANDROID_HOME 
/home/toskan/dev/android-sdk-linux

我跑的时候 $ sudo ionic build android

我得到了

toskan@mycomp:~/IdeaProjects/myappmaster$ sudo ionic build android
Running command: /home/toskan/IdeaProjects/myappmaster/hooks/after_prepare/010_add_platform_class.js /home/toskan/IdeaProjects/myappmaster
add to body class: platform-android
Running command: /home/toskan/IdeaProjects/myappmaster/hooks/after_prepare/020_remove_sass_from_platforms.js /home/toskan/IdeaProjects/myappmaster
Running command: /home/toskan/IdeaProjects/myappmaster/platforms/android/cordova/build
    [Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
ERROR building one of the platforms: Error: /home/toskan/IdeaProjects/myappmaster/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/toskan/IdeaProjects/myappmaster/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
设置了

ANDROID_HOME并在命令行中设置了命令 android

打开android包管理器

我错过了什么?

1 个答案:

答案 0 :(得分:1)

问题确实如下:

sudo没有读取PATH,它有自己的路径,出于安全原因重置。

您可以在文件中更改该路径

/etc/sudoers

sudo拥有PATH

或者看到这个

sudo changes PATH - why?