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

Could not find or load main class org.gradle.wrapper.GradleWrapperMain

Open ntenisOT opened this issue 11 years ago • 10 comments

Problem with building my app with ionic in the CLI for Android (it runs ok for iOS). Here is the error code:

/usr/local/bin/ionic run android
Updated the hooks directory to have execute permissions
Running command:     /Users/ntenisOT/Dropbox/MyProjects/PhoneGap:ionic/LifeyApp/hooks/after_prepare/010_add_platform_class.js /Users/ntenisOT/Dropbox/MyProjects/PhoneGap:ionic/LifeyApp
add to body class: platform-android
Running command: /Users/ntenisOT/Dropbox/MyProjects/PhoneGap:ionic/LifeyApp/platforms/android/cordova/run 
ANDROID_HOME=/Users/ntenisOT/Android/android-sdk-macosx
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
WARNING : No target specified, deploying to device '078f0369'.
Running: /Users/ntenisOT/Dropbox/MyProjects/PhoneGap:ionic/LifeyApp/platforms/android/gradlew cdvBuildDebug -b  /Users/ntenisOT/Dropbox/MyProjects/PhoneGap:ionic/LifeyApp/platforms/android/build.gradle -PcdvBuildArch=arm -Dorg.gradle.daemon=true
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

/Users/ntenisOT/Dropbox/MyProjects/PhoneGap:ionic/LifeyApp/platforms/android/cordova/node_modules/q/q.js:126
                throw e;
                      ^
Error code 1 for command: /Users/ntenisOT/Dropbox/MyProjects/PhoneGap:ionic/LifeyApp/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/ntenisOT/Dropbox/MyProjects/PhoneGap:ionic/LifeyApp/platforms/android/build.gradle,-PcdvBuildArch=arm,-Dorg.gradle.daemon=true 
ERROR running one or more of the platforms: Error: /Users/ntenisOT/Dropbox/MyProjects/PhoneGap:ionic/LifeyApp/platforms/android/cordova/run: Command failed with exit code 1
You may not have the required environment or OS to run this project

Here is my ionic info

Cordova CLI: 5.1.1 Ionic Version: 1.0.0 Ionic CLI Version: 1.5.0 Ionic App Lib Version: 0.1.0 ios-deploy version: Not installed ios-sim version: 3.1.1 OS: Mac OS X Yosemite Node Version: v0.12.4 Xcode version: Xcode 6.3.2 Build version 6D2105

I tried cordova build android

and it shows the same error:

Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

Can you please investigate this issue :) Thanks in advance!

ntenisOT avatar Jun 11 '15 16:06 ntenisOT

What's the results from cordova platform ls?

Also, whats in the contents of platforms/android folder?

Specifically: ls -la platforms/android/gradle/wrapper/

jbavari avatar Jun 19 '15 03:06 jbavari

Hello @jbavari here are the results of what you requested:

cordova platform ls

cordova platform ls
Installed platforms: android 4.0.2, ios 3.8.0
Available platforms: amazon-fireos, blackberry10, browser, firefoxos

platforms/android contents

ls -l
total 88
-rw-r--r--@  1 ntenisOT  staff   2542 Jun 14 16:46 AndroidManifest.xml
drwxr-xr-x@ 10 ntenisOT  staff    340 Jun 11 15:35 CordovaLib
drwxr-xr-x@  4 ntenisOT  staff    136 Jun 11 20:20 assets
-rw-r--r--@  1 ntenisOT  staff  11185 Jun 11 20:17 build.gradle
-rw-r--r--@  1 ntenisOT  staff   3934 Jun 11 15:38 build.xml
drwxr-xr-x@ 17 ntenisOT  staff    578 Jun 10 17:52 cordova
drwxr-xr-x@  5 ntenisOT  staff    170 Jun 11 20:16 gradle
-rwxr-xr-x@  1 ntenisOT  staff   5080 Jun 11 20:12 gradlew
drwxr-xr-x@  8 ntenisOT  staff    272 Jun 13 12:28 libs
-rw-r--r--@  1 ntenisOT  staff    436 Jun 11 13:09 local.properties
drwxr-xr-x@  4 ntenisOT  staff    136 Jun 10 17:52 platform_www
-rw-r--r--@  1 ntenisOT  staff    781 Jun 11 13:09 proguard-project.txt
-rw-r--r--@  1 ntenisOT  staff    601 Jun 10 17:52 project.properties
drwxr-xr-x@ 23 ntenisOT  staff    782 Jun 10 17:52 res
-rw-r--r--@  1 ntenisOT  staff     66 Jun 11 20:12 settings.gradle
drwxr-xr-x@  6 ntenisOT  staff    204 Jun 14 16:39 src

