Skip to content

Filesystem copy android crash #2105

@massimoliani

Description

@massimoliani

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions