首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >分级安卓-谷歌服务3.2.0 [错误] [com.android.build.gradle.internal.transforms.DesugarTransform]

分级安卓-谷歌服务3.2.0 [错误] [com.android.build.gradle.internal.transforms.DesugarTransform]
EN

Stack Overflow用户
提问于 2018-05-05 03:07:30
回答 1查看 877关注 0票数 1

我已经将google服务插件降级为3.2.0,这样我的构建才能正常工作,3.3.0就坏了。

但是,当我运行gradle构建时,会得到以下错误堆栈跟踪:

com.google.common.base.Preconditions.checkArgument(Preconditions.java:108)、com.google.devtools.build.android.desugar.DefaultMethodClassFixer$DefaultMethodFinder.visit(DefaultMethodClassFixer.java:483)、org.objectweb.asm.ClassReader.accept(ClassReader.java:621)、org.objectweb.asm.ClassReader.accept(ClassReader.java:500)、com.google.devtools.build.android.desugar.DefaultMethodClassFixer.defaultMethodsDefined(DefaultMethodClassFixer.java:331线程“主”java.lang.IllegalArgumentException中的错误异常)在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)

让我向您展示我的分级项目细节:

代码语言:javascript
复制
    buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
        google()
    }
    //kotlin version
    ext.kotlin_version = '1.2.41'
    ext.kotlin_ktx_version = '0.3'

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:3.2.0'
        classpath 'io.fabric.tools:gradle:1.25.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}


allprojects {
    repositories {
        jcenter()
        mavenCentral()

        maven { url "http://dl.bintray.com/pt-midtrans/maven" }

        maven { url "https://jitpack.io" }

        google()
    }



    project.ext {

        minimumSdkVersion = 16

        supportlib_version = '27.1.1'

        room_version = '1.0.0'

        espresso_version = '3.0.1'

        archLifecycleVersion = '1.1.1'

        dagger = '2.15'
    }

}

subprojects {
    //todo change this to loop once
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex')) {
                details.useVersion "$supportlib_version" //force all versions of support library to be the same. i tried commending out this entire block but that is not the issue
            }
    }
}


task clean(type: Delete) {
    delete rootProject.buildDir
}

下面是我的模块gradle文件(我只有一个模块应用程序,只有app):

代码语言:javascript
复制
    buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        google()
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'

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

