[Android] Attempt to invoke virtual method 'int android.content.Intent.getFlags()' on a null object reference
See original GitHub issueHi, this library works perfectly on most Android devices, but when I tested it on a Galaxy S6 with Android 5, it crashed. Here’s the stack trace I got
java.lang.NullPointerException Attempt to invoke virtual method 'int android.content.Intent.getFlags()' on a null object reference
Intent.java:891 android.content.Intent.createChooser
EmailModule.java:42 com.facebook.react.modules.email.EmailModule.open
Method.java:-2 java.lang.reflect.Method.invoke
Method.java:372 java.lang.reflect.Method.invoke
JavaMethodWrapper.java:372 com.facebook.react.bridge.JavaMethodWrapper.invoke
JavaModuleWrapper.java:160 com.facebook.react.bridge.JavaModuleWrapper.invoke
NativeRunnable.java:-2 com.facebook.react.bridge.queue.NativeRunnable.run
Handler.java:739 android.os.Handler.handleCallback
Handler.java:95 android.os.Handler.dispatchMessage
MessageQueueThreadHandler.java:29 com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage
Looper.java:145 android.os.Looper.loop
MessageQueueThreadImpl.java:192 com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run
Thread.java:818 java.lang.Thread.run
I also experienced the similar crashes when I test it on some Android Emulators with Android 7 (API version 25) or earlier
My code:
import { openInbox } from "react-native-email-link";
...
<Button
onPress={() => openInbox()}
title="Open Email App"
/>
...
My environment:
"react-native": "0.57.0",
"react": "16.5.0",
"react-native-email-link": "^1.2.1",
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Null Object Reference with Intent - java - Stack Overflow
... Attempt to invoke virtual method 'java.lang.String android.content.Intent.getStringExtra(java.lang.String)' on a null object reference ...
Read more >[Android] Attempt to invoke virtual method 'int android.content ...
java.lang.NullPointerException Attempt to invoke virtual method 'int android.content.Intent.getFlags()' on a null object reference ...
Read more >Fixed Error android error attempt to invoke virtual method
Need Help or Code Support? Feel Free To Contact Us Here http://www.aaviskar.com/support.phpThis video is about Fixed Error android error ...
Read more >"Attempt to invoke virtual method 'java.lang.String android ...
String android.content.Context.getPackageName()' on a null object reference" when authenticting user on Android. Authenticating the user (using ...
Read more >java.lang.NullPointerException: Attempt to invoke virtual ...
activityTrace' on a null object reference at com.newrelic.agent.android.tracing.TraceMachine.getCurrentScope(TraceMachine.java:593) at ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @johnnyborg, that’s great! I’ve incorporated your fix into the latest NPM release (
react-native-email-link@1.4.0
).Yeah, we’ve got this issue too. Its however not an issue on the line state @jorisw but a bit lower. Android on lower SDKs has an
com.android.fallback
package which has no default intent, causing the null pointer exception.I’ve written an fix for this. @tschoffelen can you integrate it? https://github.com/leanmotherfuckers/react-native-email-link/pull/24