Unable to create call adapter crash when Proguard is active - java

I want to use ProGuard in my project. I activated the option minifyEnabled. When I open the activity that uses the library Retrofit2, the app crashes with:
Unable to create call adapter for interface retrofit2.Call
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gatafan.mydeen/com.gatafan.mydeen.ActivityPlaces}:
java.lang.IllegalArgumentException: Unable to create call adapter for interface retrofit2.Call
for method i.a
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: Unable to create call adapter for interface retrofit2.Call
for method i.a
at retrofit2.ServiceMethod$Builder.a(Unknown Source)
at retrofit2.ServiceMethod$Builder.b(Unknown Source)
at retrofit2.ServiceMethod$Builder.a(Unknown Source)
at retrofit2.Retrofit.a(Unknown Source)
at retrofit2.Retrofit$1.invoke(Unknown Source)
at com.gatafan.mydeen.api.$Proxy1.a(Native Method)
at com.gatafan.mydeen.api.VenueManager.requestFoursquare(Unknown Source)
at com.gatafan.mydeen.ActivityPlaces.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5264)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
... 11 more
Caused by: java.lang.IllegalArgumentException: Call return type must be parameterized as Call<Foo> or Call<? extends Foo>
at retrofit2.Utils.e(Unknown Source)
at retrofit2.ExecutorCallAdapterFactory.a(Unknown Source)
at retrofit2.Retrofit.a(Unknown Source)
at retrofit2.Retrofit.a(Unknown Source)
... 21 more

From the github page for Retrofit there is a section explaining what to do when using proguard:
PROGUARD
If you are using Proguard in your project add the following lines to your configuration:
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
try this configuration first, before moving forward with proguard changes

Related

java.lang.RuntimeException: Unable to destroy activity {com.xxxxx/com.xxxxx.MapsActivity}:

App is crashing when I click on back button on Map activity.
Adding moveTaskToBack(true); in onBackPressed() not worked.
Below is the logcat:
--------- beginning of crash
2020-02-06 10:12:44.807 26120-26120/com.xxxx.user E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxxx.user, PID: 26120
java.lang.RuntimeException: Unable to destroy activity {com.xxxx.user/com.xxxx.user.MapsActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'boolean com.google.maps.api.android.lib6.impl.bt.s()' on a null object reference
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4663)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4681)
at android.app.ActivityThread.-wrap6(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1777)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:232)
at android.app.ActivityThread.main(ActivityThread.java:6802)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1103)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'boolean com.google.maps.api.android.lib6.impl.bt.s()' on a null object reference
at com.google.maps.api.android.lib6.impl.cv.d(:com.google.android.gms.dynamite_mapsdynamite#20142051#20.1.42 (040408-0):27)
at com.google.android.gms.maps.internal.q.a(:com.google.android.gms.dynamite_mapsdynamite#20142051#20.1.42 (040408-0):30)
at cm.onTransact(:com.google.android.gms.dynamite_mapsdynamite#20142051#20.1.42 (040408-0):5)
at android.os.Binder.transact(Binder.java:504)
at com.google.android.gms.internal.maps.zza.zzb(Unknown Source)
at com.google.android.gms.maps.internal.zzj.onDestroyView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment$zza.onDestroyView(Unknown Source)
at com.google.android.gms.dynamic.DeferredLifecycleHelper.onDestroyView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onDestroyView(Unknown Source)
at androidx.fragment.app.Fragment.performDestroyView(Fragment.java:2811)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:954)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
at androidx.fragment.app.FragmentManagerImpl.dispatchDestroy(FragmentManagerImpl.java:2644)
at androidx.fragment.app.FragmentController.dispatchDestroy(FragmentController.java:329)
at androidx.fragment.app.FragmentActivity.onDestroy(FragmentActivity.java:366)
at androidx.appcompat.app.AppCompatActivity.onDestroy(AppCompatActivity.java:233)
at com.xxxx.user.MapsActivity.onDestroy(MapsActivity.java:250)
at android.app.Activity.performDestroy(Activity.java:7183)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1153)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4650)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4681) 
Looks to me that you are just attempting to call a method to an interface or object that is not initialized on line 250:
com.xxxx.user.MapsActivity.onDestroy(MapsActivity.java:250)

Firestore internal error on initialisation

