java.lang.NoClassDefFoundError:libgdx中的kotlin/jvm/internal/Intrinsics
在我的libgdx gradle应用程序中,我有一类GroundHandler:java.lang.NoClassDefFoundError:libgdx中的kotlin/jvm/internal/Intrinsics,java,gradle,libgdx,kotlin,build.gradle,Java,Gradle,Libgdx,Kotlin,Build.gradle,在我的libgdx gradle应用程序中,我有一类GroundHandler: package com.mygdx.physics import com.badlogic.gdx.ApplicationAdapter import com.badlogic.gdx.Gdx import com.badlogic.gdx.math.Vector2 import com.badlogic.gdx.physics.box2d.Fixture import com.badlogic.gdx.phy
package com.mygdx.physics
import com.badlogic.gdx.ApplicationAdapter
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.math.Vector2
import com.badlogic.gdx.physics.box2d.Fixture
import com.badlogic.gdx.physics.box2d.Body
import com.badlogic.gdx.physics.box2d.BodyDef
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.physics.box2d.PolygonShape
import com.badlogic.gdx.physics.box2d.World
class GroundHandler(val world: World, val camera: OrthographicCamera) {
private var groundBodyDef: BodyDef = BodyDef()
private var groundBox: PolygonShape = PolygonShape()
private var groundBody: Body? = null
fun createGround() {
groundBodyDef.position.set(Vector2(0f, 10f))
groundBody = world.createBody(groundBodyDef)
groundBox.setAsBox(camera.viewportWidth, 10.0f)
groundBody?.createFixture(groundBox, 0.0f)
groundBox.dispose()
}
}
在另一个类中使用。起初它编译得很好,但当应用程序窗口启动时,我得到了
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:133)
Caused by: java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
at com.mygdx.physics.GroundHandler.<init>(GroundHandler.kt)
at com.mygdx.physics.Physics.createGround(Physics.kt:60)
at com.mygdx.physics.Physics.create(Physics.kt:31)
我所做的只是两次将“java”更改为“kotlin”,并将kotlin依赖项添加到buildscript{}只需添加jar{}节indo desktop.gradle,如下所示:
apply plugin: "kotlin"
sourceCompatibility = 1.6
sourceSets.main.java.srcDirs = [ "src/" ]
project.ext.mainClassName = "com.your.class.name"
project.ext.assetsDir = new File("../android/assets");
jar {
manifest {}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
这对你有帮助吗?
apply plugin: "kotlin"
sourceCompatibility = 1.6
sourceSets.main.java.srcDirs = [ "src/" ]
project.ext.mainClassName = "com.your.class.name"
project.ext.assetsDir = new File("../android/assets");
jar {
manifest {}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}