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

标签 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) 到目前为止,还不错。现在让我们安装安卓平台

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

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

最佳答案

您正在使用 sudo!

  1. 你可能不应该
  2. 即使 ANDROID_HOME 变量是为您的当前用户定义的,并不意味着它也为 root 用户定义,这就是 sudo 调用的环境是。

我真的不建议对 meteor 使用 sudo。如果你能避免这种情况,那么它应该可以工作,你的问题就解决了。否则确保也为 root 用户定义 ANDROID_HOME 变量,或者只使用

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

相反。

关于android - Meteor - 安装 android 平台找不到 ANDROID_HOME 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34247568/

相关文章:

android - 如何在 Android 中更改 Google Map api v2 折线

javascript - MeteorJS 和 x-editable-reactive-template

javascript - 发布一个集合以及与第一个集合中的任何文档相关的其他集合的文档

java - Android - 找出用户当前处于哪个上下文/Activity 中?

android - SearchView AppCompatActivity 中的空指针?

javascript - 没有 MongoDB 的 Meteor 1.7

javascript - Dropzone 卡在大于 1mb 的文件上

javascript - meteor 回调 天上回调又回调

android - 带有 Fragment 选项卡和 AdMob 的操作栏

android - 如何从数据库获取项目的值并将其设置为微调器值