If I follow this steps to create a new app:
Rubens-MacBook-Pro:~ rlopez$ npm install -g cordova ionic
Rubens-MacBook-Pro:~ rlopez$ ionic start myApp tabs
Rubens-
For those who gets similar error after updating Android Studio to version 3.x, you can run the following command to fix it:
sudo chmod 755 /Applications/Android\ Studio.app/Contents/gradle/gradle-4.1/bin/gradle
Hopefully it helps!
Running ionic build android --verbose
gives the following output:
/Applications/Android Studio 2.4
Preview.app/Contents/gradle/gradle-3.4.1/bin/gradle -p
/Users/rlopez/myApp/platforms/android wrapper -b
/Users/rlopez/myApp/platforms/android/wrapper.gradle
Error: spawn EACCES
at exports._errnoException (util.js:1018:11)
at ChildProcess.spawn (internal/child_process.js:319:11)
at Object.exports.spawn (child_process.js:378:9)
at exports.spawn(/Users/rlopez/myApp/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:134:31)
at GradleBuilder.runGradleWrapper(/Users/rlopez/myApp/platforms/android/cordova/lib/builders/GradleBuilder.js:78:14)
at /Users/rlopez/myApp/platforms/android/cordova/lib/builders/GradleBuilder.js:178:21
at _fulfilled (/Users/rlopez/myApp/platforms/android/cordova/node_modules/q/q.js:854:54)
at self.promiseDispatch.done (/Users/rlopez/myApp/platforms/android/cordova/node_modules/q/q.js:883:30)
at Promise.promise.promiseDispatch (/Users/rlopez/myApp/platforms/android/cordova/node_modules/q/q.js:816:13)
at /Users/rlopez/myApp/platforms/android/cordova/node_modules/q/q.js:570:49
Changing the permissions of /Applications/Android Studio 2.4 Preview.app/Contents/gradle/gradle-3.4.1/bin/gradle
solves the problem.
Just encountered the same issue, and I don't think it has anything to do with sudo - that command is simply missing the execute permission
chmod +x hooks/after_prepare/010_add_platform_class.js