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

Solution for android app crashes when file too big #13

Closed FREEZX closed 4 years ago

FREEZX commented 4 years ago

I had issues with the android app crashing once the target app was chosen, with an error like this, even though the target app successfully got the image:

2019-09-22 15:11:26.442 5306-5306/com.ktrajkovski.gifer E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 4346876)
...
2019-09-22 15:11:27.822 5306-5306/com.ktrajkovski.gifer E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.ktrajkovski.gifer, PID: 5306
    java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 4346876 bytes
        at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3950)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: android.os.TransactionTooLargeException: data parcel size 4346876 bytes
        at android.os.BinderProxy.transactNative(Native Method)
        at android.os.BinderProxy.transact(Binder.java:764)
        at android.app.IActivityManager$Stub$Proxy.activityStopped(IActivityManager.java:4623)
        at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3934)

Solved it by adding:

  @Override
  public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.clear();
  }

to the main activity.

Hope someone with the same issue finds this useful. Perhaps this should also be added to the readme

moberwasserlechner commented 4 years ago

I would be happy to accept a PR for this.

You have the needed background knowledge, so it would be highly appreciated if you can add this to the readme and create a PR.

thx, Michael

Am 22.09.2019 um 15:26 schrieb Kristijan Trajkovski notifications@github.com:

I had issues with the android app crashing once the target app was chosen, with an error like this, even though the target app successfully got the image:

2019-09-22 15:11:26.442 5306-5306/com.ktrajkovski.gifer E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 4346876) ... 2019-09-22 15:11:27.822 5306-5306/com.ktrajkovski.gifer E/AndroidRuntime: FATAL EXCEPTION: main Process: com.ktrajkovski.gifer, PID: 5306 java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 4346876 bytes at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3950) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) Caused by: android.os.TransactionTooLargeException: data parcel size 4346876 bytes at android.os.BinderProxy.transactNative(Native Method) at android.os.BinderProxy.transact(Binder.java:764) at android.app.IActivityManager$Stub$Proxy.activityStopped(IActivityManager.java:4623) at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3934) Solved it by adding:

@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.clear(); } to the main activity.

Hope someone with the same issue finds this useful. Perhaps this should also be added to the readme

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

moberwasserlechner commented 4 years ago

PR is merged. Thx again.