android {
    compileSdkVersion 27
    //buildToolsVersion '27.0.3'
    defaultConfig {
        minSdkVersion project.ext.minimumSdkVersion
        //check top level build.gradle  file for attributes -
        targetSdkVersion 27
        applicationId "com.mobile.mypackage"
        versionCode 1
        versionName "3" //whatever


        testInstrumentationRunner "com.mobile.mypackage.base.MyTestRunner"
        multiDexEnabled true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    flavorDimensions 'tier'

    buildTypes {
        release {
            debuggable false //for troubleshooting, should set to false in production build
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'proguard-fresco.pro', 'proguard-gson.pro', 'proguard-midtrans.pro'
        }

        debugMini {
            //this is a proguarded version of debug build, turn off - InstaRun to use
            initWith debug
            minifyEnabled true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'proguard-fresco.pro', 'proguard-gson.pro', 'proguard-midtrans.pro'
            matchingFallbacks = ['debug']
        }
    }

    dexOptions {
        //for out of memory gc overhead error
        javaMaxHeapSize "6g"
    }
    lintOptions {
        abortOnError false
    }

    androidExtensions {
        experimental = true
    }
    testOptions {
        //this seems to be absolutely nothing in build tools 25.0.3. after upgrading gradle will check again
        animationsDisabled = true
        execution 'ANDROID_TEST_ORCHESTRATOR'
    }

    productFlavors {

        def STRING = "String"
        def BOOLEAN = "boolean"
        def TRUE = "true"
        def FALSE = "false"
        def BASE_ENDPOINT = "BASE_ENDPOINT"


        staging {
            dimension 'tier'
      buildConfigField STRING, BASE_ENDPOINT, '"https://api.myendpoint.com"'
      versionNameSuffix '-STAGING'
            applicationIdSuffix 'staging'
        }

        labs {
            dimension 'tier'
            ext.alwaysUpdateBuildId = false

              buildConfigField STRING, BASE_ENDPOINT, '"https://api.myendpoint.com"'
              versionNameSuffix '-LABs'
            applicationIdSuffix 'labs'
        }

        prod {
            dimension 'tier'
            buildConfigField STRING, BASE_ENDPOINT, '"https://api.myendpoint.com"'
          }
    }
}

kapt {
    useBuildCache = false //toggle this to see if it will help
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation("com.android.support:appcompat-v7:$supportlib_version") {
    force = true
}
implementation 'com.android.support.constraint:constraint-layout:1.1.0'

implementation "com.android.support:support-annotations:$supportlib_version"
implementation("com.android.support:design:$supportlib_version") {
    force = true
}

implementation 'com.android.support:multidex:1.0.3'

//firebase
implementation("com.google.firebase:firebase-auth:15.1.0") {
    //force = true
}
implementation("com.google.firebase:firebase-core:15.0.2") {
   // force = true
}

implementation("com.google.firebase:firebase-config:15.0.2") {
  //  force = true
}
implementation("com.google.android.gms:play-services-auth:15.0.0") {
  //  force = true
}
implementation("com.google.firebase:firebase-messaging:15.0.2") {
  //  force = true
}

//rxjava
implementation 'io.reactivex.rxjava2:rxjava:2.1.6'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.0.0'

//square
implementation 'com.google.dagger:dagger:2.12'
kapt "com.google.dagger:dagger-compiler:2.12"
implementation 'com.github.ajalt:timberkt:1.3.0'
implementation 'com.jakewharton:butterknife:8.8.1'
kapt 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation "com.squareup.retrofit2:retrofit:2.3.0"
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation "com.squareup.retrofit2:converter-gson:2.3.0"
androidTestImplementation 'com.squareup.rx.idler:rx2-idler:0.9.0' //for espresso

//mosby //some bug in mosby3 and dagger2 preventing me from updating still. i opened a bug with mosby:  https://github.com/sockeqwe/mosby/issues/298
implementation 'com.hannesdorfmann.mosby:viewstate:2.0.1'

//------Architecture Components ------------

//room db
implementation "android.arch.persistence.room:runtime:$room_version"

implementation "android.arch.lifecycle:common-java8:1.1.1"
kapt "android.arch.persistence.room:compiler:$room_version"
implementation "android.arch.persistence.room:rxjava2:$room_version"

// Lifecycles only (no ViewModel or LiveData)
implementation "android.arch.lifecycle:runtime:$archLifecycleVersion"

kapt "android.arch.lifecycle:compiler:$archLifecycleVersion"
implementation "android.arch.lifecycle:extensions:$archLifecycleVersion"

//------END Architecture Components ------------

//event Bus
implementation 'org.greenrobot:eventbus:3.0.0'

//FB
implementation 'com.facebook.android:facebook-android-sdk:4.32.0'
//implementation 'com.facebook.android:facebook-applinks:[4,5)'
implementation 'com.facebook.fresco:fresco:1.3.0'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'

//testing
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
testImplementation 'org.mockito:mockito-core:2.15.0'
androidTestImplementation 'org.mockito:mockito-android:2.8.9'
androidTestImplementation 'com.github.fabioCollini:DaggerMock:0.8.4'
implementation 'com.squareup.okhttp3:mockwebserver:3.8.0'
testImplementation 'junit:junit:4.12'


androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test:rules:1.0.1'

// Espresso dependencies
androidTestImplementation "com.android.support.test.espresso:espresso-core:$espresso_version"
androidTestImplementation "com.android.support.test.espresso:espresso-contrib:$espresso_version"
androidTestImplementation "com.android.support.test.espresso:espresso-intents:$espresso_version"
// androidTestImplementation 'com.android.support.test.espresso:espresso-accessibility:3.0.1'
androidTestImplementation "com.android.support.test.espresso:espresso-web:$espresso_version"
androidTestImplementation "com.android.support.test.espresso.idling:idling-concurrent:$espresso_version"
androidTestImplementation "com.android.support.test.espresso:espresso-idling-resource:$espresso_version"

//UI dependencies
implementation 'com.andreabaccega:android-edittext-validator:1.3.4'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation "com.imgix:imgix-java:1.1.10"
implementation 'com.github.markomilos:paginate:0.5.1'
implementation 'com.sprylab.android.texturevideoview:texturevideoview:1.2.1'
implementation 'com.balysv:material-ripple:1.0.2'
implementation 'com.github.d-max:spots-dialog:0.7@aar' //loading screen
implementation 'com.jaredrummler:material-spinner:1.1.0'//drop down list
implementation 'com.github.ganfra:material-spinner:1.1.1'//drop down list
implementation 'com.bartoszlipinski:recyclerviewheader2:2.0.1'
//implementation 'com.github.takusemba:multisnaprecyclerview:1.1.1' //snap
implementation 'com.crystal:crystalrangeseekbar:1.1.1'
implementation 'com.github.faruktoptas:FancyShowCaseView:1.0.0'

//data structures
implementation 'com.scalified:tree:0.2.4'

//parcelable
implementation 'org.parceler:parceler-api:1.1.9'
kapt 'org.parceler:parceler:1.1.9'
//payment gateways
//implementation 'co.omise:omise-android:2.3.+'
implementation 'co.omise:omise-android:2.6.4'
implementation 'com.braintreepayments.api:braintree:1.+'
debugImplementation 'com.midtrans:uikit:1.17.0-SANDBOX'
debugMiniImplementation 'com.midtrans:uikit:1.17.0-SANDBOX'
releaseImplementation 'com.midtrans:uikit:1.17.0'

//fresh chat
implementation 'com.github.freshdesk:freshchat-android:1.3.1'

implementation('com.crashlytics.sdk.android:crashlytics:2.9.0@aar') {
    transitive = true

    //one signal
    implementation 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'

    //retrofit pretty logs
    implementation('com.github.ihsanbal:LoggingInterceptor:2.0.2') {
        exclude group: 'org.json', module: 'json'
    }

    //barcode scanner
    implementation 'com.journeyapps:zxing-android-embedded:3.5.0'

    //masking text
    implementation 'com.redmadrobot:inputmask:2.3.0'

    // Analytics
    implementation "com.google.android.gms:play-services-analytics:15.0.0"
    implementation 'com.appsflyer:af-android-sdk:4+@aar'
    implementation 'com.android.installreferrer:installreferrer:1.0'

    //runtime permissions
    implementation 'com.karumi:dexter:4.2.0'

    //chrome custom tabs
    implementation 'saschpe.android:customtabs:1.0.9'

    //searching
    implementation 'com.algolia:algoliasearch-android:3.+'

    //credit card scanner
    implementation 'io.card:android-sdk:5.5.1'

    //firebase test orchestrator
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestUtil 'com.android.support.test:orchestrator:1.0.1'

    //kotlin
    //implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    //implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    //kotlin ktx
    implementation "androidx.core:core-ktx:$kotlin_ktx_version"

    }

apply plugin: 'com.google.gms.google-services' //add to bottom of file

我尝试在gradle-属性中添加以下boolaen,但是它没有帮助:android.enableD8.desugling= true

我是。使用gradle包装4.4,但也尝试了4.6。实例化运行已关闭。并关闭按需配置。但我也试过了。我切换了D8编译器,但这并没有帮助。

您认为这与Java运行时环境有关吗?我看到以下摘要错误:

代码语言:javascript
复制
Process 'command '/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

我的理解是,在gradle中,我可以使用implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version",而它将使用找出要使用的包版本

EN

回答 1

Stack Overflow用户

发布于 2018-05-05 11:55:00

消除对oneSignal sdk的依赖解决了此问题:

从build.gradle中删除这一行:

代码语言:javascript
复制
 implementation 'com.onesignal:OneSignal:3.8.4'

如果我将以下内容从gradle中删除,上面的依赖关系似乎会起作用:

代码语言:javascript
复制
 compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

更新:我现在不必删除java 8的特性。我发现,如果我强制所有依赖项都是firebase 12.0.1,那么所有这些都能工作。下面是我在顶级gradle文件中的解决策略:

代码语言:javascript
复制
    subprojects {
    //todo change this to loop once
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
          if (details.requested.group == 'com.google.android.gms' ||
                    details.requested.group == 'com.google.firebase') {
                details.useVersion(firebase_resolution_version)//firebase_resolution_version being 12.0.1
            }
        }
    }
}

然后进入您的build.gradle应用程序文件,将com.google.android.gms*和com.google.Firebase的所有依赖项更改为12.0.1。

确保您还使用了'com.google.gms:google-services:3.2.1'类路径

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50185312

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档