Unable to run cordova run android in IONIC project

2019-01-20 15:53发布

问题:

I installed ionic in my Mac and created project using

$ ionic start MyIonicProject tutorial

Now i run

$ cd MyIonicProject
$ ionic serve

Now it is serving successfully in browser working fine. So I would like to see the same in android mobile so tried using the below command,

ionic cordova run android --prod --release

This is the pretty concise issue and i can't able to rectify my OSX error's below are the issues when i run above in my Mac..

 > cordova run android --release
ANDROID_HOME=/usr/local/Caskroom/android-sdk/3859397,26.0.2
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
Error: spawn EACCES

[ERROR] An error occurred while running cordova run android --release (exit code 1).

[17:54:52]  lint finished in 2.69 s 

Please help me someone on how to rectify these error when running the IONIC project on Android natively.

Thanks,

回答1:

I had run into a similar issue.I had to set executable permissions in the android platform gradle. Correction: It was actually executable permissions in the android gradle installation. It seems to be a reported issue here and the actual issue in cordova is tracked here.

Run the command:

chmod -R +x <location_of_android_studo>/gradle/gradle-<version>/bin

NOTE: -R will run the command recursively from the given directory.