ls -la platforms/android/gradle/wrapper/

total 112
drwxr-xr-x@ 4 ntenisOT  staff    136 Jun 11 20:12 .
drwxr-xr-x@ 5 ntenisOT  staff    170 Jun 11 20:16 ..
-rw-r--r--@ 1 ntenisOT  staff  49896 Jun 11 20:12 gradle-wrapper.jar
-rw-r--r--@ 1 ntenisOT  staff    195 Jun 11 20:12 gradle-wrapper.properties

I don't know if it helps but the project builds and runs ok on iOS.

Thanks.

ntenisOT avatar Jun 19 '15 03:06 ntenisOT

@ntenisOT I had the same problem. It seems to be the colon in your project's path. Something must be doing something like PATH=$PATH:/my/path/with/a:colon/gradle/wrapper. I'm not sure if colons are illegal in cordova projects' path names, but changing the colon to an underscore fixed the build.

imhoffd avatar Oct 27 '15 20:10 imhoffd

Hi i am new to ionic + cordova .Getting an error while calling ionic build android.

Exception in thread "main" java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:78) at org.gradle.wrapper.Install.createDist(Install.java:47) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48) Caused by: java.util.zip.ZipException: error in opening zip file at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.(ZipFile.java:215) at java.util.zip.ZipFile.(ZipFile.java:145) at java.util.zip.ZipFile.(ZipFile.java:159) at org.gradle.wrapper.Install.unzip(Install.java:160) at org.gradle.wrapper.Install.access$400(Install.java:29) at org.gradle.wrapper.Install$1.call(Install.java:70) at org.gradle.wrapper.Install$1.call(Install.java:47) at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65) ... 3 more

C:\Users\vishnu\Desktop\Angular\mobile\first\myapp\platforms\android\cordova\node_modules\q\q.js:126 throw e; ^ Error code 1 for command: cmd with args: /s /c "C:\Users\vishnu\Desktop\Angular\mobile\first\myapp\platforms\android\gradlew cdvBuildDebug -b C:\Users\vishnu\Desktop\Angular\mobile\first\myapp\platforms\android\build.gradle -Dorg.gradle.daemon=true" ERROR building one of the platforms: Error: cmd: Command failed with exit code 1 You may not have the required environment or OS to build this project Error: cmd: Command failed with exit code 1 at ChildProcess.whenDone (C:\Users\vishnu\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:139:23) at emitTwo (events.js:87:13) at ChildProcess.emit (events.js:172:7) at maybeClose (internal/child_process.js:818:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

ghost avatar Nov 05 '15 20:11 ghost

  • I am facing the same issue. Please suggest.

ravikajain avatar Mar 02 '16 07:03 ravikajain

@ravikajain Did my fix not work for you? https://github.com/driftyco/ionic-cli/issues/478#issuecomment-151629678

imhoffd avatar Mar 02 '16 13:03 imhoffd

@dwieeb I have the same problem but i didn't understand exactly what you mean, you mean the path must be specified in a bash_profile?

pillito avatar May 12 '16 08:05 pillito

@pillito No. @ntenisOT's issue was that he had a colon in his workspace path. If you don't have a colon in your workspace path, then you have a different problem. Post the entire error and I might be able to help.

imhoffd avatar May 12 '16 14:05 imhoffd

Hi, i am getting same error when build the apk

Exception in thread "main" java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:78) at org.gradle.wrapper.Install.createDist(Install.java:47) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48) Caused by: java.util.zip.ZipException: error in opening zip file at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.(ZipFile.java:215) at java.util.zip.ZipFile.(ZipFile.java:145)

at java.util.zip.ZipFile.(ZipFile.java:159) at org.gradle.wrapper.Install.unzip(Install.java:160) at org.gradle.wrapper.Install.access$400(Install.java:29) at org.gradle.wrapper.Install$1.call(Install.java:70) at org.gradle.wrapper.Install$1.call(Install.java:47) at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65) ... 3 more

i am doing delete file from :~/.gradle/wrapper/dists$ gradle-2.13-all

then again build its work for me.

the problem is there the gradle-2.13-all is not complete download because file size to long when build apk then download the file.....

anuragranjan242 avatar Sep 24 '16 15:09 anuragranjan242

I had a problem similar to this and its because I had a broken Android studio installed and when I reinstalled it instead of replacing my sdk folder under users\ {your name}\appdata\local\android it created a new folder called sdk1 which was not being called.

imanube avatar Dec 13 '16 20:12 imanube