Issue with currentActivity.getClass when using RN 0.30 on Android
bourgois opened this issue · 5 comments
Hi
We upgraded our app to RN 0.30 and while it works on iOS, it crash immediately at launch on Android:
- AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
- AndroidRuntime: at com.slowpath.hockeyapp.RNHockeyAppModule.start(RNHockeyAppModule.java:105)
This seems to be an issue with:
LoginManager.register(_context, _token, _appSecret, authenticationMode, currentActivity.getClass());
Any idea what we are doing wrong?
The only other thing we see in the logs is: "FATAL EXCEPTION: mqt_native_modules"
Thanks!
@martincik Any idea on how to deal with this?
@martincik
It seems the issue is with using getCurrentActivity() as activity can be null sometime.
I resolved the issue by adding the following to start, update and feedback:
if (currentActivity == null) {
// The currentActivity can be null if it is backgrounded / destroyed, so we simply
// no-op to prevent any null pointer exceptions.
return;
}
I can make a pull request if you want.
thanks @martincik
I'm actually seeing this error when an app is started. It seems the currentActivity is null when start is called. You could no-op, but then HockeyApp wouldn't be started.
If I implement LifeCycleEventListener
I can see:
@Override
public void onHostResume() {
System.out.println("Printed after start method.");
}
Is called after start. So when start was called there was no activity.
Maybe start could check for activity, if it isn't null then start. If it is then set a flag and then start in the onHostResume method.
If this sounds alright I'll submit a PR. It would also be good to get a release pushed.
Sounds good to me.