Android Studio构建LibGDX项目遇ZipFile初始化错误及解决
编辑:已解决问题,原因是未使用与LibGDX一致的Android API和SDK版本。
LibGDX项目构建错误问题
我尝试在Android Studio中构建首个LibGDX项目时出现错误:
A build operation failed. 'void org.apache.commons.compress.archivers.zip.ZipFile.<init>(java.nio.channels.SeekableByteChannel)' 'void org.apache.commons.compress.archivers.zip.ZipFile.<init>(java.nio.channels.SeekableByteChannel)'
错误截图
我使用的是最新版Android Studio、最新版LibGDX Setup工具及JDK 18。
以下是我的build.gradle文件:
buildscript { repositories { mavenLocal() mavenCentral() gradlePluginPortal() maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } google() } dependencies { classpath 'org.wisepersist:gwt-gradle-plugin:1.1.16' classpath 'org.gretty:gretty:3.0.7' classpath 'com.android.tools.build:gradle:7.2.2' classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.16' } } allprojects { apply plugin: "eclipse" version = '1.0' ext { appName = "JumpMaster" gdxVersion = '1.11.0' roboVMVersion = '2.3.16' box2DLightsVersion = '1.5' ashleyVersion = '1.7.4' aiVersion = '1.8.2' gdxControllersVersion = '2.2.1' } repositories { mavenLocal() mavenCentral() google() gradlePluginPortal() maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } maven { url "https://oss.sonatype.org/content/repositories/releases/" } maven { url "https://jitpack.io" } } } project(":desktop") { apply plugin: "java-library" dependencies { implementation project(":core") api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" api "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop" api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop" api "com.badlogicgames.gdx-controllers:gdx-controllers-desktop:$gdxControllersVersion" api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop" } } project(":android") { apply plugin: "com.android.application" configurations { natives } dependencies { implementation project(":core") api "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64" api "com.badlogicgames.gdx:gdx-bullet:$gdxVersion" natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-arm64-v8a" natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86" natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86_64" api "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion" api "com.badlogicgames.ashley:ashley:$ashleyVersion" api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64" api "com.badlogicgames.gdx:gdx-ai:$aiVersion" api "com.badlogicgames.gdx-controllers:gdx-controllers-android:$gdxControllersVersion" api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64" } } project(":ios") { apply plugin: "java-library" apply plugin: "robovm" dependencies { implementation project(":core") api "com.mobidevelop.robovm:robovm-rt:$roboVMVersion" api "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion" api "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion" api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios" api "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-ios" api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios" api "com.badlogicgames.gdx-controllers:gdx-controllers-ios:$gdxControllersVersion" api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios" } } project(":html") { apply plugin: "java-library" apply plugin: "gwt" apply plugin: "war" apply plugin: "org.gretty" dependencies { implementation project(":core") api "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion" api "com.badlogicgames.gdx:gdx:$gdxVersion:sources" api "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources" api "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion:sources" api "com.badlogicgames.ashley:ashley:$ashleyVersion:sources" api "com.badlogicgames.gdx:gdx-ai:$aiVersion:sources" api "com.badlogicgames.gdx-controllers:gdx-controllers-core:$gdxControllersVersion:sources" api "com.badlogicgames.gdx-controllers:gdx-controllers-gwt:$gdxControllersVersion" api "com.badlogicgames.gdx-controllers:gdx-controllers-gwt:$gdxControllersVersion:sources" api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources" api "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources" } } project(":core") { apply plugin: "java-library" dependencies { api "com.badlogicgames.gdx:gdx:$gdxVersion" api "com.badlogicgames.gdx:gdx-bullet:$gdxVersion" api "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion" api "com.badlogicgames.ashley:ashley:$ashleyVersion" api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" api "com.badlogicgames.gdx:gdx-ai:$aiVersion" api "com.badlogicgames.gdx-controllers:gdx-controllers-core:$gdxControllersVersion" api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" } }
我多次尝试重建项目,甚至切换到IntelliJ Idea,但项目始终无法构建(推测因Android Studio基于IntelliJ Idea开发)。
内容的提问来源于stack exchange,提问作者user21136295
相关产品推荐
相关产品推荐

