【问题标题】:Mixing Google Play games with Firebase将 Google Play 游戏与 Firebase 混合使用
【发布时间】:2017-05-20 08:28:05
【问题描述】:

我使用 google games api 在我的 android 游戏中添加了排行榜。现在我想使用 Android Studio 的 Firebase 'Wizard' 添加横幅广告。它构建良好,但是当我尝试创建 apk 时,出现以下错误:

错误:将字节码转换为 dex 时出错: 原因:com.android.dex.DexException: 多个dex文件定义Lcom/google/android/gms/internal/zzqv;

使用向导后,我的 build.gradle 文件如下所示:

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 22
        buildToolsVersion "22.0.1"
        defaultConfig {
        applicationId "xxx"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
     buildTypes {
         release {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
         }
     }
  }

  dependencies {

       compile fileTree(dir: 'libs', include: ['*.jar'])


       compile project(':BaseGameUtils')

       androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',     {
    exclude group: 'com.android.support', module: 'support-annotations'
})

      compile 'com.google.android.gms:play-services-games:10.0.1'
      compile 'com.google.firebase:firebase-ads:10.0.1'

      testCompile 'junit:junit:4.12'
   }


   apply plugin: 'com.google.gms.google-services'

我尝试/阅读了与多个 dex 文件问题相关的所有内容,但对我没有任何帮助。有人对我有提示吗?我是否也必须将 Firebase 用于排行榜?没找到怎么...

感谢任何帮助/提示 彼得森

【问题讨论】:

  • 我无法使用类似的 build.gradle 文件重现该问题。请发布您的顶级(项目)build.gradle。另外,您是否尝试过“清理”您的项目?
  • 检查 BaseGameUtils 的 gradle 文件 - 我猜你有多个版本的 play-services-* 被包括在内。 BaseGameUtils 的价值不再有限,您可能只想将其中的几个静态方法直接复制到您的项目中。

标签: android firebase admob google-play-services google-play-games


【解决方案1】:

感谢 Clayton Wilkinson 的评论,我可以解决我的问题。 问题是 BaseGameUtils 仍在使用/引用旧版本的游戏服务。添加了正确的版本,现在可以使用了。我想我会在下一个项目中省略 BaseGameUtils。

非常感谢

【讨论】:

    【解决方案2】:

    当然,有一些冲突...但是,问题是,如果您笼统地说,我的意思是,您使用 compile 'com.google.android.gms:play-services:XXX',就完成了.

    【讨论】:

      【解决方案3】:

      我有同样的错误,只是启用 proguard 工作(将 false 更改为 true):

      buildTypes {
          release {
              minifyEnabled true //Here change false to true
              proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
          }
      }
      

      【讨论】:

        猜你喜欢
        • 2017-02-10
        • 2016-07-14
        • 2013-06-16
        • 1970-01-01
        • 2018-02-09
        • 2019-10-30
        • 1970-01-01
        • 1970-01-01
        • 2014-02-02
        相关资源
        最近更新 更多