流星:ANDROID_HOME 未设置,即使已设置

Meteor: ANDROID_HOME is not set even though it is set

OS : Ubuntu 14.04 框架:流星1.1.0.2 应用名称:Songofy

这是 meteor install-sdk android

的输出
 meteor install-sdk android
✓ Found Android bundle
✓ A JDK is installed                          
✓ Found Android Platform tools                
✓ Found Android Build Tools                   
✓ Found Android 19 API                        
✓ Found suitable Android x86 image            
✓ 'meteor' android virtual device (AVD) found 
✗ Android emulator acceleration is not installed
  (The Android emulator will be very slow without acceleration)
Platform requirements not yet met             
Please follow the instructions here:          
https://github.com/meteor/meteor/wiki/Mobile-Dev-Install:-Android-on-Linux#haxm

我使用

进入目录
cd Desktop/songofy

然后我输入 sudo add-platform android,它要求我接受 eprmission,然后发生了这样的事情:

`You must agree to the terms to proceed.       

Do you agree (Y/n)? Y

/home/abhishek/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/fibers/future.js:245
                        throw(ex);
                              ^
Error: Error running /home/abhishek/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/tools/cordova-scripts/cordova.sh

/home/abhishek/.meteor/android_bundle/.cordova/lib/npm_cache/cordova-android/3.6.4/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.

我使用这个添加 ANDROID_HOME 变量。

 abhishek@TiltedLines:~/Desktop/songofy$ export ANDROID_HOME=~/.meteor/android_bundle/android-sdk
 abhishek@TiltedLines:~/Desktop/songofy$ export PATH=$ANDROID_HOME/tools:$PATH
 abhishek@TiltedLines:~/Desktop/songofy$ export PATH=$ANDROID_HOME/platform-tools:$PATH

Cordova 和 Meteor 有什么问题?

我明白了。这是一个权限问题。因为 android 是作为用户安装的,并且为用户设置了环境变量,所以 sudo 无法访问这些变量。

所以我做的是

sudo -E su

我正在使用它来为 root 用户传输环境变量。我 运行 meteor 它为 root 安装流星。执行 meteor install-sdk android 它也会为 root 安装 sdk,然后 运行 sudo add-platform android。 Root 现在有 meteor 和 android sdk,所以应用 运行s.

希望这对您有所帮助。浪费了很多时间。

我在以下环境中遇到了同样的问题:

  • 流星 1.5
  • Android SDK 工具 26
  • $ANDROID_HOME 设置正确

这是我修复的方法: