EddyVerbruggen / SocialSharing-PhoneGap-Plugin

👨‍❤️‍💋‍👨 Cordova plugin to share text, a file (image/PDF/..), or a URL (or all three) via the native sharing widget
MIT License
1.78k stars 905 forks source link

Android app crashed when share through email #1213

Open phihungnv opened 11 months ago

phihungnv commented 11 months ago

14403-14484/com.xxx E/AndroidRuntime: FATAL EXCEPTION: pool-2-thread-1 Process: com.xxx, PID: 14403 java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1 at java.util.ArrayList.remove(ArrayList.java:506) at nl.xservices.plugins.SocialSharing$1.run(SocialSharing.java:199) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) at java.lang.Thread.run(Thread.java:1012)

andrerds commented 10 months ago

I'm facing the same issue. Does anyone have any suggestions to fix it? :(.

EYALIN commented 10 months ago

@phihungnv @andrerds it looks like you don't have any email app installed maybe

andrerds commented 10 months ago

Hi,

I was able to make the app work, but I haven't been able to test it on different versions of Android yet.

Here is a possible solution, which is not definitive, but it stopped the app from crashing for me.

On line 167, I added a check:

if(fileUris.isEmpty()){ return; }

As I said, it is not a definitive solution, but it stopped the app from crashing on Android 12.

I will continue testing the app on different versions of Android to see if I can find a more definitive solution.

andrerds commented 10 months ago

file fix in : SocialSharing.java

acosme commented 9 months ago

Solved this fixing the issues in this pr:

https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/pull/1206/files

tested in android 13

Dan890 commented 8 months ago

@acosme and @andrerds the solutions below not fixed in my app.

still crush on android 12

kiozer001 commented 3 months ago

@Dan890 @andrerds @acosme @phihungnv creo que he resuelto el problema, Solo agregue en el Androidanifest.xml lo siguiente

<queries>
    <package android:name="com.google.android.gm" />
    <package android:name="com.microsoft.office.outlook" />
</queries>

Esto nos permita que la aplicacion nos deje elegir entre el app de gmail o la de outlook, en caso de que se requiera que aparezca otra aplicación de correo, se necesitara agregar tambien el nombre del paquete que se requiera