android - 集成 Firebase Crashlytics 后生成签名 APK 时出错

标签 android gradle crashlytics

我已经按照官方文档整合了 firebase crashlytis。 https://firebase.google.com/docs/crashlytics/get-started

它在调试构建时工作正常,我也在控制台中遇到崩溃,但在生成签名的 APK 时遇到错误。

Warning:com.twitter.sdk.android.core.internal.scribe.ScribeFilesSender$ConfigRequestInterceptor: can't find referenced method 'java.lang.String getDeviceUUID()' in program class io.fabric.sdk.android.services.common.IdManager
Information:See complete output in console
Warning:there were 1 unresolved references to program class members.
Information:3 warnings
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForLivedemoRelease'.
> Job failed, see logs for details
Information:1 error
Information:BUILD FAILED in 10s
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.

应用级build.gradle

apply plugin: 'com.android.application'


android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    defaultConfig {
       ----
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 5885
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        buildConfigField 'boolean', 'DIALER_WITH_RECENT', 'false'
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }


    flavorDimensions "prod"
    productFlavors {
        prod {
            dimension "prod"
            .....
        }
        livedemo {
            dimension "prod"
            .....
        }
        stage {
            dimension "prod"
            .....
        }
        stage2 {
            dimension "prod"
           ....
        }
    }
}


dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    /*androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })*/
    //bluetooth
    //compile 'com.estimote:sdk:0.11.1@aar'//Beacon-code
    /*androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.android.support', module: 'design'
        exclude group: 'com.android.support', module: 'recyclerview-v7'
    }*/
    //compile 'com.android.support.constraint:constraint-layout:1.0.2'
    /*compile 'com.google.firebase:firebase-messaging:10.0.1'*/
    //facebook login
    //twitter login
    implementation('com.twitter.sdk.android:twitter-core:1.6.6@aar') {
        transitive = true
    }
    implementation('com.twitter.sdk.android:twitter:1.13.1@aar') {
        transitive = true
    }
    implementation project(':libraryHashTag')
    implementation files('libs/SQLiteStudioRemote.jar')

    implementation project(':SwipeMenuLibCustom')

    implementation files('libs/jtar-1.1.jar')
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support:recyclerview-v7:27.1.0'
    implementation 'com.android.support:cardview-v7:27.1.0'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
    implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
    implementation 'com.github.bumptech.glide:glide:4.5.0'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
    implementation 'com.google.android.gms:play-services-safetynet:11.8.0'
    implementation 'com.github.clans:fab:1.6.4'
    implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
    implementation 'com.github.chrisbanes:PhotoView:2.1.3'
    implementation 'com.google.android.gms:play-services-analytics:11.8.0'
    implementation 'com.google.android.gms:play-services-location:11.8.0'
    implementation 'com.google.android.gms:play-services-base:11.8.0'
    implementation 'com.github.kenglxn.QRGen:android:2.4.0'
    implementation 'com.journeyapps:zxing-android-embedded:3.5.0'
    implementation 'com.facebook.android:facebook-android-sdk:4.28.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.android.gms:play-services-places:11.8.0'
    implementation 'com.google.android.gms:play-services-maps:11.8.0'
    implementation 'com.splitwise:tokenautocomplete:2.0.8'
    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    implementation 'com.google.android.gms:play-services-vision:11.8.0'
    implementation 'com.github.castorflex.smoothprogressbar:library:1.1.0'

    /*For Crashlytics*/
    releaseImplementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
        transitive = true
    }
    compile 'com.google.firebase:firebase-core:11.8.0'

    testCompile 'junit:junit:4.12'
}


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

混淆规则文件

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in D:\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}
-dontwarn javax.annotation.**
-dontwarn com.squareup.okhttp3.**
-keep class com.squareup.okhttp3.** { *; }
-keep interface com.squareup.okhttp3.* { *; }
-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.ParametersAreNonnullByDefault
-dontwarn javax.annotation.GuardedBy
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}
-dontwarn okio.**
-dontwarn org.apache.lang.**
-dontwarn org.joda.time.**
-dontwarn org.w3c.dom.**
-dontwarn com.viewpagerindicator.**
-keep class android.support.v4.** { *; }
-dontnote android.support.v4.**
-dontwarn retrofit2.Platform$Java8
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class android.support.v7.app.** { *; }
-keep interface android.support.v7.app.** { *; }
-keep class android.support.v7.widget.SearchView { *; }
-keep class org.ocpsoft.prettytime.**

-keep class com.estimote.sdk.* { *; }
-keep interface com.estimote.sdk.* { *; }
-dontwarn com.estimote.sdk.**

-dontwarn com.beloo.widget.chipslayoutmanager.Orientation
-keep class com.beloo.widget.chipslayoutmanager.* { *; }
-keep class com.beloo.widget.chipslayoutmanager.** { *; }
-keep class com.beloo.widget.chipslayoutmanager.*$* { *; }
-keep class RestrictTo.*
-keep class RestrictTo.**
-keep class RestrictTo.*$*

-keep class org.ocpsoft.prettytime.i18n.**

-keepclassmembers class android.support.design.internal.BottomNavigationMenuView {
    boolean mShiftingMode;
}


-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception


#-renamesourcefileattribute SourceFile
#-keepattributes SourceFile,LineNumberTable

#-printmapping mapping.txt

#-keepresourcexmlelements manifest/application/meta-data@value=GlideModule

最佳答案

这里是来自 Fabric 的 Mike。您正在使用 Fabric 不再支持的 Twitter SDK 版本。具体来说:

//twitter login
implementation('com.twitter.sdk.android:twitter-core:1.6.6@aar') {
    transitive = true
}
implementation('com.twitter.sdk.android:twitter:1.13.1@aar') {
    transitive = true
}

您应该更新到 Twitter's 3.x 版本的新 SDK。

关于android - 集成 Firebase Crashlytics 后生成签名 APK 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49277023/

相关文章:

android - 如何在 SQLite 中创建用户定义的函数?

gradle - java.lang.IllegalArgumentException带Kotlin的Corda转换存储库

ios - drawRect 中的 SIGABRT

ios - Crashlytics:您必须安装 Crashlytics 才能继续

java - ListView 中的图像在滚动上重复

java - 如何在库本身中使用库生成的类

android - 如何知道是否授予定位权限 "Allow all the time"

unit-testing - 在 IntelliJ 中运行单元和集成测试

gradle - 如何在Gradle项目中同时运行JUnit5和Spock 2.0测试

flutter - 在 dart 中操作 StackTrace