Proguard与Crashlytics 2.7.1崩溃

时间:2017-10-25 08:41:13

标签: android crashlytics crashlytics-android

刚刚从2.6.8更新到2.7.1,我在Proguard上遇到了这次崩溃:

io.fabric.sdk.android.services.common.FirebaseInfo: can't find referenced method 'java.lang.String sha256(java.lang.String)' in program class io.fabric.sdk.android.services.common.CommonUtils

我该如何解决这个问题?

尝试:

-keep class io.fabric.sdk.android.** { *; }

但它似乎没有起作用。

的build.gradle:

dependencies {

    //Support stuff
    compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
    compile "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
    compile "com.android.support:design:$rootProject.supportLibraryVersion"
    compile "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
    compile "com.android.support:support-v4:$rootProject.supportLibraryVersion"
    compile "com.android.support:palette-v7:$rootProject.supportLibraryVersion"
    compile "com.android.support:support-annotations:$rootProject.supportLibraryVersion"
    compile "com.android.support:support-vector-drawable:$rootProject.supportLibraryVersion"
    compile "com.android.support:preference-v7:$rootProject.supportLibraryVersion"
    compile "com.android.support:preference-v14:$rootProject.supportLibraryVersion"
    compile 'com.android.support:multidex:1.0.1'

    //Logging
    compile "com.jakewharton.timber:timber:$rootProject.timberVersion"

    //Rx
    compile "io.reactivex:rxjava:$rootProject.rxjavaVersion"
    compile "io.reactivex:rxandroid:$rootProject.rxandroidVersion"

    //Retrofit
    compile "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
    compile "com.squareup.retrofit2:adapter-rxjava:$rootProject.retrofitVersion"
    compile "com.squareup.retrofit2:converter-gson:$rootProject.retrofitVersion"

    //Okhttp
    compile "com.squareup.okhttp3:okhttp:$rootProject.okHttpVersion"
    compile "com.squareup.okhttp3:logging-interceptor:$rootProject.okHttpVersion"

    //Gson
    compile "com.google.code.gson:gson:$rootProject.gsonVersion"

    //Picasso
    compile "com.squareup.picasso:picasso:$rootProject.picassoVersion"

 compile("com.crashlytics.sdk.android:crashlytics:$rootProject.crashlyticsVersion@aar") {
        transitive = true
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    compile 'com.mixpanel.android:mixpanel-android:5.+'
    compile "com.google.android.gms:play-services-gcm:$rootProject.playServicesVersion"
    compile "com.google.android.gms:play-services-base:$rootProject.playServicesVersion"

    //Injection
    compile "com.google.dagger:dagger:$rootProject.daggerVersion"
    annotationProcessor "com.google.dagger:dagger-compiler:$rootProject.daggerVersion"
    compile "com.jakewharton:butterknife:$rootProject.butterKnifeVersion"
    annotationProcessor "com.jakewharton:butterknife-compiler:$rootProject.butterKnifeVersion"

    //Mosby
    compile "com.hannesdorfmann.mosby:mvp:$rootProject.mosbyVersion"
    compile "com.hannesdorfmann.mosby:viewstate:$rootProject.mosbyVersion"

    //Merlin beard
    compile "com.novoda:merlin:$rootProject.merlinVersion"

    //Database
    compile "com.squareup.sqlbrite:sqlbrite:$rootProject.sqlbriteVersion"
    compile "io.requery:requery:$rootProject.ext.requeryVersion"
    compile "io.requery:requery-android:$rootProject.ext.requeryVersion"
    annotationProcessor "io.requery:requery-processor:$rootProject.ext.requeryVersion"
    compile 'net.danlew:android.joda:2.9.9'

    //Streaming library
    compile project(':streamlib')
    testCompile "junit:junit:$rootProject.ext.junitVersion"
    androidTestCompile("com.android.support.test.espresso:espresso-core:$rootProject.ext.espressoVersion", {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestCompile 'com.google.code.findbugs:jsr305:3.0.0'
    compile "com.algolia:algoliasearch-android:$algoliaVersion"
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
}

我的计划规则:

-dontnote android.net.http.*
-dontnote org.apache.commons.codec.**
-dontnote org.apache.http.**


#### -- Picasso --
 -dontwarn com.squareup.picasso.**
 #### -- Apache Commons --
 -dontwarn org.apache.commons.logging.**

 #### -- OkHttp --

 -dontwarn com.squareup.okhttp.internal.**
 -dontwarn okio.**
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**


-dontwarn okio.**
-dontwarn javax.annotation.**
-dontwarn retrofit2.Platform$Java8
-dontwarn com.squareup.okhttp.*

-keep class sun.misc.Unsafe { *; }
-keep class retrofit.** { *; }


-keepattributes *Annotation*
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception

-keep class com.crashlytics.** { *; }
-keep class io.fabric.sdk.android.** { *; }
-dontwarn com.crashlytics.**


-dontwarn sun.misc.**
-dontwarn rx.Completable**
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
   long producerIndex;
   long consumerIndex;
}

-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
    rx.internal.util.atomic.LinkedQueueNode producerNode;
}

-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
    rx.internal.util.atomic.LinkedQueueNode consumerNode;
}

-dontnote rx.internal.util.PlatformDependent

3 个答案:

答案 0 :(得分:3)

  1. 删除exclude部分:

    compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') { transitive = true }

  2. 将以下内容添加到Proguard规则中:

    -keep class io.fabric.sdk.android.** { *; } -dontwarn io.fabric.sdk.android.**

  3. 使用最新的支持库版本:26.1.0

  4. 这可以解决您的问题。

答案 1 :(得分:0)

你可以尝试:

# Crashlytics 2.+

-keep class com.crashlytics.** { *; }
-keep class com.crashlytics.android.**
-keepattributes SourceFile, LineNumberTable, *Annotation*

# If you are using custom exceptions, add this line so that custom exception types are skipped during obfuscation:
-keep public class * extends java.lang.Exception

# For Fabric to properly de-obfuscate your crash reports, you need to remove this line from your ProGuard config:
# -printmapping mapping.txt

答案 2 :(得分:0)

这可能对您有所帮助

compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
    transitive = true
    exclude group: 'com.android.support', module: 'support-annotations'
}