moberwasserlechner / capacitor-filesharer

Capacitor plugin to download and share files for the Web, Android and iOS! Stop the war in Ukraine!
MIT License
82 stars 20 forks source link

Bug: NullPointerException in "handleOnActivityResult" #22

Closed carsten-klaffke closed 1 year ago

carsten-klaffke commented 3 years ago

From the crash reports in Google Play Console, I regularly see a NullPointerException in this Plugin.

Capacitor version:

@capacitor/cli 2.3.0 @capacitor/android 2.3.0 @capacitor/core 2.3.0 @capacitor/ios 2.3.0 @capacitor/electron not installed

java.lang.RuntimeException: 
  at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4053)
  at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:4085)
  at android.app.servertransaction.ResumeActivityItem.execute (ResumeActivityItem.java:51)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:145)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:70)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1984)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:216)
  at android.app.ActivityThread.main (ActivityThread.java:7211)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:975)
Caused by: java.lang.RuntimeException: 
  at android.app.ActivityThread.deliverResults (ActivityThread.java:4683)
  at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4042)
Caused by: java.lang.NullPointerException: 
  at com.byteowls.capacitor.filesharer.FileSharerPlugin.handleOnActivityResult (FileSharerPlugin.java:110)
  at com.getcapacitor.Bridge.onActivityResult (Bridge.java:771)
  at com.getcapacitor.BridgeActivity.onActivityResult (BridgeActivity.java:216)
  at android.app.Activity.dispatchActivityResult (Activity.java:7806)
  at android.app.ActivityThread.deliverResults (ActivityThread.java:4676)

It seems like the PluginCall returned from getSavedCall() can be null. Is this a known issue? Do you know how this situation can occur?

Library version:

Your Plugin Configuration

{
import {Plugins} from '@capacitor/core';
const {Share} = Plugins;

Plugins.FileSharer.share({
                                                filename: "mindlib-export.opml",
                                                base64Data: btoa(unescape(encodeURIComponent(result))),
                                                contentType: "text/plain",
                                            }) ...
}

Affected Platform(s):

moberwasserlechner commented 2 years ago

I released the new version 3.0.0 today

If you can and it is still relevant please test this issue with the new version. (Capacitor 3.0.0 required)

I keep this issue open a few days and close it afterwards if there is no feedback.

BR Michael

moberwasserlechner commented 1 year ago

Closed as outdated.