【问题标题】:gradle error in building compile 'com.firebase:firebase-client-android:2.5.2+'构建编译时出现 gradle 错误 'com.firebase:firebase-client-android:2.5.2+'
【发布时间】:2016-04-18 11:05:48
【问题描述】:

错误:任务 ':app:transformClassesWithDexForDebug' 执行失败。

com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:处理'命令'/Library/Java/JavaVirtualMachines/jdk1。 8.0_77.jdk/Contents/Home/bin/java'' 以非零退出值 2 结束

我该怎么办? 我在库中没有多个 firebase-client 副本。它只存在于外部库中。

我的依赖:

 compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:design:23.2.1'
    compile 'com.android.support:support-v4:23.2.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.google.android.gms:play-services-maps:8.4.0'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.parse:parse-android:1.+'
    compile 'com.firebase:firebase-client-android:2.5.2+'

【问题讨论】:

  • 这种情况曾经发生在我身上,我的项目有很多外部库,我已经超过了 64k 的限制。我启用了multidex,配置了一个proguard文件并将minifyEnabled设置为true(用于调试和发布模式),然后问题就解决了。希望这也能解决您的问题。
  • 试试这个依赖依赖{ compile 'com.firebase:firebase-client-android:2.5.2' }
  • 去掉+号...重建你的项目
  • @ExceptionLover: 这是我的依赖项
  • pooja,我编辑答案并改进

标签: java android firebase


【解决方案1】:

只需删除 + 符号并清理并重建您的项目或尝试此依赖项and also check on stack overflow answer, com.android.build.transform.api.TransformException

   apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        //your application id here
        applicationId "yourapp.com.demoapps"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    dexOptions {

        javaMaxHeapSize "4g"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
     compile fileTree(include: ['*.jar'], dir: 'libs')
     testCompile 'junit:junit:4.12'
     compile 'com.android.support:appcompat-v7:23.2.1' 
     compile 'com.android.support:design:23.2.1'
     compile 'com.android.support:support-v4:23.2.1'
     compile 'com.google.android.gms:play-services:8.4.0'
     compile 'com.google.android.gms:play-services-maps:8.4.0'
     compile 'com.parse.bolts:bolts-android:1.4.0' 
     compile 'com.parse:parse-android:1.13.0' 
     compile 'com.firebase:firebase-client-android:2.5.2'
            }

【讨论】:

  • gradle 正在构建,当我评论这个 compile 'com.firebase:firebase-client-android:2.5.2' 但我想要 parse 和 firebase
  • 从尝试编译 'com.firebase:firebase-client-android:2.5.2' 中删除 + 号,有时服务器无法使用 + 号。所以依赖项不起作用..
  • 我删除了所有的 + 符号。还是一样
  • 非常感谢你,。它对我帮助很大:D 这样的救生员。
  • Multidex 是解决此问题的一个不好的解决方法。请看我的回答。
【解决方案2】:

您的问题是您包含的依赖项过多,超出了multidex limit

这一行...

compile 'com.google.android.gms:play-services:8.4.0'

如果你阅读this documentation,有一个注释

注意:如果您的应用中的方法引用数量超过 65K 限制,您的应用可能无法编译。在编译您的应用程序时,您可以通过仅指定您的应用程序使用的特定 Google Play 服务 API 而不是所有这些 API 来缓解此问题。有关如何执行此操作的信息,请参阅Selectively compiling APIs into your executable

您已经包含了 Google Maps API,那么您还需要更多的 Google 服务吗?如果是这样,请从该注释末尾的链接中选择这些服务并删除我上面提到的那一行。

【讨论】:

    【解决方案3】:

    可能是外部库未正确包含或尝试使用替代库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多