My app keeps force closing in onCreate at the point where I initialise my Firebase.java class.
This is the constructor for the Firebase.java class.
public Firebase(Context context, ProgressChecker progressChecker) {
db = FirebaseFirestore.getInstance();
FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
.setTimestampsInSnapshotsEnabled(true)
.build();
db.setFirestoreSettings(settings);
batch = db.batch();
}
This is the stack trace that I get from Crashlytics.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: julio.ai.moyela.tito.timetoolay, PID: 4740
java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
at ecb.b(SourceFile:324)
at ece.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ExceptionInInitializerError
at esr.<clinit>(SourceFile:82)
at evl.b(SourceFile:103)
at evm.b(SourceFile:46)
at evm.a(SourceFile:26)
at ese.a(SourceFile:70)
at ebh.<init>(SourceFile:88)
at dwp.a(SourceFile:1217)
at dwr.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at ecb$a.run(SourceFile:190)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Package.getImplementationVersion()' on a null object reference
at etx.b(SourceFile:742)
at etx.<clinit>(SourceFile:197)
at esr.<clinit>(SourceFile:82) 
at evl.b(SourceFile:103) 
at evm.b(SourceFile:46) 
at evm.a(SourceFile:26) 
at ese.a(SourceFile:70) 
at ebh.<init>(SourceFile:88) 
at dwp.a(SourceFile:1217) 
at dwr.run(Unknown Source) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
at ecb$a.run(SourceFile:190) 
at java.lang.Thread.run(Thread.java:761) 
I honestly don't know what else to include because this is a Runtime error. It only occurs in my release build, and it stops occurring when I just get rid of the Firestore initialisation.
I am running these firebase libraries as well.
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-invites:16.0.0'
implementation 'com.google.firebase:firebase-firestore:17.0.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.3'

java.lang.NoSuchFieldError: No static field KL of type Lcom/google/android/gms/internal/zzsb$zzb

I'm trying to open a Camera Activity on my Android but I got this error when the Activity starts:
FATAL EXCEPTION: main
Process: bookreader.bookreader, PID: 19132
java.lang.NoSuchFieldError: No static field KL of type Lcom/google/android/gms/internal/zzsb$zzb; in class Lcom/google/android/gms/internal/zzsb; or its superclasses (declaration of 'com.google.android.gms.internal.zzsb' appears in /data/app/bookreader.bookreader-1/split_lib_dependencies_apk.apk:classes4.dex)
at com.google.android.gms.vision.text.internal.client.zze.zzcic(Unknown Source)
at com.google.android.gms.vision.text.internal.client.zze.<init>(Unknown Source)
at com.google.android.gms.vision.text.TextRecognizer$Builder.build(Unknown Source)
at bookreader.bookreader.CameraActivity.onCreate(CameraActivity.java:97)
at android.app.Activity.performCreate(Activity.java:6609)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3113)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3275)
at android.app.ActivityThread.access$1000(ActivityThread.java:218)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1744)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:7007)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
I don't know how to solve it. In my Android Manifest, I have this:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
make sure everything is up to date inside your build.gradle
no such method/field/class error usually occur because of dependency version mismatch (obfuscated fields names may be different across versions)

java.lang.IllegalAccessError on updating Firebase Auth from version 9.6.1 to 9.8.0

i recently updated Firebase Auth version in my app to 9.8.0 from 9.6.1. However, when I run the app, it crashes instantly. I get following error in the logcat:
java.lang.IllegalAccessError: Interface com.google.android.gms.internal.zzanb implemented by class com.google.firebase.auth.FirebaseAuth is inaccessible (declaration of 'com.google.firebase.auth.FirebaseAuth' appears in /data/data/com.svtech.thirdeye.thirdeye/files/instant-run/dex/slice-com.google.firebase-firebase-auth-9.6.1_65404207295ac58253e1599e984563499e3fff8b-classes.dex)
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:338)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
at com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(IncrementalClassLoader.java:90)
at com.android.tools.fd.runtime.IncrementalClassLoader.findClass(IncrementalClassLoader.java:62)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at java.lang.Class.forName(Class.java:285)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1801)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1776)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5427)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5000)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4940)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1549)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5728)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
What is causing this error?? How can I get rid of it???
Disable Instant run on your Android Studio and re-run the app.
To disable Instant Run:
Open the Settings or Preferences dialog.
Navigate to Build,
Execution, Deployment > Instant Run.
Uncheck the box next to Enable Instant Run.

The PersistenceManagerFactory class must define a static method?

