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

Issue with version 3.0.0 #23

Open
paulstelzer opened this issue Nov 23, 2020 · 1 comment
Open

Issue with version 3.0.0 #23

paulstelzer opened this issue Nov 23, 2020 · 1 comment

Comments

@paulstelzer
Copy link

paulstelzer commented Nov 23, 2020

After updating to Version 3.0.0 of the capacitor plugin, I always get the following error:

Serious error executing plugin
    java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)
        at com.getcapacitor.Bridge$1.run(Bridge.java:526)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:237)
        at android.os.HandlerThread.run(HandlerThread.java:67)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
        at io.branch.referral.BranchUrlBuilder.<init>(BranchUrlBuilder.java:56)
        at io.branch.referral.BranchShortLinkBuilder.<init>(BranchShortLinkBuilder.java:15)

I adjusted my app like mentioned in the Android setup: https://github.com/BranchMetrics/capacitor-branch-deep-links#android-setup

After adding

activity = getActivity();

to BranchDeepLinks.java it works again

@tafelnl
Copy link
Contributor

tafelnl commented Dec 1, 2020

It could probably happen when calling one or more of the following methods: showShareSheet, generateShortUrl and sendBranchEvent. These methods do not necessarily make sure to instantiate the activity variable.

It is because of this commit: 0dbd399#diff-7dcd608548c6c4277db3aa21fca44b202ff712b42548c381870ce930e3262659

You can see this.activity = getActivity(); has been deleted. So adding that will indeed fix the issue. Feel free to make a pull request for this. Branch will probably merge it sometime in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants