ionic-cli icon indicating copy to clipboard operation
ionic-cli copied to clipboard

cordova build android error spawn EACCES when I update Android Studio 3.0(Gradle 4.1)

Open silentcmz opened this issue 9 years ago • 45 comments

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:

silentcmz avatar Oct 26 '17 09:10 silentcmz

getting the same error here.

Here's a repo with the error.

Steps to reproduce:

  • update Android Studio to v3.
  • clone https://github.com/hugodes/android-eacces
  • run ionic cordova build android

hugodes avatar Oct 26 '17 14:10 hugodes

I have been struggling with this for a few days now as well, let us know if you figure anything out.

kevintowe avatar Oct 27 '17 10:10 kevintowe

any fixes? I'm stumped

tskweres avatar Oct 28 '17 03:10 tskweres

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 avatar Oct 28 '17 15:10 kevintowe

@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 

wavelynn avatar Oct 30 '17 02:10 wavelynn

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

hugodes avatar Oct 30 '17 10:10 hugodes

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.

ghost avatar Oct 31 '17 11:10 ghost

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.

imhoffd avatar Oct 31 '17 19:10 imhoffd

@dwieeb I agree with you somewhat, but wouldn't it be nice for ionic to work out of the box with Android Studio ?

hugodes avatar Nov 02 '17 08:11 hugodes

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

storrisi avatar Nov 02 '17 11:11 storrisi

@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.

imhoffd avatar Nov 04 '17 06:11 imhoffd

@dwieeb Thanks 755 on the gradle script did the trick.

peterhorsley avatar Nov 04 '17 20:11 peterhorsley

@dwieeb my bad, didn't see the linked comment. Thanks for the update 😀

hugodes avatar Nov 06 '17 10:11 hugodes

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

quarantaquatro avatar Nov 07 '17 20:11 quarantaquatro

Thanks guys!! this really helps!

tonisilvan avatar Nov 09 '17 13:11 tonisilvan

Thank you guys, this works for me too.

xllordella avatar Nov 15 '17 10:11 xllordella

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

saravanans-arch avatar Nov 17 '17 03:11 saravanans-arch

Nothing changing permissions fixed my issue

erperejildo avatar Nov 22 '17 21:11 erperejildo

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

brunoescalona-zz avatar Nov 23 '17 14:11 brunoescalona-zz

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"

saids avatar Nov 26 '17 03:11 saids