【问题标题】:NoClassDefFoundError - GameHelper Google GamesNoClassDefFoundError - GameHelper Google 游戏
【发布时间】:2014-05-07 13:24:55
【问题描述】:

使用 Eclipse IDE

关注:https://developers.google.com/games/services/android/quickstart

  1. 使用 google-play-services_lib 的副本(按照推荐)并作为 Eclipse 项目导入。
  2. 编辑游戏清单:

  3. 将我们的 APP ID 添加到 res/values/strings.xml

  4. 将 google-play-services_lib 与我们的游戏项目相关联,并在项目设置中的 Order 和 Export 选项卡中设置引用

  5. 按照https://developers.google.com/games/services/android/init使用BaseGameUtils项目,我们的Activity不能从该项目继承,因为已经有另一个类了。

  6. 因此,我们移至不继承的第二个方法(请参阅在没有 BaseGameActivity 的情况下使用 GameHelper)。我们为 BaseGameUtils 链接了 google-play-services_lib 并设置了库(编译成功)。

  7. 为我们的项目添加了链接,以便能够使用 GameHelper 以及 google-play-services_lib。

此时来自 Facebook 的 SDK 开始出现问题,因此我们不得不添加 android-support-v4.jar(BaseGameUtils 也使用)并在编译过程中出现错误:

Found 2 versions of android-support-v4.jar in the dependency list,
but not all the versions are identical (check is based on SHA-1 only at this time).
All versions of the libraries must be the same at this time.
Versions found are:
Path: /Users/travis/Work/Craneballs/Mafia_android/facebook-android-sdk/facebook/libs/android-support-v4.jar

路径:/Users/travis/Work/Craneballs/Mafia_android/BaseGameUtils/libs/android-support-v4.jar

  • 项目可以启动,但在 GoogleHelper = new GameHelper(this, GameHelper.CLIENT_ALL) 上崩溃 带有错误消息:java.lang.NoClassDefFoundError: com.google.example.games.basegameutils.GameHelper

我为此花费了许多痛苦的时间,现在已经不知所措了。有什么想法吗?

【问题讨论】:

    标签: android google-play-games


    【解决方案1】:

    我遇到了同样的问题。

    这是为我修复的the solution

    我遇到了同样的问题,我做了以下解决问题。

    1. 转到项目的“属性”。
    2. 选择“Java 构建路径”
    3. 选择“订购和导出”选项卡
    4. 您应该在此处看到所选项目的“src”和“gen”路径和依赖项。
    5. 他们列出的顺序是首先是“src”,然后是“gen”路径
    6. 我切换它们,以便在“src”之前构建“gen”文件夹

    gen - 项目中的自动化代码(来自依赖项和引用)

    src - 项目中的源代码

    无需重新启动 Eclipse。它刚刚开始工作。

    老实说,我从未尝试过“Android 工具 > 修复项目属性”,有时它可能会做同样的事情。我不知道,我只是在看到错误消息后做了上面的,认为构建路径有问题。

    可能有帮助的资源...

    NoClassDefFoundError for code in an Java library on Android

    Android app crashes after SDK-tools update version (NoClassDefFound, tool version 22)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-16
      • 1970-01-01
      • 1970-01-01
      • 2014-02-02
      相关资源
      最近更新 更多