If you've recently upgraded to the latest version of Ionic you might find your project builds breaking for Android with an EACCES error.
If you weren't already aware an EACCES error is unix speak for permission denied - basically a particular file doesn't have the prerequisite permissions to be accessed and/or executed.
Unfortunately the Ionic CLI doesn't provide any details about where this error occurs so you need to dig a little deeper to determine this information.
Armed with the knowledge of what causes an EACCES error it then becomes a process of determining which file (or files) lack the correct permissions.
We can accomplish this by re-running the android build command with an added --verbose flag like so:
cordova run android --verbose
This will print detailed information to the screen about what is happening at each stage of the build process (which is pretty handy when you're sat there scratching your head trying to figure out where to start looking for the cause of such errors).
Sure enough the --verbose flag subsequently identifies the file that lacks the necessary permissions causing the build process to break:
"/Applications/Android Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle" -p /My-project/platforms/android wrapper -b /My-project/platforms/android/wrapper.gradle Error: spawn EACCES
Now it's simply a matter of changing the permission for that file with the following command:
chmod +x /Applications/Android Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle
This simply states that the file will be made executable which, once completed, will allow the next android build process to proceed without throwing up any further EACCES errors...exactly what we need!
Hopefully this helps any developers out there experiencing the same issue.
If you find your Android builds breaking with EACCES errors simply use the --verbose flag to determine which file(s) they are breaking on and then set the correct permissions accordingly.
All things being equal that should subsequently eliminate those errors and allow your build process to proceed unabated.
If you enjoyed or found useful what you've read here then please sign up to my mailing list and, if you haven't done so already, take a look at my e-book: Mastering Ionic for information about troubleshooting further issues when developing apps with the Ionic Framework.