Error when I try to generate a libgdx projet

白昼怎懂夜的黑 提交于 2019-12-12 17:27:24

问题


I'm trying to do a project on android studio with libgdx but I have a problem when I generate a libgdx project. At first, he told me that my local variable JAVA_HOME had a problem and he could findn't my JDK (that was present) When I tried to copy my java JDK on my file "c:\dev\java\JDK", he told me :

Generating app in C:\Users\Thomas\Desktop\YoloRPG
Executing 'C:\Users\Thomas\Desktop\YoloRPG/gradlew.bat clean --no-daemon'
Unzipping C:\Users\Thomas\.gradle\wrapper\dists\gradle-2.10-
all\5b6kqrscumh9p4evkkemdk57ad\gradle-2.10-all.zip to 
C:\Users\Thomas\.gradle\wrapper\dists\gradle-2.10-all\5b6kqrscumh9p4evkkemdk57ad
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:61)
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:219)
at java.util.zip.ZipFile.<init>(ZipFile.java:149)
at java.util.zip.ZipFile.<init>(ZipFile.java:163)
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
Done!
To import in Eclipse: File -> Import -> Gradle -> Gradle Project
To import to Intellij IDEA: File -> Open -> build.gradle

And when I try to open the created project on android with files --> import settings... A message box popup with written "Cannot find file 'C:\Users\Thomas\Desktop\YoloRPG\settings.jar'"

Can someone please help me ? :(


回答1:


Caused by: java.util.zip.ZipException: error in opening zip file

This mean that a file that Gradle has downloaded has become corrupted due to somehow or some reason. This might be the download of Gradle itself (which the wrapper does), or any dependency that Gradle has downloaded to run your libgdx build.

Gradle doesn't attempt to detect or resolve the problem, so you need to fix it manually. The solution is often to purge Gradle's download caches and let it get fresh copies of what it needs.

To do that, delete the .gradle directories in both your home directory and in your project's root directory and try building again.

In your case home directory is

C:\Users\Thomas\.gradle

and Project's root directory

C:\Users\Thomas\Desktop\YoloRPG



回答2:


Thanks, I used a similar methode to solve my problem. I went to : c:\Users\Thomas\.gradle\wrapper\dist

and deleted the file gradle-2.10-all

then I tiped in google chrome http://services.gradle.org/distributions/gradle-2.10-all.zip and pasted the zip file where gradle-2.10-all was

Then when I retried, it downloading a corect version of gradle and it worked !

But when I try to import the libgdx project on android studio I still have the message :

Cannot find file 'Cannot find file 'C:\dev\libgdx projects\YoloRPG\settings.jar'

I'm using android studio 2.2.3, and on all the tutorials I checked, they all have a button "import non android studio project", but I only have "import settings...", do you know how I can import a libgdx on android studio now ?




回答3:


go to androidStudioProjects/yourProject/gradle/wrapper open gradle-wrapper properties file

in last line: (change in this line) distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip

change in: /gradle-2.2-all.zip with your version eg: in my case i replaced with distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip



来源:https://stackoverflow.com/questions/42090713/error-when-i-try-to-generate-a-libgdx-projet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!