Android-приложение падает при выпуске с Proguard - PullRequest
3 голосов
/ 08 мая 2019

My App , сбой при создании выпуска сборки . Приложение работало правильно, и внезапно это произошло. У меня есть эта строка в BaseActivity.java MultiDex.install(this); Я пробовал несколько вариантов из SO, но ни один из них не работал. Ошибка также не предоставляет достаточно подробностей, или я не могу найти точку, где происходит эта проблема. Любая помощь будет принята с благодарностью.

Вот трассировка стека.

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.packagename, PID: 10136
    java.lang.VerifyError: Verifier rejected class android.support.multidex.MultiDex: void android.support.multidex.MultiDex.<init>() failed to verify: void android.support.multidex.MultiDex.<init>(): [0x0] Constructor returning without calling superclass constructor (declaration of 'android.support.multidex.MultiDex' appears in /data/app/com.packagename-4uitso2MKAahWwylc8ZTtA==/base.apk!classes2.dex)
        at android.support.multidex.MultiDex.install(MultiDex.java:95)
        at com.packagename.baseactivity.BaseActivity.attachBaseContext(BaseActivity.java:43)
        at android.app.Application.attach(Application.java:224)
        at android.app.Instrumentation.newApplication(Instrumentation.java:1128)
        at android.app.LoadedApk.makeApplication(LoadedApk.java:1162)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6607)
        at android.app.ActivityThread.access$2000(ActivityThread.java:268)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1995)
        at android.os.Handler.dispatchMessage(Handler.java:109)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:7539)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)

Вот мой build.gradle

apply plugin: 'com.android.application'

android {
    signingConfigs {
        release {
            keyAlias 'packagename'
            keyPassword 'packagename'
            storeFile file('E:/Projects/packagenameFile')
            storePassword 'packagename'
        }
        debug {
            keyAlias 'packagename'
            keyPassword 'packagename'
            storeFile file('E:/Projects/packagenameFile')
            storePassword 'packagename'
        }

    }
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.packagename"
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 15
        versionName "4.2.3.5"
        multiDexEnabled true
        manifestPlaceholders = [onesignal_app_id               : "d4d19a49b4f3b96",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "10977637306"]
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    buildTypes {
        release {
            multiDexEnabled true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            debuggable false
            jniDebuggable false
            signingConfig signingConfigs.release
            renderscriptDebuggable false
            pseudoLocalesEnabled false
        }
        debug {
            multiDexEnabled true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
}

dependencies {

    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'

    // below 3 libs are for one Signal
    implementation 'com.onesignal:OneSignal:3.+@aar'
    implementation 'com.google.android.gms:play-services-gcm:16.1.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'

    //SMS auto retriever API
    implementation "com.google.android.gms:play-services-auth:16.0.1"

    //firebase analytics
    implementation "com.google.firebase:firebase-core:16.0.8"

    //Network calls
    implementation 'com.squareup.okhttp3:okhttp:3.12.1'

    //PDF Reader
    implementation 'com.github.barteksc:android-pdf-viewer:2.4.0'

    //for creating demos.
    implementation 'uk.co.samuelwall:material-tap-target-prompt:2.0.1'

    //displays charts.
    implementation project(':MPChartLib')

    //Kotlin
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    // Sql Cipher
    implementation 'net.zetetic:android-database-sqlcipher:4.1.3@aar'

}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

Обновлено с правилами Proguard

# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# 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 *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*
-keepattributes EnclosingMethod
-keepattributes InnerClasses
-dontwarn org.xmlpull.v1.**
-dontwarn android-support-v4.**
-dontwarn  com.crashlytics.**
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
-keep public class com.google.** {*;}
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable

-dontwarn android.support.v7.**
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }
-keep class android.support.design.widget.** { *; }
-keep interface android.support.design.widget.** { *; }
-dontwarn android.support.design.**
-keep class yourpakganame.itemdecorator
-keep public class * extends android.support.v7.widget.RecyclerView.ItemDecoration
-keep class android.support.v7.widget.RecyclerView
-assumenosideeffects class android.util.Log{*;}
#1 to
-assumenosideeffects class * implements Interface {
    public <init>();
    public Object interfacemethod(); # May concern methods with same signature in other Objects
}
#end

-keep class net.sqlcipher.** { *; }
-dontwarn net.sqlcipher.**
-dontwarn OneSignalSDK.**
-dontwarn com.amazon.**
-dontwarn  com.crashlytics.**
-keep class android.support.** { *; }
-dontnote android.support.**
-dontwarn android.support.**
-keep class com.firebase.** { *; }
-keep class org.apache.** { *; }
-keepnames class com.fasterxml.jackson.** { *; }
-keepnames class javax.servlet.** { *; }
-keepnames class org.ietf.jgss.** { *; }
-dontwarn okhttp3.**
-dontwarn okio.**
-keep class okhttp3.**{ *;}
-dontwarn org.apache.**
-dontwarn org.w3c.dom.**
-dontwarn org.joda.time.**
-dontwarn org.shaded.apache.**
-keep class com.crashlytics.** { *; }
-keep class com.shockwave.**
-keepclassmembers class com.shockwave.** { *; }
-keep class com.google.firebase.example.fireeats.model.** { *; }
-keepclassmembers class com.getbase.floatingactionbutton.FloatingActionsMenu$RotatingDrawable {
   void set*(***);
   *** get*();
}

1 Ответ

2 голосов
/ 08 мая 2019

от здесь

удалить строки из вашего файла proguard

#1 to
-assumenosideeffects class * implements Interface {
    public <init>();
    public Object interfacemethod(); # May concern methods with same signature in other Objects
}
#end

И заменить

-assumenosideeffects class android.util.Log{*;}

С

-assumenosideeffects class android.util.Log {
   public static *** v(...);
   public static *** d(...);
   public static *** i(...);
   public static *** w(...);
   public static *** e(...);
   public static *** wtf(...);

}

...