Description:
cordova build android
ANDROID_HOME=/Users/Minzou/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
Error: spawn EACCES
[ERROR] An error occurred while running cordova build android (exit code 1).
[17:43:12]  lint finished in 2.41 s
bogon:cutePuppyPics Minzou$ cordova build android
ANDROID_HOME=/Users/Minzou/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
Error: spawn EACCES
Steps to Reproduce:
ionic cordova build android --prod
Example repo:
1.
2.
3.
Output:
ANDROID_HOME=/Users/Minzou/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
Error: spawn EACCES
My ionic info:
bogon:cutePuppyPics Minzou$ ionic info
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils  : 1.15.1
ionic (Ionic CLI) : 3.15.1
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.0.1
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.7.1
System:
Android SDK Tools : 26.1.1
Node              : v8.8.0
npm               : 5.5.1
OS                : macOS Sierra
Xcode             : Xcode 9.0.1 Build version 9A1004
Environment Variables:
ANDROID_HOME : /Users/Minzou/Library/Android/sdk
Misc:
backend : legacy
Other Information:
getting the same error here.
Here's a repo with the error.
Steps to reproduce:
ionic cordova build androidI have been struggling with this for a few days now as well, let us know if you figure anything out.
any fixes?
I'm stumped
After a long and really frustrating night I got mine woking.
This is the command that finally fixed it for MY configuration
sudo chmod 777 “/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle”
_Note the space in 'Android Studio'_
What is the root problem? I don't know. I do know that I recently downloaded the new android studio 3 and then this started being a problem. It probably is something to do with the 'gradle-4.1'.
On a lot of other threads that contain this same issue there is someone strongly advising against just 'chmod'ing random folders, and I see his point, but I tried everything else.
Before I ran the 'sudo chmod 777 ...", I deleted android studio and then reinstalled it.
I hope this helps.
EDIT: Just for additional detail, my .bash_profile, which I copied directly from the ionic setup guide for mac, specifics the targeted gradle file as 'gradle-3.2', yet my setup was not working until I ran the 'chmod' on the gradle-4.1/bin/gradle
@kevintowe  is right, use cordova with same problem,look at
https://cordova.apache.org/docs/en/latest/guide/cli/index.html#create-the-app
next step will cause problem
cordova build android 
so then use next commond will see detail problem.
cordova build --verbose android 
Having to sudo to change the permissions of the gradle executable isn't a clean solution.
For those who don't want to use sudo, an option is to downgrade to AS 2.3 while this issue is being fixed. : https://developer.android.com/studio/archive.html
I confirm the gradle need the good permission for the first launch after the update. You can get back to the original 644 after one build.
Related comments: https://github.com/ionic-team/ionic-cli/issues/2176#issuecomment-339780573
Making the gradle executable _actually executable_ again doesn't seem that unclean to me. The usage of sudo is justified because it's not writing files or messing up file ownership. Also, you may not need sudo if the files under /Applications/Android Studio.app are owned by your user.
@bhandaribhumin's solution in the comments I linked to is the best known workaround, as far as I can tell:
sudo chmod 755 "/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle"
Using an earlier version of Android Studio certainly will work, too. You can also install the Android SDK and gradle by itself, which is what I do.
@dwieeb I agree with you somewhat, but wouldn't it be nice for ionic to work out of the box with Android Studio ?
Same problem here, solved using
sudo chmod 755 "/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle"
Maybe if installing android-tools without Android Studio would solve the problem
@hugodes Definitely! We always want to support the latest and greatest stuff (which is often why things break like this all the time 😆). If you'll follow those comments I linked to, I do link to this Cordova issue, which we're tracking. The issue is with cordova-android, not the Ionic CLI, so we're waiting on an official fix. The Cordova team was caught by surprise by this as well.
Until then, the chmod workaround seems like the best fix for most people.
@dwieeb Thanks 755 on the gradle script did the trick.
@dwieeb my bad, didn't see the linked comment. Thanks for the update 😀
Saved my day. Same thing here, solved the problem.
sudo chmod 755 "/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle"
thx guys
Thanks guys!! this really helps!
Thank you guys, this works for me too.
In Mac Mini : You can't directly get /Applications/Android....... , So Goto Following Path
/Users/YourUserName/Library/Android/Applications/Android\ Studio.app/Contents/gradle/gradle-4.1/bin/gradle,
Command is : sudo chmod -R 777 /Users/YourUserName/Library/Android/Applications/Android\ Studio.app/Contents/gradle/gradle-4.1/bin/gradle
Nothing changing permissions fixed my issue
Hi,
I am having the same issue and I can't resolve changing the permissions of my file.
I copy here the ionic info output:
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils  : 1.16.0
ionic (Ionic CLI) : 3.16.0
System:
Node : v8.9.0
npm  : 5.5.1 
OS   : macOS Sierra
Misc:
backend : pro
Also the error I get with ionic cordova run android --verbose:
[DEBUG] Reason for not using local CLI: LOCAL_CLI_NOT_FOUND
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: '/Users/ana/Pitagorines/00_PROYECTOS/NEXCON/NexconApp', local:
false, binPath: '/usr/local/lib/node_modules/ionic/bin/ionic', libPath:
'/usr/local/lib/node_modules/ionic/dist/index.js' }
Running app-scripts build: --platform android --target cordova
[15:49:07] build dev started ...
[15:49:07] clean started ...
[15:49:07] clean finished in 5 ms
[15:49:07] copy started ...
[15:49:08] deeplinks started ...
[15:49:08] deeplinks finished in 134 ms
[15:49:08] transpile started ...
[15:49:19] transpile finished in 11.24 s
[15:49:19] preprocess started ...
[15:49:19] preprocess finished in 1 ms
[15:49:19] webpack started ...
[15:49:19] copy finished in 12.03 s
[15:49:37] webpack finished in 17.50 s
[15:49:37] sass started ...
[15:49:39] sass finished in 2.48 s
[15:49:39] postprocess started ...
[15:49:39] postprocess finished in 301 ms
[15:49:39] lint started ...
[15:49:39] build dev finished in 32.32 s
> cordova run android
ANDROID_HOME=/Users/ana/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
Error: spawn EACCES
[ERROR] An error occurred while running cordova run android (exit code 1).
[15:49:49] lint finished in 9.69 s
[DEBUG] registerShutdownFunction process.exit/normal shutdown
Some help could be really appreciated.
Nice work with ionic by the way.
Cheers
So far this command does the job! Works like a charm!!!
sudo chmod 755 "/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle"
you saved my day @dwieeb, thank you
How do you find gradle if using a Macbook? I tried checking /Users/YourUserName/Library/Android/Applications/Android\ Studio.app/Contents/gradle/gradle-4.1/bin/gradle but my machine only contains the sdk directory in /Users/YourUserName/Library/Android
I also tried the command find . -name android\ studio.app from the users directory but it is not returning anything. ( I do have Android Studio in my Launchpad and I can open it without any issues).
I solved my problem doing a:
cordova platform rm android
Followed by a:
cordova platform add android
Because a reason that i cannot found, the latest Gradle version dont work with the cordova android 6.3.0.
Hope it helps. :)
Had this issue cause i was keeping 2 versions of android studio on a mac. version 2.1.0 & 3.0.1 with 2 different names 'Android Studio' & 'Android Studio 2'. Fixed by renaming new version to 'Android Studio'.
@kevintowe Thanks! This really helped me a lot!
Thanks @dwieeb this works for me!
sudo chmod 755 "/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle"
this line work perfect for me
sudo chmod 755 "/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle"
As mentioned above the permissions on the gradle executable are wrong: it doesn't have executable permissions. I use this
chmod +x /Applications/Android\ Studio.app/Contents/gradle/gradle-4.1/bin/gradle
That only adds executable permissions and leaves the rest as in (worst idea is to give it 777 permissions as mentioned above)
after more tryings and failed all ways, finally i solved it with this solution:
First of all in terminal go to project folder using cd command, after that give grant permission to your user to access this folders JavaVirtualMachines, _YourProjectFolder_ using this commands:
1- sudo chmod -R a+rwx /Library/Java/JavaVirtualMachines *
2- sudo chmod -R a+rwx *
3- sudo chmod 777 /Applications/Android\ Studio.app/Contents/gradle/gradle-4.1/bin/gradle
it will be solved.
Thanks @moaazhomaid this works for me!
I had the similar problem. I tried all the permission issue mentioned above. Did not work for me. Then I run cordova command in --verbose mode. I the found issue is with Android Studio gradle module. you need to give permission to android studio gradle bin.
#How to check Issue
cordova build android --verbose
#How to fix
chmod -R a+rwx /Applications/Android\ Studio.app/Contents/gradle/gradle-4.1/bin/gradle
#Location may change watch the output of --verbose
I resolved it using this command.
sudo chmod -R 777 /Applications/Android\ Studio.app/Contents/gradle/gradle-4.1/bin/gradle
This is Permission Error While Building App
You Need to Give Permission Gradle
sudo chmod -R 777 /Applications/Android\ Studio\ 3.0\ Preview.app/Contents/gradle
I am just adding my observation to this thread so that you guys have more info.
I added background geo-location plugin and had to fix the issue with the same command : sudo chmod -R 777 /Applications/Android\ Studio.app/Contents/gradle/ bear in mind everything worked right up until I installed the plugin.
@moaazhomaid thnks. Its work for me.
grade version 3.2 works fine for me.
Thanks @dwieeb this works for me and you saved my day!
sudo chmod 755 "/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle"
Thanks @kevintowe and Remember run
ionic cordova platform rm android
and then
ionic cordova platform add android
I forgot that and still had this issue..
I had the same kind of issue and the chmod command described above didn't work for me. Running a verbose Cordova build got me closer to the issue: cordova run android --verbose --buildConfig ./build.json.
It stopped at:
Running command: /.../my-project-directory/cordova/platforms/android/gradlew cdvBuildDebug -b /.../my-project-directory/cordova/platforms/android/build.gradle -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m -Pandroid.useDeprecatedNdk=true
Error: spawn EACCES
So I ran that command myself and it gave me the following error:
permission denied: /.../my-project-directory/cordova/platforms/android/gradlew
Fixed it running the following command:
chmod +x /.../my-project-directory/cordova/platforms/android/gradlew
Hope this helps anyone.
Thanks!
We have done after change gradle permission ;)
Ionic crodova platform rm android
then
Ionic crodova platform add android
works for me 
Because earlier i was build apk using android studio so the gradle version changed
I had same issue.
It was because I had 2 copies of Android Studio. resolved by removing canary version 
The permission fix of gradle worked for me, thanks! - although i do not understand what made this error happen, we didn't change anything.
cordova build --verbose android helps identifying a necessary
chmod 777 platforms/android/gradlew
build passed, thanks to all :)
reverted then to chmod 755 platforms/android/gradlew 
(locked due to this being the most active issue from google)
The fix is here: https://github.com/ionic-team/ionic-cli/issues/2835#issuecomment-340875489
Most helpful comment
After a long and really frustrating night I got mine woking.
This is the command that finally fixed it for MY configuration
sudo chmod 777 “/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle”_Note the space in 'Android Studio'_
What is the root problem? I don't know. I do know that I recently downloaded the new android studio 3 and then this started being a problem. It probably is something to do with the 'gradle-4.1'.
On a lot of other threads that contain this same issue there is someone strongly advising against just 'chmod'ing random folders, and I see his point, but I tried everything else.
Before I ran the 'sudo chmod 777 ...", I deleted android studio and then reinstalled it.
I hope this helps.
EDIT: Just for additional detail, my .bash_profile, which I copied directly from the ionic setup guide for mac, specifics the targeted gradle file as 'gradle-3.2', yet my setup was not working until I ran the 'chmod' on the gradle-4.1/bin/gradle