尝试构建我的项目时,将 gms/firebase 升级到版本 15.0.0 会导致 gradle 崩溃? [复制]

Posted

技术标签:

【中文标题】尝试构建我的项目时,将 gms/firebase 升级到版本 15.0.0 会导致 gradle 崩溃? [复制]【英文标题】:Upgrading gms/firebase to version 15.0.0 making gradle crash when trying to build my project? [duplicate] 【发布时间】:2018-10-13 16:39:12 【问题描述】:

我正在尝试更新我的项目以使用版本 15.+ 的 gms/firebase 但是在尝试构建项目时遇到以下问题

    :app:transformClassesWithDesugarForDebug
Exception in thread "main" java.lang.IllegalArgumentException
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:108)
    at com.google.devtools.build.android.desugar.DefaultMethodClassFixer$DefaultMethodFinder.visit(DefaultMethodClassFixer.java:483)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:621)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
    at com.google.devtools.build.android.desugar.DefaultMethodClassFixer.defaultMethodsDefined(DefaultMethodClassFixer.java:331)
    at com.google.devtools.build.android.desugar.DefaultMethodClassFixer.visitEnd(DefaultMethodClassFixer.java:91)
    at org.objectweb.asm.ClassVisitor.visitEnd(ClassVisitor.java:339)
    at com.google.devtools.build.android.desugar.InterfaceDesugaring.visitEnd(InterfaceDesugaring.java:112)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:702)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
    at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:477)
    at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:361)
    at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:314)
    at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:711)

Exception in thread "main" java.lang.IllegalArgumentException
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:108)
    at com.google.devtools.build.android.desugar.DefaultMethodClassFixer$DefaultMethodFinder.visit(DefaultMethodClassFixer.java:483)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:621)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
    at com.google.devtools.build.android.desugar.DefaultMethodClassFixer.defaultMethodsDefined(DefaultMethodClassFixer.java:331)
    at com.google.devtools.build.android.desugar.DefaultMethodClassFixer.visitEnd(DefaultMethodClassFixer.java:91)
    at org.objectweb.asm.ClassVisitor.visitEnd(ClassVisitor.java:339)
    at com.google.devtools.build.android.desugar.InterfaceDesugaring.visitEnd(InterfaceDesugaring.java:112)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:702)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
    at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:477)
    at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:361)
    at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:314)
    at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:711)


 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDesugarForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.google.devtools.build.android.desugar.Desugar 

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 42s

当我使用 11.8.0 时,gradle 构建并没有出现任何问题

这是应用程序的 gradle 代码

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android 
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig 
    applicationId ""
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
    "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true


buildTypes 
    release 
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
        'proguard-rules.pro'
    


dexOptions 
    javaMaxHeapSize "4g"


signingConfigs 
    debug 
        keyAlias 'androidDebugKey'
        keyPassword 'android'
        storeFile file('/Users/nerdy/.android/debug.keystore')
        storePassword('android')
    


compileOptions 
    sourceCompatibility 1.8
    targetCompatibility 1.8



repositories 
maven  url 'https://maven.fabric.io/public' 


dependencies 
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso- 
core:2.2.2', 
    exclude group: 'com.android.support', module: 'support-annotations'
)

implementation project(':domain')
implementation project(':data')
implementation project(path: ':chat-sdk-audio-message')
implementation project(path: ':chat-sdk-video-message')
implementation project(path: ':chat-sdk-contact-book')

api 'com.android.support:appcompat-v7:27.1.1'
api 'com.android.support:cardview-v7:27.1.1'
api 'com.android.support:design:27.1.1'
api 'com.android.support:support-v4:27.1.1'
api 'com.android.support.constraint:constraint-layout:1.1.0'

api 'com.firebaseui:firebase-ui-storage:0.6.0'
api 'com.google.firebase:firebase-crash:15.0.2'
api 'com.google.firebase:firebase-auth:15.1.0'
api 'com.google.firebase:firebase-core:15.0.2'
api 'com.google.firebase:firebase-database:15.0.1'
api 'com.google.firebase:firebase-firestore:16.0.0'
api 'com.google.firebase:firebase-messaging:15.0.2'
api 'com.google.firebase:firebase-storage:15.0.2'

