Skip to content
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

NullPointerException in Android #600

Closed
lachtos opened this issue Jul 18, 2019 · 4 comments
Closed

NullPointerException in Android #600

lachtos opened this issue Jul 18, 2019 · 4 comments
Labels
1️⃣ good first issue Good for newcomers 🤖 android Related to android 🐛 bug Something isn't working

Comments

@lachtos
Copy link

lachtos commented Jul 18, 2019

I had an app crash in the pre-launch test in google play console, giving this error stack:

FATAL EXCEPTION: mqt_native_modules
java.lang.NullPointerException
	at com.dooboolab.RNIap.RNIapModule$11.run(RNIapModule.java:496)
	at com.dooboolab.RNIap.RNIapModule.ensureConnection(RNIapModule.java:89)
	at com.dooboolab.RNIap.RNIapModule.sendUnconsumedPurchases(RNIapModule.java:491)
	at com.dooboolab.RNIap.RNIapModule.startListening(RNIapModule.java:508)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:525)
	at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
	at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
	at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
	at android.os.Handler.handleCallback(Handler.java:730)
	at android.os.Handler.dispatchMessage(Handler.java:92)
	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
	at android.os.Looper.loop(Looper.java:176)
	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
	at java.lang.Thread.run(Thread.java:841)

I don't get crashes yet on real devices, but since the code which caused this crash is fairly new (RNIapModule.java:496) I think it would be smart to take a look into this. Maybe it's just an environment issue and would not occur in real devices?

Also, I just had another pre-launch test on updated apk with no changes to the IAP module/code on the same android 4.3 device and it did not crash.

Version of react-native-iap

3.3.1

Version of react-native

0.59.10

Platforms you faced the error (IOS or Android or both?)

Android 4.3 | Galaxy S3

Expected behavior

No crash

Actual behavior

java.lang.NullPointerException

Tested environment (Emulator? Real Device?)

Google Play Console Pre-launch report

Steps to reproduce the behavior

Have google play console run a pre-launch test on the uploaded app

@hyochan hyochan added 🤖 android Related to android 🐛 bug Something isn't working 1️⃣ good first issue Good for newcomers labels Jul 18, 2019
@hyochan
Copy link
Owner

hyochan commented Jul 18, 2019

Please try 3.3.3 and come back.

ming436534 pushed a commit to ming436534/react-native-iap that referenced this issue Jul 19, 2019
* 'master' of https://github.com/dooboolab/react-native-iap: (107 commits)
  Release 3.3.4
  Keep valid SKUs in memory
  chore(package): update flow-bin to version 0.103.0
  Fixes hyochan#600
  Added missing types on updates in 3.3.0
  chore(package): update @types/react-native to version 0.60.2
  Release 3.3.1 (hyochan#596)
  Update travis with yarn
  Fix flow type for purchaseUpdatedListener
  Upgrade example project rn version
  chore(package): update @types/react-native to version 0.60.1
  Fix hyochan#581 finishTransaction called automatically (hyochan#589)
  Update index.js.flow
  chore(package): update lockfile yarn.lock
  chore(package): update @types/react-native to version 0.60.0
  chore(package): update lockfile yarn.lock
  chore(package): update @types/react to version 16.8.23
  Fixes hyochan#577 (hyochan#578)
  Update @types/react-native to the latest version 🚀 (hyochan#575)
  Improve README (hyochan#574)
  ...

# Conflicts:
#	ios/RNIapIos.m
@lachtos
Copy link
Author

lachtos commented Jul 19, 2019

I have a few crashes because of null pointer at line 504 now, on Android 8.1 in production build. v3.3.4

java.lang.NullPointerException: 
  at com.dooboolab.RNIap.RNIapModule$11.run (RNIapModule.java:504)
  at com.dooboolab.RNIap.RNIapModule.ensureConnection (RNIapModule.java:90)
  at com.dooboolab.RNIap.RNIapModule.sendUnconsumedPurchases (RNIapModule.java:496)
  at com.dooboolab.RNIap.RNIapModule.startListening (RNIapModule.java:516)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:372)
  at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:158)
  at com.facebook.react.bridge.queue.NativeRunnable.run (Native Method)
  at android.os.Handler.handleCallback (Handler.java:790)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:29)
  at android.os.Looper.loop (Looper.java:164)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:232)
  at java.lang.Thread.run (Thread.java:764)

@hyochan
Copy link
Owner

hyochan commented Jul 19, 2019

@lachtos Would you try 3.3.5? It's hard for me to debug since I can't generate this right now.

@lachtos
Copy link
Author

lachtos commented Jul 19, 2019

I can't reproduce it so it's a bit hard to debug. These logs are from google play console crash reports. After some googling I found that there are some rare cases when the value returned from the google api is null, so there should be null checks like there are right now in 3.3.5

I can't afford to keep testing this in production so I threw the code inside a try/catch for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1️⃣ good first issue Good for newcomers 🤖 android Related to android 🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants