Meteor - 安装android平台无法找到ANDROID_HOME变量

时间:2015-12-13 03:06:24

标签: android meteor

当我尝试安装Android平台时,我收到一个错误,即环境变量ANDROID_HOME无法找到,但如果我回应它,​​则证明它存在。

让我带你去看看:

1)让我们创建一个新应用

dbugger@mercury:~/projects/meteor$ meteor create test 
Created a new Meteor app in 'test'.           

To run your new app:                          
  cd test                                     
  meteor                                      

If you are new to Meteor, try some of the learning resources here:
  https://www.meteor.com/learn                

2)到目前为止,非常好。让我们现在安装android平台

dbugger@mercury:~/projects/meteor$ cd test/

dbugger@mercury:~/projects/meteor/test$ meteor add-platform android --verbose
Writing new config.xml                        
Creating Cordova project                      
% Creating a new cordova project.             
Adding platform Android to Cordova project    
=> Errors executing Cordova commands:         

   While adding platform Android to Cordova project:
   Cordova error: CordovaError: Failed to fetch platform android
   Probably this is either a connection problem, or platform spec is incorrect.
   Check your connection and platform name/version/URL.
   undefined
   at /home/dbugger/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/cordova-lib/src/cordova/platform.js:270:25
   at _rejected (/home/dbugger/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/q/q.js:797:24)
   at /home/dbugger/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/q/q.js:823:30
   at Promise.when (/home/dbugger/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/q/q.js:1035:31)
   at Promise.promise.promiseDispatch (/home/dbugger/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/q/q.js:741:41)
   at /home/dbugger/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/q/q.js:557:44
   at flush (/home/dbugger/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/q/q.js:108:17)
   at process._tickCallback (node.js:448:13)
   (If the error message contains suggestions for a fix, note that this may not apply to the Meteor integration. You can try running again with the --verbose option to help diagnose the issue.)

3)嗯,这样做不太顺利。让我们试试sudo

dbugger@mercury:~/projects/meteor/test$ sudo meteor add-platform android --verbose
Adding platform Android to Cordova project    
% Adding android project...                   
android: added platform                       
Checking Cordova requirements for platform Android

Your system does not yet seem to fulfill all requirements to build apps for Android.

Please follow the installation instructions here:
https://github.com/meteor/meteor/wiki/Mobile-Development-Install:-Android-on-Linux

Status of the requirements:                   
✓ Java JDK                                    
✗ Android SDK: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
  Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
✗ Android target: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
✗ Gradle: Could not find gradle wrapper within Android SDK. Could not find Android SDK directory.
  Might need to install Android SDK or set up 'ANDROID_HOME' env variable.

4)等等,什么?我确定已设置环境变量。我们来检查吧。

dbugger@mercury:~/projects/meteor/test$ echo $ANDROID_HOME
/home/dbugger/Android/Sdk

5)我知道了!那为什么会失败......?让我们再检查一下

dbugger@mercury:~/projects/meteor/test$ sudo meteor add-platform android --verbose


While adding platforms:
error: android: platform is already added

什么?现在事实证明它最终安装DID ??这里发生了什么?我怀疑我的系统中出现了大量错误配置,但我不确定是什么......

1 个答案:

答案 0 :(得分:1)

您正在使用sudo

  1. 你可能不应该
  2. 即使为当前用户定义ANDROID_HOME变量也不意味着它也是为root用户定义的,这就是sudo调用的环境。
  3. 我真的建议不要在流星上使用sudo。如果你可以避免这种情况,那么它应该可以工作,你的问题就解决了。否则,请确保也为root用户定义ANDROID_HOME变量,或者只使用

    sudo env ANDROID_HOME=[whatever you want it to be] meteor
    

    代替。