简体   繁体   English

JetPack Jetifier的Android Crashlytics问题

[英]Android Crashlytics issue with JetPack Jetifier

Well I created a project and added the Fabric plugin and Crashlytics dependency and I also tested it and it worked. 好吧,我创建了一个项目,并添加了Fabric插件和Crashlytics依赖项,并且我也对其进行了测试并奏效。 But when I refactor the project to use AndroidX and enable the jetifier tool android.enableJetifier=true the project wont build and I get multiple errors like: 但是当我重构项目以使用AndroidX并启用jetifier工具android.enableJetifier=true该项目将无法构建,并且出现多个错误,例如:

Failed to transform file 'crashlytics-2.9.2.aar' to match attributes {artifactType=jetified-aar} using transform JetifyTransform

It seems there is something wrong with jetifier tool and the Crashlytics dependency. 似乎jetifier工具和Crashlytics依赖项有问题。 Is there a way to turn off the JetifyTransform for a single dependency? 有没有办法为单个依赖项关闭JetifyTransform

Project level gradle file: 项目级gradle文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.2.41'
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0-alpha14'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:3.1.2'
        classpath 'io.fabric.tools:gradle:1.25.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

Module level gradle file: 模块级gradle文件:

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

android {
    compileSdkVersion 'android-P'
    defaultConfig {
        applicationId "ir.scannpay.person"
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-alpha1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha1'

    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.2'
}

gradle.properties file: gradle.properties文件:

android.enableJetifier=true
android.useAndroidX=true

And I didn't forget to put the Fabric key in the manifest , I also put the google-services.json file in app module. 而且我没有忘记将Fabric密钥放入manifest ,也将google-services.json文件放入了app模块中。

When I try to build, I get multiple of these errors: 当我尝试构建时,出现以下多个错误:

Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform file 'crashlytics-2.9.2.aar' to match attributes {artifactType=jetified-aar} using transform JetifyTransform

Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform file 'crashlytics-core-2.6.2.aar' to match attributes {artifactType=jetified-aar} using transform JetifyTransform

Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform file 'beta-1.2.7.aar' to match attributes {artifactType=jetified-aar} using transform JetifyTransform

Well I found the solution. 好吧,我找到了解决方案。

What you need to do is to upgrade your fabric version to 1.25.4 in your project level build.gradle file: 您需要做的是在项目级别的build.gradle文件1.25.4结构版本升级到1.25.4

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:3.2.0'
        classpath 'io.fabric.tools:gradle:1.25.4'
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM