Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

android 13,open apk crash #44

Closed
ZhangHuay opened this issue Jul 14, 2023 · 4 comments
Closed

android 13,open apk crash #44

ZhangHuay opened this issue Jul 14, 2023 · 4 comments
Assignees
Labels
bug Something isn't working invalid This doesn't seem right wontfix This will not be worked on

Comments

@ZhangHuay
Copy link

Describe the bug
Real machine running, android 13, use FileOpener.open to open the apk file crashes

To Reproduce

import { FileOpener } from "@capacitor-community/file-opener";
FileOpener.open({
path:path,#path is the real path file:///data/user/0/...../app.release.apk
contentType: 'application/octet-stream',
})

You can find this apk in the directory but The calling method will return to the desktop

Smartphone (please complete the following information):

  • Device: [open find X3 pro]
  • OS: [android 13]
  • @capacitor-community/file-opener:^1.0.5
@ryaa ryaa self-assigned this Jul 14, 2023
@kfvv
Copy link

kfvv commented Jul 19, 2023

I've got the same issue while trying to open a file on my physical android device. I've tested it also in iOS but that seems to work fine.

import { FileOpener } from '@capacitor-community/file-opener'
FileOpener.open({ filePath: localUrl, contentType: filetype })

the localUrl is an pdf hosted on our internal server. the contentType is application/pdf. The device crashes and returns to the desktop/home when trying to open the file. When I try to open a local image, I get the same result.

It seems like there's a NullPointerException from line 33 from FileOpenerPlugin.java
File file = new File(fileName);
The android terminal gives the following error:

E/Capacitor: 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:774)
        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:942)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.os.HandlerThread.run(HandlerThread.java:67)
     Caused by: java.lang.NullPointerException
        at java.io.File.<init>(File.java:283)
        at com.ryltsov.alex.plugins.file.opener.FileOpenerPlugin.open(FileOpenerPlugin.java:33)
        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:774) 
        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:942) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loopOnce(Looper.java:226) 
        at android.os.Looper.loop(Looper.java:313) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 
E/AndroidRuntime: FATAL EXCEPTION: CapacitorPlugins
    Process: nl.leaseplan.berijdersapp, PID: 8597
    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:783)
        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:942)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        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:774)
        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:942) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loopOnce(Looper.java:226) 
        at android.os.Looper.loop(Looper.java:313) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 
     Caused by: java.lang.NullPointerException
        at java.io.File.<init>(File.java:283)
        at com.ryltsov.alex.plugins.file.opener.FileOpenerPlugin.open(FileOpenerPlugin.java:33)
        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:774) 
        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:942) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loopOnce(Looper.java:226) 
        at android.os.Looper.loop(Looper.java:313) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 

Smartphone (please complete the following information):

  • Device: Galaxy A71
  • OS: [android 13]
  • @capacitor-community/file-opener:^1.0.5

@ryaa ryaa added the bug Something isn't working label Jul 24, 2023
@ryaa
Copy link
Member

ryaa commented Jul 24, 2023

Real machine running, android 13, use FileOpener.open to open the apk file crashes

@ZhangHuay The problem is that you are passing the wrong param. The parameter with the file path is filePath and not path and since the plugin is not provided the required parameter, it crashes.

@ryaa
Copy link
Member

ryaa commented Jul 24, 2023

It seems like there's a NullPointerException from line 33 from FileOpenerPlugin.java

@kfvv NullPointerException will be thrown if the filePath parameter passed to open plugin method is null (see https://github.com/capacitor-community/file-opener/blob/master/android/src/main/java/com/ryltsov/alex/plugins/file/opener/FileOpenerPlugin.java#L33 and https://docs.oracle.com/javase/8/docs/api/java/io/File.html#File-java.lang.String-)

Please make sure that you provide filePath parameter with the right value. If you believe that you have provided the right value to the param, please provide more details (ideally, the repo in the github demonstrating the problem).

@ryaa
Copy link
Member

ryaa commented Jul 24, 2023

Closing as this is not the plugin problem. Added this #46 to avoid plugin/app crash if require param(s) are not provided.

@ryaa ryaa closed this as completed Jul 24, 2023
@ryaa ryaa added invalid This doesn't seem right wontfix This will not be worked on labels Jul 24, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working invalid This doesn't seem right wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants