capacitor-plugins icon indicating copy to clipboard operation
capacitor-plugins copied to clipboard

Filesystem copy android crash

Open massimoliani opened this issue 1 year ago • 5 comments

Bug Report

Plugin(s)

Filesystem

Capacitor Version

Latest Dependencies:

  @capacitor/cli: 6.0.0
  @capacitor/core: 6.0.0
  @capacitor/android: 6.0.0
  @capacitor/ios: 6.0.0

Installed Dependencies:

  @capacitor/cli: 5.7.4
  @capacitor/android: 5.7.4
  @capacitor/ios: 5.7.4
  @capacitor/core: 5.7.4

Platform(s)

Android

Current Behavior

If you try to copy a content:/.... file to local app folder the app crash.

Expected Behavior

I excpect to be able to copy a content:/... file (like image or video) like a normal file:/.... path.

Code Reproduction

file.path is a native path like content:/.... file.name the name of the file

        let inputFile = encodeURI(file.path);
        let outputFile = ("media-store/file.name).replace(/ /g, "_");
        Filesystem.copy({
          from: inputFile,
          to: outputFile,
          toDirectory: Directory.Data,
        })

Other Technical Details

I test it on API30 and API33 but the result is the same. Simulator or physical device same result. A content:/.... file can execute: stat, read functions of Filesystem plugin, only copy crash.

Additional Context

Serious error executing plugin java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:138) at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:800) at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0) at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference at com.capacitorjs.plugins.filesystem.Filesystem.getDirectory(Filesystem.java:203) at com.capacitorjs.plugins.filesystem.Filesystem.getFileObject(Filesystem.java:227) at com.capacitorjs.plugins.filesystem.Filesystem.copy(Filesystem.java:109) at com.capacitorjs.plugins.filesystem.FilesystemPlugin._copy(FilesystemPlugin.java:430) at com.capacitorjs.plugins.filesystem.FilesystemPlugin.copy(FilesystemPlugin.java:381) at java.lang.reflect.Method.invoke(Native Method) at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:138) at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:800) at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0) at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.os.HandlerThread.run(HandlerThread.java:67) 2024-04-18 22:57:35.221 21631-21924 AndroidRuntime it.skirankapp.official E FATAL EXCEPTION: CapacitorPlugins Process: it.skirankapp.official, PID: 21631 java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:809) at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0) at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:138) at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:800) at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0) at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference at com.capacitorjs.plugins.filesystem.Filesystem.getDirectory(Filesystem.java:203) at com.capacitorjs.plugins.filesystem.Filesystem.getFileObject(Filesystem.java:227) at com.capacitorjs.plugins.filesystem.Filesystem.copy(Filesystem.java:109) at com.capacitorjs.plugins.filesystem.FilesystemPlugin._copy(FilesystemPlugin.java:430) at com.capacitorjs.plugins.filesystem.FilesystemPlugin.copy(FilesystemPlugin.java:381) at java.lang.reflect.Method.invoke(Native Method) at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:138) at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:800) at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0) at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.os.HandlerThread.run(HandlerThread.java:67)

massimoliani avatar May 14 '24 11:05 massimoliani

Hi i'm having the same issue ! It crashes the app when i call the copy() method :(

Here is my code :

await Filesystem.copy({ from: media.path, to: singleUUid + "." + mediaType, toDirectory: Directory.Cache });
const mediaData = await Filesystem.readFile({ path: singleUUid + "." + mediaType, directory: Directory.Cache });
base64Data = `data:${media.mimeType};base64,${mediaData.data}`;
await Filesystem.deleteFile({ path: singleUUid + "." + mediaType, directory: Directory.Cache });

And here are my crash logs as a .txt file : https://nopaste.net/JI1WX24Dr3

maximilien0405 avatar May 18 '24 21:05 maximilien0405

Any news on this issue ? This is kind of a big deal :/

maximilien0405 avatar May 27 '24 11:05 maximilien0405

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed.

Please see the Contributing Guide for how to create a Sample App.

Thanks! Ionitron 💙

Ionitron avatar Jun 07 '24 15:06 Ionitron

Dear Ionitron here the link to public github repository to test the issue: https://github.com/massimoliani/fscopy-crash.git

In the README.md you can find additional info on test procedure.

massimoliani avatar Jun 09 '24 10:06 massimoliani