api 'com.google.android.gms:play-services-location:15.0.1'
api 'com.google.android.gms:play-services-maps:15.0.1'
api 'com.google.android.gms:play-services-places:15.0.1'

api 'com.jakewharton:butterknife:8.5.1'
api 'com.ncapdevi:frag-nav:1.4.0'
api 'io.reactivex.rxjava2:rxandroid:2.0.1'
api 'io.reactivex.rxjava2:rxjava:2.1.7'
api 'com.android.support:multidex:1.0.3'
api 'com.crystal:crystalrangeseekbar:1.1.3'
api 'joda-time:joda-time:2.9.9'
api 'id.zelory:compressor:2.1.0'
api 'com.airbnb.android:lottie:2.1.2'
api 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
api 'com.facebook.android:facebook-share:4.32.0'
api 'com.facebook.android:facebook-applinks:4.32.0'
api 'com.crashlytics.sdk.android:crashlytics:2.9.2'

api 'co.chatsdk.chatsdk:chat-sdk-core:' + project.CHAT_SDK_VERSION
api 'co.chatsdk.chatsdk:chat-sdk-ui:' + project.CHAT_SDK_VERSION
api 'co.chatsdk.chatsdk:chat-sdk-firebase-adapter:' + 
project.CHAT_SDK_VERSION
api 'co.chatsdk.chatsdk:chat-sdk-firebase-file-storage:' + 
project.CHAT_SDK_VERSION
api 'co.chatsdk.chatsdk:chat-sdk-firebase-push:' + 
project.CHAT_SDK_VERSION


configurations.all 
resolutionStrategy.eachDependency   details ->
    def requested = details.requested
    if (requested.group == 'com.android.support') 
        if (!requested.name.startsWith("multidex")) 
            details.useVersion '27.+'
        
    



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

这里是项目的gradle

buildscript 
repositories 
    jcenter()
    mavenCentral()
    google()
    maven  url 'https://maven.fabric.io/public' 

dependencies 
    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath 'com.google.gms:google-services:3.3.0'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
    classpath 'io.fabric.tools:gradle:1.25.2'



allprojects 
repositories 
    jcenter()
        maven  url "https://maven.google.com" 
        maven  url "http://dl.bintray.com/chat-sdk/chat-sdk-android" 
        maven  url "https://jitpack.io" 

    google()



task clean(type: Delete) 
delete rootProject.buildDir

我也尝试过使用不同版本的 gradle 包装器,4.4、4.7 等版本...

【问题讨论】:

查看此链接***.com/a/45835332/9502230 你可以使用12.0.1 解决方法请参考***.com/a/50149536/5740236 【参考方案1】:

这是因为firebase更新而发生的,我通过这个解决了

implementation 'com.google.firebase:firebase-database:15.0.0'
implementation 'com.google.firebase:firebase-storage:15.0.2'
implementation 'com.google.firebase:firebase-auth:15.1.0'
implementation 'com.google.firebase:firebase-messaging:15.0.2'

在这里检查一次:- https://firebase.google.com/support/release-notes/android

【讨论】:

即使使用特定的版本号,仍然会出现相同的错误 @Sci 你能发布你的gradle 代码吗!

以上是关于尝试构建我的项目时,将 gms/firebase 升级到版本 15.0.0 会导致 gradle 崩溃? [复制]的主要内容,如果未能解决你的问题,请参考以下文章

Android Gradle:所有 gms/firebase 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)

当我将设备连接到 xcode 并尝试构建我的项目时,它会产生错误

尝试为 iOS 运行或构建 Flutter 项目时出错

当我尝试构建我的项目时,Unity 给出了奇怪的错误

为 iOS 编译 Flutter 项目时的 Xcode 构建问题

构建 Angular 项目导致内存不足