When I tried to install the Android platform, I get a error that the environment variable ANDROID_HOME cant be found, but if I echo it, it proves it exists.

Let me walk you to it:

1) Lets create a new app

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) So far, so good. Lets now install the android platform

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) Well, that did not work out so well. Let's try with 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) Wait, what? Im sure that environment variable is set. Let's check it.

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

5) I knew it! So why did it fail...? Let's check it up again

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


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

What?! Now it turns out that it DID install in the end?? What is going on here? I suspect something is greatly misconfigured in my system, but I am not sure what...

share|improve this question
    
I have exactly the same issues, have you resolved this? – alek kowalczyk Jan 3 '16 at 22:42
    
I have not solved it yet... – Enrique Moreno Tent Jan 12 '16 at 11:45
    
I solved it, but can't reproduce it to provide a clear answer, generally for sure sudo shouldn't be used in meteor, I had to give the permissions for my user for all meteor/project/android folders. – alek kowalczyk Jan 12 '16 at 13:09

you are using sudo!

  1. you probably shouldn't
  2. even if the ANDROID_HOME variable is defined for your current user does not mean it is also defined for the root user, which is what the environment of the sudo call will be.

I'd really recommend against using sudo for meteor. If you can avoid that, then it should work and your problem is solved. Otherwise make sure to define the ANDROID_HOME variable also for the root user, or just use

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

instead.

share|improve this answer
    
with sudo env I do not get that error... How about if I need to set more than one env variable? – Enrique Moreno Tent Dec 13 '15 at 8:19
    
Im going to review my whole installation process. Probably I installed something as I shouldnt... – Enrique Moreno Tent Dec 13 '15 at 8:29
    
all you might need to do to fix your installation is sudo chown -R USERNAME .meteor in your home directory and in your project folder sudo chown -R USERNAME .. – Christian Fritz Dec 13 '15 at 20:38
    
I take that USERNAME must be my system username, in this case "dbugger". Sadly that did not fix my issue. I still need to use sudo env ... – Enrique Moreno Tent Dec 13 '15 at 22:00
    
check the owner on all your project files and in ~/.meteor. They must all be your own. After that you should be able to start meteor without sudo. – Christian Fritz Dec 13 '15 at 22:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.