当我尝试安装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
!
- 你可能不应该
- 即使
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/