I am attempting to connect my android app to my backend endpoints (in Google's App Engine) so that I can store my java objects in Google's datastore. However when I try to initialize the PersistenceManagerFactory object, I get the error seen at the end of this post - The PersistenceManagerFactory class must define a static method.
I am trying to initialize the object using the following code, and note: I do have the library in the classpath.
public static PersistenceManagerFactory InitializePersistanceManagerClass(){
Properties properties = new Properties();
properties.setProperty("javax.jdo.PersistenceManagerFactoryClass", "org.datanucleus.api.jdo.JDOPersistenceManagerFactory");
properties.setProperty("javax.jdo.option.ConnectionURL", "appengine");
properties.setProperty("javax.jdo.option.NontransactionalRead", "true");
properties.setProperty("javax.jdo.option.NontransactionalWrite", "true");
properties.setProperty("javax.jdo.option.RetainValues", "true");
properties.setProperty("datanucleus.appengine.autoCreateDatastoreTxns", "true");
properties.setProperty("datanucleus.appengine.singletonPMFForName", "true");
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(properties);
return pmf;
}
There is no line number listed in the error, however I am 90% sure the problem lies in the code above, or the class that I am using for the persistenceManagerFactory. The error when this code runs appears below. Any ideas? I really don't understand what the problem is....
08-23 09:10:31.826 7932-7932/com.myApp.myModule E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.myApp.myModule, PID: 7932
javax.jdo.JDOFatalInternalException: The PersistenceManagerFactory class must define a static method
PersistenceManagerFactory getPersistenceManagerFactory(Map props).
The class "org.datanucleus.jdo.JDOPersistenceManagerFactory"
defines a non-static getPersistenceManagerFactory(Map props) method.
at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(Unknown Source)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(Unknown Source)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(Unknown Source)
at com.myApp.myModule.forStorage.PMF.<init>(Unknown Source)
at com.myApp.myModule.Login.onConnected(Unknown Source)
at wz.a(Unknown Source)
at rb.e(Unknown Source)
at rb.d(Unknown Source)
at rd.onConnected(Unknown Source)
at wz.a(Unknown Source)
at wz.a(Unknown Source)
at wy.a(Unknown Source)
at wy.a(Unknown Source)
at wv.b(Unknown Source)
at wu.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5872)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:852)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:668)
at dalvik.system.NativeStart.main(Native Method)
NestedThrowablesStackTrace:
java.lang.NullPointerException
at javax.jdo.JDOHelper.forName(Unknown Source)
at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(Unknown Source)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(Unknown Source)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(Unknown Source)
at com.myApp.myModule.forStorage.PMF.<init>(Unknown Source)
at com.myApp.myModule.Login.onConnected(Unknown Source)
at wz.a(Unknown Source)
at rb.e(Unknown Source)
at rb.d(Unknown Source)
at rd.onConnected(Unknown Source)
at wz.a(Unknown Source)
at wz.a(Unknown Source)
at wy.a(Unknown Source)
at wy.a(Unknown Source)
at wv.b(Unknown Source)
at wu.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5872)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:852)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:668)
at dalvik.system.NativeStart.main(Native Method)
From the javax/jdo/Bundle.properties, we can see the below definition.
EXC_GetPMFNullPointerException = The PersistenceManagerFactory class must define a static methodPersistenceManagerFactory getPersistenceManagerFactory(Map props). The class "{0}" defines a non-static getPersistenceManagerFactory(Map props) method.
From the javax.jdo.JDOHelper source code, we can deduce that the below error message "The PersistenceManagerFactory class must define a static method PersistenceManagerFactory getPersistenceManagerFactory(Map props). The class org.datanucleus.jdo.JDOPersistenceManagerFactory defines a non-static getPersistenceManagerFactory(Map props) method." is coming from the below code in invokeGetPersistenceManagerFactoryOnImplementation method.
catch (NullPointerException e) {
throw new JDOFatalInternalException (msg.msg("EXC_GetPMFNullPointerException", pmfClassName), e);}
This is caused by java.lang.NullPointerException at javax.jdo.JDOHelper.forName(Unknown Source), which is mostly probably coming form Class.forName(name, init, loader);
Anyway, you could modify the javax.jdo.JDOHelper.forName method to add some more traces & print more exception info in it. It's not difficult.
If requried, you tell me the version for "jdo-api", then, I could provide one for you.

Categories