【问题标题】:Fabric plugin crash --> No such property: betaDistributionApkFilePath for class: org.codehaus.groovy.runtime.GStringImplFabric 插件崩溃 --> 没有这样的属性:betaDistributionApkFilePath 类:org.codehaus.groovy.runtime.GStringImpl
【发布时间】:2019-12-08 15:35:41
【问题描述】:

我无法在我的应用程序中配置 Crashlytics。 就在我应用结构插件 (plugin: 'io.fabric') 并构建时,我收到此错误。

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> groovy.lang.MissingPropertyException: No such property: betaDistributionApkFilePath for class: org.codehaus.groovy.runtime.GStringImpl

* 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

CONFIGURE FAILED in 4s
No such property: betaDistributionApkFilePath for class: org.codehaus.groovy.runtime.GStringImpl

我的 gradle 文件是:

build.gradle(项目级别)

buildscript {
    ext.kotlin_version = '1.3.41'
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.1.0'
        classpath 'io.fabric.tools:gradle:1.+'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }

    }
}

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

build.gradle(应用级别)

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

apply from: '../dependencies.gradle'

android {
    compileSdkVersion compileVersion
    buildToolsVersion = buildTools

    defaultConfig {
        applicationId appId
        minSdkVersion minVersion
        targetSdkVersion targetVersion
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        vectorDrawables {
            useSupportLibrary = true
        }

        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }

    signingConfigs {
        release {
            storeFile file(keyStoreFile)
            keyPassword releaseKeyPassword
            keyAlias releaseKeyAlias
            storePassword releaseStorePassword
        }
        debug {
            storeFile file('../extra/debug.jks')
            keyPassword 'android'
            storePassword 'android'
            keyAlias 'android'
        }
    }

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

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            multiDexEnabled true
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            resValue "string", "app_name", "@string/app_name_release"
            buildConfigField "String", "BASE_URL", '"https://www.mywebsite.com/api/"'
        }

        debug {
            minifyEnabled false
            debuggable true
            shrinkResources false
            multiDexEnabled true
            signingConfig signingConfigs.debug
            applicationIdSuffix '.debug'
            resValue "string", "app_name", "@string/app_name_debug"
            buildConfigField "String", "BASE_URL", '"https://staging.mywebsite.com/api/"'
        }
    }

    androidExtensions {
        experimental = true
    }
}

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

    testImplementation testDependencies.values()
    testImplementation androidTestDependencies.values()

    implementation kotlinDependencies.values()
    implementation androidSupportLibraries.values()
    implementation daggerDependencies.values()
    implementation androidArchDependencies.values()
    implementation rxJavaDependencies.values()
    implementation retrofitDependencies.values()
    implementation firebaseDependencies.values()
    implementation cookieJar
    implementation timber
    implementation crashlytics

    implementation glide
    api glideDependencies.values()
    kapt glideCompiler

    kapt daggerAnnotationProcessor.values()
    kapt roomAnnotationProcessor
}

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

dependencies.gradle(此处声明的所有依赖项)

