Skip to content
Advertisement

Cordova can’t find ANDROID_HOME or android in my PATH although they are there

I set up ANDROID_HOME to my android installation dir as well as adding $ANDROID_HOME/platform-tools and $ANDROID_HOME/tools to my PATH.

When adding the android platform to my project, cordova seems to find android as it needs to run “android update project …..” for doing so but when I’m trying to run “cordova run android” it results in the following error:

ERROR: Error: Failed to find 'ANDROID_HOME' environment variable. Try 
setting it manually.
enter code hereFailed to find 'android' command in your 'PATH'. Try 
update your 'PATH' to include path to valid SDK directory.
ERROR running one or more of the platforms: Error: 
[PATH_TO_PROJECT]/platforms/android/cordova/run: Command failed with exit 
code 2

It seems like all of a sudden cordova lost access to my environment variables or maybe it’s a version conflict of some sort?

I installed android SDK 26 as well as all API and build tools between 19 and 22 (as those are the requirements of the project) I am running cordova 6.0.0 phonegap 7.0.1 My system is a debian

I tried everything that was suggested in all the other posts with similar issues but still no success and it still gives me the same error.

Probably it’s just a little thing I have overlooked but right now I’m clueless and thankful for any idea as to what might be causing the problem.

Advertisement

Answer

Maybe for some reason, these files are under your home but you don’t have permissions on then, if you execute the command chown (change owner) with recursive param (-r) it will change the ownership of the whole directory and you won’t have any permission issues. sudo chown -R yourusername:yourusername ~/directory

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement