I am using a multi-module app and the app crashes when minifyEnabled true in the installed module's build.gradle.
Following is the deobfuscated stacktrace I retrieved from play console.
FATAL EXCEPTION: ControllerMessenger
Process: com.packagename, PID: 16978
java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object java.util.List.get(int)' on a null object reference
at com.packagename.login.Utils.AuthenticationActions.saveCredentials(AuthenticationActions.java)
at com.packagename.login.LoginActivity$1$1.onCompleted(LoginActivity.java)
at com.packagename.login.LoginActivity$1$1.onCompleted(LoginActivity.java)
at com.koushikdutta.async.future.SimpleFuture.handleCallbackUnlocked(SimpleFuture.java)
at com.koushikdutta.async.future.SimpleFuture.setComplete(SimpleFuture.java)
at com.koushikdutta.async.future.SimpleFuture.setComplete(SimpleFuture.java)
at com.koushikdutta.ion.IonRequestBuilder$EmitterTransform$1.onCompleted(IonRequestBuilder.java)
at com.koushikdutta.async.future.SimpleFuture.handleCallbackUnlocked(SimpleFuture.java)
at com.koushikdutta.async.future.SimpleFuture.setComplete(SimpleFuture.java)
at com.koushikdutta.async.future.SimpleFuture.setComplete(SimpleFuture.java)
at com.koushikdutta.ion.IonRequestBuilder$1.run(IonRequestBuilder.java)
at com.koushikdutta.async.AsyncServer$RunnableWrapper.run(AsyncServer.java)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at androidx.test.espresso.base.Interrogator.a(Interrogator.java:19)
at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:166)
at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:158)
at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:34)
at androidx.test.espresso.action.MotionEvents.a(MotionEvents.java:77)
at androidx.test.espresso.action.MotionEvents.a(MotionEvents.java:52)
at androidx.test.espresso.action.Tap.c(Tap.java:8)
at androidx.test.espresso.action.Tap.b(Tap.java:18)
at androidx.test.espresso.action.Tap$1.a(Tap.java:3)
at androidx.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:22)
at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:9)
at androidx.test.espresso.ViewInteraction.a(ViewInteraction.java:79)
at androidx.test.espresso.ViewInteraction.a(ViewInteraction.java:96)
at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:3)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5459)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
I am unable to understand what does this code correspond to 'java.lang.Object java.util.List.get(int)'
I am using multiple external libraries, one of which is ion koush.
I have tried adding this to ever proguard-rules.pro file in my project
-keep class com.koushikdutta.** { *;}. But this didn't yield any success.
This happens when your app transform json to POJOs and you have minify enable. Minify change those POJOs making the transformation impossible (it will compile, but all your POJOs propierties will be null).
Keep those POJOs adding -keep class com.packagename.<path to pojos> {*; } to your proguard-rules file.
Also add "#Keep" above class name to all Pojo files.
Related
The Math.toIntExact method is throwing an exception on my Android 6.0 emulator. (More recent emulator versions are ok)
This Microsoft doc is the only doc I found about it. Am I correct in thinking that Math.toIntExact is not compatible before Android 9.0 ?
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dmurphy.remotescrumpoker, PID: 9527
java.lang.NoSuchMethodError: No static method toIntExact(J)I in class Ljava/lang/Math; or its super classes (declaration of 'java.lang.Math' appears in /system/framework/core-libart.jar)
at com.dmurphy.remotescrumpoker.Activity_TeamDetails$6.onComplete(Activity_TeamDetails.java:268)
at com.google.android.gms.tasks.zzj.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
D/FA: Event not sent since app measurement is disabled
Math::toIntExact, as per the documentation, has been introduced with API level 24, that is Android 7.0. So yeah, it's not available on Android 6.
The good news is that you can easily implement it yourself by extracting it from the java.lang.Math source code.
public static int toIntExact(long value) {
if ((int)value != value) {
throw new ArithmeticException("integer overflow");
}
return (int)value;
}
I want to add Internet Connection Problem Dialog in my Async Task subclass. I tried many methods but the same error happened when my internet not connected.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.yasht.cricketapp, PID: 12793
java.lang.ClassCastException: java.lang.String cannot be cast to java.io.InputStream
at com.example.yasht.cricketapp.m_Rss.Downloader.onPostExecute(Downloader.java:66)
at android.os.AsyncTask.finish(AsyncTask.java:667)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:684)
at android.os.Handler.dispatchMessage(Handler.java:102)
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)
Error Pointing On 66 line:
Please comment If you want any other information.
You are casting data into inputStream, if you want to create this object you should do something like : ByteArrayInputStream( data.getBytes() )
probably you should post your onExecute too to see what are you trying to do
So, I have been following a YouTube tutorial for an android Weather application. The app seems to compile, however crashes whenever opened on the emulator. I'm not the most fluent programmer, however the code is understood. I can't figure out what's causing the issue though. The app is supposed to fetch weather data for the location of the hardcoded location in "MainActivity.java". The data is fetched from Yahoo! using an API.
Link for the project files: https://drive.google.com/drive/folders/0B2dQ9-JQjysVeXlqZENBZDExN0E?usp=sharing
Below is the error I get:
--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.mattbenson.cw_2_weather, PID: 2529
java.lang.NullPointerException: Attempt to invoke virtual method 'int org.json.JSONObject.optInt(java.lang.String)' on a null object reference
at com.example.mattbenson.cw_2_weather.service.WeatherService$1.onPostExecute(WeatherService.java:81)
at com.example.mattbenson.cw_2_weather.service.WeatherService$1.onPostExecute(WeatherService.java:38)
at android.os.AsyncTask.finish(AsyncTask.java:667)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:684)
at android.os.Handler.dispatchMessage(Handler.java:102)
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)
E/Surface: queueBuffer: error queuing buffer to SurfaceTexture, -19
E/EGL_emulation: tid 2570: swapBuffers(487): error 0x300d (EGL_BAD_SURFACE)
W/OpenGLRenderer: swapBuffers encountered EGL error 12301 on 0x76990bb1c580, halting rendering...
Application terminated.
(Sorry, I am new to this site!)
Any help is greatly appreciated.
As StackTrace says the error is at Class WeatherService at line 81 int count = queryResults.optInt("Count"); because it is returning NULL.
Try using method optInt with fallback value queryResults.optInt("Count", 0);
Used native-libs.jar. Following the same method as given in the sample. Currently using quickblox-android-sdk-videochat-webrtc-2.4. Trying using the sample code QBRTCClient shows the below error message:
java.lang.NoSuchMethodError: No static method registerComplexPropertyParser(Ljava/lang/String;Lcom/quickblox/chat/propertyparsers/MessagePropertyParser;)V in class Lcom/quickblox/chat/model/QBChatMessageExtension; or its super classes (declaration of 'com.quickblox.chat.model.QBChatMessageExtension' appears in /data/app/xxx.xxx.xxx/base.apk)
at com.quickblox.videochat.webrtc.RTCSignallingMessageProcessor.<clinit>(RTCSignallingMessageProcessor.java:38)
at com.quickblox.videochat.webrtc.QBRTCClient.<init>(QBRTCClient.java:93)
at com.quickblox.videochat.webrtc.QBRTCClient.getInstance(QBRTCClient.java:124)
at xxx.xxx.xxx.Activity.CallActivity.initQBRTCClient(CallActivity.java:125)
at xxx.xxx.xxx..Activity.CallActivity.onCreate(CallActivity.java:119)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2312)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2421)
at android.app.ActivityThread.access$900(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5329)
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:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
I was using multiple version of library for chat, video and core, so i contacted Quickblox and they told me to use the same version of library for all. Hope this helps.
Thank You
Recently I started to observe a lot of exceptions of this kind.
The classes that can not be casted to itself are injected by dagger.
By the way, I'm using multidex build in gradle.
Log look like the following:
FATAL EXCEPTION: main
Process: com.ui.client.debug, PID: 22087
java.lang.ClassCastException: com.logic.feed.FeedManager cannot be cast
to com.logic.feed.FeedManager
at com.logic.topic.TopicHandler$$InjectAdapter.get(TopicHandler$$InjectAdapter.java:73)
at com.logic.topic.TopicHandler$$InjectAdapter.get(TopicHandler$$InjectAdapter.java:19)
at com.ui.client.module.MainActivityModule$$ModuleAdapter$ProvideTopicHandlerProvidesAdapter.get(MainActivityModule$$ModuleAdapter.java:1244)
at com.ui.client.module.MainActivityModule$$ModuleAdapter$ProvideTopicHandlerProvidesAdapter.get(MainActivityModule$$ModuleAdapter.java:1208)
at com.ui.topic.TopicScene$$InjectAdapter.injectMembers(TopicScene$$InjectAdapter.java:73)
at com.ui.topic.TopicScene$$InjectAdapter.injectMembers(TopicScene$$InjectAdapter.java:23)
at dagger.ObjectGraph$DaggerObjectGraph.inject(ObjectGraph.java:281)
at com.ui.core.base.BaseActivity.inject(BaseActivity.java:35)
at com.ui.core.base.BaseFragment.onActivityCreated(BaseFragment.java:54)
at android.app.Fragment.performActivityCreated(Fragment.java:2122)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
at android.app.BackStackRecord.run(BackStackRecord.java:833)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:452)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5834)
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:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
If you still haven't figured a solution, it might be Samsung's faulty implementation of MultiDex on theEuropean variant of the Galaxy S5 on 5.0:
https://stackoverflow.com/a/29008480/477243
I've had plenty of similar crashes reported (ClassCastException on casting a class to itself).
Upon reading the linked answer I've checked the devices which were generating the crash, all of them were SM G900F on Android 5.0, which is a shame since my App is available only on UK and Netherlands and the GS5 is one of our top devices (11.5% of the users).