-
Notifications
You must be signed in to change notification settings - Fork 271
Closed
Description
I'm using retrofit with okhttp and migrated to AndroidX, When I make a signed app that obfuscated with proguard it crashes and gives an error,but in debug mode when proguard is not enabled it's working good. and I disabled proguard just for testing and made a signed APK it's working this way too. so I'm sure the crash is caused by Proguard. And I did some search on google they all say that I have to add proguard rules for both OKHTTP and Retrofit I did add them too but it still crashes. The error is logged from Crashlytics because I didn't enable proguard in debug mode:
PagedStorage.java line 118
androidx.paging.PagedStorage.init
Fatal Exception: java.lang.NullPointerException
Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
androidx.paging.PagedStorage.init (PagedStorage.java:118)
androidx.paging.PagedStorage.init (PagedStorage.java:131)
androidx.paging.ContiguousPagedList$1.onPageResult (ContiguousPagedList.java:81)
androidx.paging.DataSource$LoadCallbackHelper$1.run (DataSource.java:324)
android.os.Handler.handleCallback (Handler.java:790)
android.os.Handler.dispatchMessage (Handler.java:99)
android.os.Looper.loop (Looper.java:164)
android.app.ActivityThread.main (ActivityThread.java:7000)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:441)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408)
Thread-20
java.lang.Object.wait (Object.java)
java.lang.Thread.parkFor$ (Thread.java:2137)
sun.misc.Unsafe.park (Unsafe.java:358)
java.util.concurrent.locks.LockSupport.park (LockSupport.java:190)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2059)
java.util.concurrent.PriorityBlockingQueue.take (PriorityBlockingQueue.java:548)
com.android.volley.NetworkDispatcher.processRequest (NetworkDispatcher.java:104)
com.android.volley.NetworkDispatcher.run (Network
And that's my Proguard rules:
-dontwarn org.conscrypt.OpenSSLProvider
-dontwarn org.conscrypt.Conscrypt
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
-keepattributes Signature, InnerClasses, EnclosingMethod
# Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* <methods>;
}
# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**
# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit
# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.-KotlinExtensions
# JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**
# A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*
# OkHttp platform used only on JVM and when Conscrypt dependency is available.
-dontwarn okhttp3.internal.platform.ConscryptPlatform
-keep class com.google.android.material.** { *; }
-dontwarn com.google.android.material.**
-dontnote com.google.android.material.**
this part added after the crash but it's still useless
-dontwarn androidx.**
-keep class androidx.** { *; }
-keep interface androidx.** { *; }
-keep class androidx.paging.PagedStorage.init
And that's my gradle:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.1.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'com.google.android.material:material:1.1.0-alpha01'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
implementation 'androidx.drawerlayout:drawerlayout:1.0.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.facebook.android:audience-network-sdk:5.1.0'
implementation 'com.facebook.android:facebook-android-sdk:4.37.0'
implementation 'com.github.KwabenBerko:OpenWeatherMap-Android-Library:v1.1.1'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.google.firebase:firebase-invites:16.0.5'
implementation 'com.google.firebase:firebase-core:16.0.5'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.6'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
implementation 'com.google.firebase:firebase-analytics:16.0.5'
implementation 'com.google.firebase:firebase-dynamic-links:16.1.3'
implementation 'com.firebaseui:firebase-ui-auth:4.2.1'
implementation 'androidx.paging:paging-runtime:2.1.0-beta01'
//Rate my APP
implementation 'com.github.hotchemi:android-rate:1.0.1'
//Firebase performance
implementation 'com.google.firebase:firebase-perf:16.2.0'
implementation 'com.google.firebase:firebase-config:16.1.0'
implementation 'com.github.metalurgus:LocaleText:0.0.1.1'
implementation 'com.github.paolorotolo:appintro:v5.1.0'
/*
* Step 2: Adding ViewModel and Lifecycle
*/
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
/*
* Step 3: Adding rxJava to the app
*/
implementation 'io.reactivex.rxjava2:rxjava:2.2.2'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'com.an.customfontview:customfont:0.1.0'
/*
* Step 4: Adding retrofit to the app
*/
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
/*
* Step 5: We would be needing an image loading library.
* So we are going to use Picasso
*/
implementation 'com.squareup.picasso:picasso:2.71828'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
}
apply plugin: 'com.google.gms.google-services'
And I have posted it to StackOverflow too:
Metadata
Metadata
Assignees
Labels
No labels