gdx pay desktop no class 定义错误

Gdx pay desktop no class defined error

我正在使用 libgdx 支付 Android 和 iOS,并且直到最近才能够在桌面模式下测试我的应用程序。

自升级到 IntelliJ 2016.1 后,我现在仅在尝试 运行 桌面应用程序时收到以下错误; iOS 和 Android 都继续编译并且 运行 成功。

错误:

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NoClassDefFoundError: com/badlogic/gdx/pay/PurchaseObserver

我的 build.gradle 桌面和核心模块文件如下所示;

allprojects {
  apply plugin: "eclipse"
  apply plugin: "idea"

  version = '1.0'
  ext {
      appName = '####'
      gdxVersion = '1.9.2'
      roboVMVersion = '1.8.0'
      box2DLightsVersion = '1.4'
      ashleyVersion = '1.4.0'
      aiVersion = '1.5.0'
      gdxpayVersion = '0.6.0'
  }

  repositories {
      mavenCentral()
      maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
      maven { url "https://oss.sonatype.org/content/repositories/releases/" }
  }
}

project(":core") {
  apply plugin: "java"


  dependencies {
      compile "com.badlogicgames.gdx:gdx:$gdxVersion"
      compile "de.tomgrill.gdxtwitter:gdx-twitter-core:0.1.0-SNAPSHOT"

      compile "com.badlogicgames.gdxpay:gdx-pay:$gdxpayVersion"
      compile "com.badlogicgames.gdxpay:gdx-pay-client:$gdxpayVersion"
  }
}

project(":desktop") {
  apply plugin: "java"


  dependencies {
    compile project(":core")

    compile "de.tomgrill.gdxtwitter:gdx-twitter-desktop:0.1.0-SNAPSHOT"

    compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
    compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
  }
}

此外,在 IntelliJ 中,它没有报告能够导入 PurchaseObserver 的错误,它仅在我尝试 运行 应用程序时发生。

如有任何帮助,我们将不胜感激。

这是IntelliJ本身的一个已知bug,这里总结一下http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=21148&hilit=intellij

可以在此处找到 IntelliJ 问题的错误 https://youtrack.jetbrains.com/issue/IDEA-147788

仅当还有 Android 运行 配置时才会出现错误。

在修复之前,解决方法是通过命令行使用 gradle,如下所示;

gradle ProjectName:desktop run

这也可以作为 IntelliJ 中的 运行 配置来实现。