I’m getting the following error when running ‘ionic cordova run android’
ANDROID_HOME=/home/nathan/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
studio
/usr/lib/gradle/4.8.1/bin/gradle: 172: exec: : Permission denied
(node:7996) UnhandledPromiseRejectionWarning: Error: /usr/lib/gradle/4.8.1/bin/gradle: Command failed with exit code 126
at ChildProcess.whenDone (/home/nathan/Workspace/demos/studentsapp-ionic/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:7996) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7996) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I see you’re working on a Linux machine but this is what I do on my Windows machine. May it can give you some new insights…
Every time i get some gradle errors, first thing I do is deleting the .gradle folder in my user directory. (Asuming your setup doesn’t depend on other software and/or packages; please check your own other dependencies first.!)
Close all running applications
Navigate to C:\Users\ [USERNAME] in explorer
Delete the .gradle folder and it’s content (you may need to logoff and login to release some running processes; if so, try this step again)
Open Android Studio. Create a new empty project or open an existing project. When loading the project Android Studio willl download and prepare all required files and it will create your .gradle folder again.
You may also need to delete and re-create your existing platforms (e.g. android).
Try running ionic cordova run android again (console might download some dependencies again)
Building the first time after these steps does also fail with me again, but after trying again the building does succeed. (Just had to do this today again; working)
I found the problem, by accident. I was doing some random bs, like installing yarn. It gave me a message about unnecessary packages, one of them being gradle 4.8.1, and I knew Gradle 4.9 was also installed. So I runned apt-autoremove, tried to build, cordova decided to use gradle 4.9 by default and my app started.