【问题标题】:google gms:play service conflict with firebase谷歌 gms:play 服务与 firebase 冲突
【发布时间】:2017-06-20 10:46:41
【问题描述】:

我正在尝试在我已经使用谷歌地图的项目中添加 firebase-messaging。所以当我添加 firebase 依赖时

compile 'com.google.firebase:firebase-messaging:10.0.1'

我收到以下错误。

错误:.dex 文件中的方法引用数不能超过 64K。 在https://developer.android.com/tools/building/multidex.html 了解如何解决此问题 错误:任务“:app:transformClassesWithDexForDebug”执行失败。 com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException

我该如何解决这个问题 这是我的 build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "com.edesign.astutesol.sallaticustomerapp"
    minSdkVersion 19
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.1.1'
compile 'com.mcxiaoke.volley:library:1.0.15'
compile 'com.github.lecho:hellocharts-library:1.5.8@aar'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.android.gms:play-services-auth:10.0.1'
apply plugin: 'com.google.gms.google-services'
compile 'com.google.firebase:firebase-messaging:10.0.1'

compile 'com.android.support:cardview-v7:25.+'
compile 'org.lucasr.twowayview:twowayview:0.1.4'

}

这些是谷歌依赖项

compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.android.gms:play-services-auth:10.0.1'
apply plugin: 'com.google.gms.google-services'
compile 'com.google.firebase:firebase-messaging:10.0.1'

【问题讨论】:

  • 嗨。你有没有看到像one这样讨论错误的帖子?
  • @AL。是的,我尝试了 multiDexEnabled,但它也没有帮助。
  • 如果不需要compile 'com.google.android.gms:play-services:10.0.1',请删除此依赖项。因为,它有 79958 个方法计数。
  • 我需要这个来制作地图。我在我的应用程序中使用 latlong。
  • 那你需要用这个.... compile 'com.google.android.gms:play-services-maps:10.0.1'

标签: android google-maps android-studio firebase firebase-cloud-messaging


【解决方案1】:

在您的默认配置中启用 multidex。

defaultConfig {
    applicationId "com.edesign.astutesol.sallaticustomerapp"
    minSdkVersion 19
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}

【讨论】:

  • 我尝试了 multiDexEnabled 但并没有解决问题
【解决方案2】:

如果启用 multidex 支持对您不起作用,可能是因为您可能已经为您的应用定义了自定义应用程序类。清单文件中的应用程序名称是什么?如果您通过扩展 Application 定义了自定义应用程序类(例如集成 ACRA 或谷歌分析),那么您将必须覆盖 attachBaseContext 方法。

@Override
    protected void attachBaseContext(Context context) {
        super.attachBaseContext(context);
        MultiDex.install(this);
    }

【讨论】:

    【解决方案3】:

    简短回答:删除compile 'com.google.android.gms:play-services:10.0.1'


    您的 build.gradle

    中不应包含以下行
    compile 'com.google.android.gms:play-services:10.0.1'
    

    该行将包含您应用程序中的所有 google 库,这将超出方法限制(您报告的错误),并且会使您的应用程序变大而没有任何好处。

    您应该只包含您需要的子库。

    例子:

    compile 'com.google.android.gms:play-services-auth:10.0.1
    

    没问题,因为您只包含库的 -auth 部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-15
      • 2019-04-17
      • 2018-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多