In our Android mobile application (compatible with Android versions 4.0 and upper), we use Google Maps API V2.
We get some bug reports from users on some kinds of devices (Android versions 4.3, 4.4 and 5.0) with a NullPointerException in setBoundsInParent method of android.view.accessibility.AccessibilityNodeInfo class.
The application crashes when the user tries to move or to zoom on the map.
The problem only appears for some users - devices. Most of our customers do not have that problem.
The problem seems to come from the use of the setPadding method of Google Maps API to position the Google logo so that it is always clearly visible on the map :
#Override
protected void onCreate(Bundle savedInstanceState)
{
...
// Initialize map
...
// Sets the padding for the map
if(mMap!=null)
{
mMap.setPadding(0, DPI.toPixels(100), 0, DPI.toPixels(100));
}
...
}
Removing the call to the setPadding method seems to resolve the problem for affected users but it is not a valid solution for us because we need to position the Google logo with this method.
We cannot reproduce this problem on our development devices, so it's difficult for us to find the real origin of this problem.
You will find the full stacktraces of the bug below.
Does someone have an idea?
Thanks a lot in advance for your answer.
Best regards.
Stacktrace on Android 4.3 - 4.4
java.lang.NullPointerException
at android.view.accessibility.AccessibilityNodeInfo.setBoundsInParent(AccessibilityNodeInfo.java:1012)
at android.support.v4.view.a.k.c(SourceFile:819)
at android.support.v4.view.a.i.b(SourceFile:1850)
at com.google.maps.api.android.lib6.c.et.a(Unknown Source)
at android.support.v4.widget.ab.a(SourceFile:56)
at android.support.v4.widget.ac.a(SourceFile:717)
at android.support.v4.view.a.x.a(SourceFile:112)
at android.support.v4.view.a.ad.createAccessibilityNodeInfo(SourceFile:42)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchAccessibilityNodeInfos(AccessibilityInteractionController.java:724)
at android.view.AccessibilityInteractionController.findAccessibilityNodeInfoByAccessibilityIdUiThread(AccessibilityInteractionController.java:147)
at android.view.AccessibilityInteractionController.access$300(AccessibilityInteractionController.java:49)
at android.view.AccessibilityInteractionController$PrivateHandler.handleMessage(AccessibilityInteractionController.java:971)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5212)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
Stacktrace on Android 5.0
java.lang.NullPointerException: Attempt to read from field 'int android.graphics.Rect.left' on a null object reference
at android.view.accessibility.AccessibilityNodeInfo.setBoundsInParent(AccessibilityNodeInfo.java:1316)
at android.support.v4.view.a.k.c(SourceFile:819)
at android.support.v4.view.a.i.b(SourceFile:1850)
at com.google.maps.api.android.lib6.c.et.a(Unknown Source)
at android.support.v4.widget.ab.a(SourceFile:56)
at android.support.v4.widget.ac.a(SourceFile:717)
at android.support.v4.view.a.x.a(SourceFile:112)
at android.support.v4.view.a.ad.createAccessibilityNodeInfo(SourceFile:42)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchAccessibilityNodeInfos(AccessibilityInteractionController.java:894)
at android.view.AccessibilityInteractionController.findAccessibilityNodeInfoByAccessibilityIdUiThread(AccessibilityInteractionController.java:155)
at android.view.AccessibilityInteractionController.access$400(AccessibilityInteractionController.java:53)
at android.view.AccessibilityInteractionController$PrivateHandler.handleMessage(AccessibilityInteractionController.java:1236)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
The bug has been confirmed by Google : http://code.google.com/p/gmaps-api-issues/issues/detail?id=7619
Best regards.
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;
}
On android 7.0 when I want to open a camera in logs I see this :
EventBus: Could not dispatch event: class pl.eltegps.smokkomunikator.event.PhotoRequestedEvent to subscribing class class pl.eltegps.smokkomunikator.ui.activity.MainActivity
android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/pl.eltegps.smokkomunikator/images/gps_TEMP.jpg exposed beyond app through ClipData.Item.getUri()
at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
at android.net.Uri.checkFileUriExposed(Uri.java:2346)
at android.content.ClipData.prepareToLeaveProcess(ClipData.java:832)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9483)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9468)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1525)
at android.app.Activity.startActivityForResult(Activity.java:4399)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
at android.app.Activity.startActivityForResult(Activity.java:4358)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:871)
at pl.eltegps.smokkomunikator.ui.activity.MainActivity.onPhotoRequestedEvent(MainActivity.java:399)
at java.lang.reflect.Method.invoke(Native Method)
at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:485)
at org.greenrobot.eventbus.EventBus.postToSubscription(EventBus.java:416)
at org.greenrobot.eventbus.EventBus.postSingleEventForEventType(EventBus.java:397)
at org.greenrobot.eventbus.EventBus.postSingleEvent(EventBus.java:370)
at org.greenrobot.eventbus.EventBus.post(EventBus.java:251)
at pl.eltegps.smokkomunikator.ui.fragment.NewMessageFragment.photo(NewMessageFragment.java:259)
at pl.eltegps.smokkomunikator.ui.fragment.NewMessageFragment$$ViewBinder$1.doClick(NewMessageFragment$$ViewBinder.java:28)
at butterknife.internal.DebouncingOnClickListener.onClick(DebouncingOnClickListener.java:22)
at android.view.View.performClick(View.java:6199)
at android.view.View$PerformClick.run(View.java:23647)
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:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
On android 4.4.2 I check and it works corretly, but on new android it doesn't works corretly and I don't know why ...
This is a problem I faced also faced while testing on 7.0 . Seems like you can not use getUri() Directly on 7.0 without the use of content provider.
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
FileProvider.getUriForFile(getActivity(), getActivity().getApplicationContext().getPackageName() + ".provider", f));
You will have to use this and add a provider.xml in xml directory of your project.
this link has detailed explaination about it.
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).