question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] Attempt to invoke virtual method 'int android.content.Intent.getFlags()' on a null object reference

See original GitHub issue

Hi, 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

Image from Gyazo


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:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
tschoffelencommented, Jun 27, 2019

Thanks @johnnyborg, that’s great! I’ve incorporated your fix into the latest NPM release (react-native-email-link@1.4.0).

1reaction
johnnyborgcommented, Jun 27, 2019

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found