ext {

    compileVersion = 28
    minVersion = 16
    targetVersion = 28
    buildTools = '28.0.3'

    appId = 'com.mywebsite.demo'

    def kotlinVersion = '1.3.41'
    def kotlinCoreVersion = '1.0.2'
    def daggerVersion = '2.17'
    def retrofitVersion = '2.4.0'
    def loggingInterceptorVersion = '3.10.0'
    def rxAndroidVersion = '2.1.1'
    def rxJavaVersion = '2.2.9'
    def testRunnerVersion = '1.1.1'
    def appCompatVersion = '1.0.2'
    def espressoCoreVersion = '3.1.1'
    def constraintLayoutVersion = '1.1.3'
    def lifecycleExtensionsVersion = '1.1.1'
    def cookieJarVersion = "v1.0.1"
    def roomVersion = "2.1.0-rc01"
    def roomRxVersion = "1.1.1"
    def roomAnnotationProcessorVersion = "2.0.0-rc01"
    def timberVersion = "4.6.1"
    def recyclerViewVersion = "1.0.0"
    def designSupportLibVersion = "1.1.0-alpha06"
    def glideVersion = "4.9.0"
    def glideTransformationVersion = "3.0.1"
    def firebaseAnalyticsVersion = "17.0.1"
    def firebaseConfigVersion = "18.0.0"
    def fcmVersion = "19.0.1"
    def crashlyticsVersion = "2.10.1"

    testDependencies = [
            "junit": "junit:junit:4.13-beta-3"
    ]

    androidTestDependencies = [
            "runner"      : "androidx.test:runner:$testRunnerVersion",
            "espressoCore": "androidx.test.espresso:espresso-core:$espressoCoreVersion"
    ]

    kotlinDependencies = [
            "kotlinStdLib": "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion",
            "kotlinCore"  : "androidx.core:core-ktx:$kotlinCoreVersion"
    ]

    androidSupportLibraries = [
            "appcompat"       : "androidx.appcompat:appcompat:$appCompatVersion",
            "constraintlayout": "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion",
            "recyclerview"    : "androidx.recyclerview:recyclerview:$recyclerViewVersion",
            "design"          : "com.google.android.material:material:$designSupportLibVersion",

    ]

    retrofitDependencies = [
            "retrofit"           : "com.squareup.retrofit2:retrofit:$retrofitVersion",
            "gson"               : "com.squareup.retrofit2:converter-gson:$retrofitVersion",
            "adapter-rxjava2"    : "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion",
            "logging-interceptor": "com.squareup.okhttp3:logging-interceptor:$loggingInterceptorVersion"
    ]

    rxJavaDependencies = [
            "rxandroid": "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion",
            "rxjava"   : "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
    ]

    androidArchDependencies = [
            "lifecycleExtensions": "android.arch.lifecycle:extensions:$lifecycleExtensionsVersion",
            "room"               : "androidx.room:room-runtime:$roomVersion",
            "roomRx"             : "android.arch.persistence.room:rxjava2:$roomRxVersion"
    ]

    daggerAnnotationProcessor = [
            "daggerCompiler": "com.google.dagger:dagger-compiler:$daggerVersion",
            "daggerAP"      : "com.google.dagger:dagger-android-processor:$daggerVersion"
    ]

    daggerDependencies = [
            "dagger"                : "com.google.dagger:dagger:$daggerVersion",
            "dagger-android"        : "com.google.dagger:dagger-android:$daggerVersion",
            "dagger-android-support": "com.google.dagger:dagger-android-support:$daggerVersion"
    ]

    glideDependencies = [
            "glideIntegration"        : "com.github.bumptech.glide:okhttp3-integration:$glideVersion",
            "glideAnnotationProcesser": "com.github.bumptech.glide:annotations:$glideVersion",
            "glideTransformation"     : "jp.wasabeef:glide-transformations:${glideTransformationVersion}",
    ]

    firebaseDependencies = [
            "firebaseAnalytics": "com.google.firebase:firebase-core:$firebaseAnalyticsVersion",
            "firebaseConfig"   : "com.google.firebase:firebase-config:$firebaseConfigVersion",
            "fcm"              : "com.google.firebase:firebase-messaging:${fcmVersion}"
    ]

    cookieJar = "com.github.franmontiel:PersistentCookieJar:$cookieJarVersion"
    roomAnnotationProcessor = "androidx.room:room-compiler:$roomAnnotationProcessorVersion"
    timber = "com.jakewharton.timber:timber:${timberVersion}"
    glide = "com.github.bumptech.glide:glide:${glideVersion}"
    glideCompiler = "com.github.bumptech.glide:compiler:${glideVersion}"
    crashlytics = "com.crashlytics.sdk.android:crashlytics:${crashlyticsVersion}"

}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.mywebsite.demo">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
            android:allowBackup="true"
            android:name=".App"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
        <activity android:name="com.mywebsite.demo.app.activity.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <service
                android:name=".managers.fcm.FcmMessageService"
                android:stopWithTask="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>

        <meta-data
                android:name="io.fabric.ApiKey"
                android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
    </application>

</manifest>

【问题讨论】:

    标签: android gradle crashlytics google-fabric crashlytics-android


    【解决方案1】:

    通过对如何在单独的 Gradle 文件中声明 Crashlytics 进行大量测试和试验,问题得到了解决。

    所做的更改是: dependencies.gradle

    Before
    
    ext {
        def crashlyticsVersion = "2.10.1"
        crashlytics = "com.crashlytics.sdk.android:crashlytics:${crashlyticsVersion}"
    }
    
    After
    
    ext {
        def crashlyticsVersion = "2.10.1"
        crashlyticsDependencies = [
                "crashlytics": "com.crashlytics.sdk.android:crashlytics:${crashlyticsVersion}"
        ]
    }
    

    build.gradle(应用级别)

    Before
    
    dependencies {
        implementation crashlytics
    }
    
    After
    
    dependencies {
        implementation crashlyticsDependencies.values()
    }
    
    

    仍然不确定为什么 crashlytics 只强制使用这种类型的声明。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-31
      • 2016-08-28
      • 1970-01-01
      • 1970-01-01
      • 2019-02-10
      • 2022-08-03
      • 2014-07-14
      • 1970-01-01
      相关资源
      最近更新 更多