-
Notifications
You must be signed in to change notification settings - Fork 565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java.lang.NullPointerException · Attempt to invoke virtual method 'void android.app.Activity.runOnUiThread(java.lang.Runnable)' on a null object reference #181
Comments
Thank you for reporting. This has been fixed in 0.5.0-alpha.21. Don't take following anyhow personally. But it would offload lot of burden from me, if I don't have to check if reported issue was not fixed in some later releases. This is specially valid for alpha releases. |
Thanks. How do I replicate on the latest alpha version? |
Well that's something I would like know too. I don't know how you managed to get this exception. |
After upgrading to 0.5.0-alpha.21, the null exception issue gone but I'm getting another exception. java.lang.IllegalArgumentExceptioncom.android.launcher3.Launcher
It is quite hard to reproduce though. It happened when I launched the app after the first time fresh installation and I couldn't reproduce it anymore using the same way right after that. By the way, I realise that the app sometimes resume rather than relaunch from the beginning, after I pressed home key and closed it. Is there anyway to prevent it from resuming? I have stopped the services and removed all the event handlers. Below is my configuration and log,
|
Just tried it again and hit the same error. App crashed immediately when I was trying to call stop() and removeEventListeners() in my ComponentWillUnmount method. The following is the adb log:
|
Can you share your component source code, so I can try to reproduce |
Also what is your android version? Device model and manufacturer? Or maybe even log from moment plugin is started (start method called). |
This looks like race condition. By any chance don't you call stop 2x in close to each other? |
The attached is my MainScreen Component Source Code. I can't share the whole project as it is too huge and due to some confidential issues. I'm using Geny Motion Google Nexus 5 , android 6.0 API 23. I have set the stopOnTerminate to True while calling stop() in componentWillUnMount, could that be the issue which caused the race condition? |
Why did the app resume and open the old page when I open it? It seems like doesn't get killed completely and start from splash screen when I close it from recent app list. It calls stop() and removes all listeners when I removed the app from recent app list. If It calls stop(), removes all listeners on A screen, navigates to B screen and I close it from recent app list, it will show activity DEAD in my adb logcat and start from splash screen again next time when I launch the app. If it starts the service, bind all event listeners on screen A, and then calls stop(), removes all listeners on same screen when I remove the app from recent app list. The next time when I launch the app again, it will show me the last screen I have viewed without starting from splash screen again. How do I prevent it from opening the old screen? This only happens on some android devices like Samsung. |
those question are not related to this plugin rather android, react-native... Please use stackoverflow for those. |
I can't reproduce crashes that are fixed in my PR. I`ve just found them in crashlytics of my release build and fixed it. |
@Yusiro85 I've tried to mimic your app, but cannot reproduce on Genymotion Custom Phone 6.0.0 API 23 Can you try this example (it's basically same what are you doing in your app):
|
Sorry for the late reply. I was outstation and couldn't go online last few days Yes, I have tried your sample code and hit the same error on GenyMotion Google Nexus 5 - 6.0 API 23. It happened when I press home button and removed the app from recent app list. Below is the log:
|
Regarding this issue, I have removed all my codes and applied only the sample code but still getting the same behaviour. Can you help me to look into it? |
@Yusiro85 ok. i'll added some more guards to prevent race conditions. I'll publish updated plugin later today, so you can test it. |
@Yusiro85 can you try latest alpha.24? |
fixed in 0.5.0-alpha.36 |
Your Environment
BackgroundGeolocation.configure({
distanceFilter: 50,
debug: false,
startOnBoot: false,
stationaryRadius: 50,
stopOnTerminate: true,
desiredAccuracy: 10,
interval: 15000
});
Context
Expected Behavior
Having these two lines of codes in my ComponentWillUnmount(),
BackgroundGeolocation.stop();
BackgroundGeolocation.events.forEach(event => BackgroundGeolocation.removeAllListeners(event));
When I press home key and close the app, it should not crash.
Actual Behavior
Tested on different android devices and emulator had different behaviors,
some would not crashed but some would.
Possible Fix
Steps to Reproduce
Context
Debug logs
The text was updated successfully, but these errors were encountered: