当我尝试从我的 iOnic 应用程序构建 apk 时遇到问题。
当我发送$sudo ionic cordova build --release android --verbose
返回此:
**Failed to find 'ANDROID_HOME' environment variable.** Try setting it manually.
**Failed to find 'android' command in your 'PATH'.**
Try update your 'PATH' to include path to valid SDK directory.
CordovaError: Failed to find 'ANDROID_HOME' environment variable. Try setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
at /home/sion/lab/mifasol_dd/mifasol-beta/platforms/android/cordova/lib/check_reqs.js:297:19
at _fulfilled (/home/sion/lab/mifasol_dd/mifasol-beta/platforms/android/cordova/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/home/sion/lab/mifasol_dd/mifasol-beta/platforms/android/cordova/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/home/sion/lab/mifasol_dd/mifasol-beta/platforms/android/cordova/node_modules/q/q.js:796:13)
at /home/sion/lab/mifasol_dd/mifasol-beta/platforms/android/cordova/node_modules/q/q.js:857:14
at runSingle (/home/sion/lab/mifasol_dd/mifasol-beta/platforms/android/cordova/node_modules/q/q.js:137:13)
at flush (/home/sion/lab/mifasol_dd/mifasol-beta/platforms/android/cordova/node_modules/q/q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
[ERROR] An error occurred while running subprocess cordova.
cordova build android --release --verbose exited with exit code 1.
当我检查 ANDROID_HOME 时,有一个正确的 PATH
ANDROID_HOME=/主页/sion/Android/Sdk
我不知道发生了什么,你能帮帮我吗?
问候
答案1
当您通过 调用任何命令时sudo
,sudo
出于安全原因,将重置该命令的环境。请参阅man sudo;man sudoers
。
一定要用sudo
这个吗?为什么?
您是否可以通过找到群组访问权限并将自己添加到该群组来实现同样的目标?
ls -ld
sudo adduser $USER group
目前,这不是推荐的方法(因为它可能不完整),
sudo env PATH=$PATH ANDROID_HOME=$ANDROID_HOME $(type -p ionic) cordoba ...