1

好吧,我创建了一个项目并添加了Fabric插件和Crashlytics依赖项,我还对其进行了测试并且它工作正常。但是,当我重构项目以使用AndroidX并启用 jetifier 工具android.enableJetifier=true时,项目将无法构建,并且出现多个错误,例如:

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

jetifier工具和Crashlytics依赖项似乎有问题。有没有办法关闭JetifyTransform单个依赖项?

项目级 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
}

模块级 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 文件:

android.enableJetifier=true
android.useAndroidX=true

而且我没有忘记将Fabric密钥放入manifest,我还将google-services.json文件放入app模块中。

当我尝试构建时,我收到多个以下错误:

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
4

1 回答 1

5

好吧,我找到了解决方案。

您需要做的是将您的结构版本升级到1.25.4项目级别build.gradle文件中:

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:3.2.0'
        classpath 'io.fabric.tools:gradle:1.25.4'
    }
}
于 2018-05-15T07:08:09.777 回答