ionic-cli: cordova build android error spawn EACCES when I update Android Studio 3.0(Gradle 4.1)
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:
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:
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 12
- Comments: 45 (3 by maintainers)
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
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 needsudo
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:
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.
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
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
@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
so then use next commond will see detail problem.
I resolved it using this command.
sudo chmod -R 777 /Applications/Android\ Studio.app/Contents/gradle/gradle-4.1/bin/gradle
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.
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.
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)
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 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. 😃
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
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 @kevintowe and Remember run
ionic cordova platform rm android
and thenionic cordova platform add android
I forgot that and still had this issue…
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.
this line work perfect for me
sudo chmod 755 "/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle"
Thanks @dwieeb this works for me!
sudo chmod 755 "/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle"
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”
@dwieeb my bad, didn’t see the linked comment. Thanks for the update 😀
@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.