-
Notifications
You must be signed in to change notification settings - Fork 760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Critical Issue: not working with external sdcard on phones like Samsung A7, A20, Note8, Huawei etc #350
Comments
Are you able to provide a minimal sample reproduction app without ionic to reproduce this issue? https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md Thanks. |
@breautek Here is a link to repository having reproduction sample. This is an issue with smartphones like Samsung A7, A20, Note8, Huawei etc I have used 3 cordova plugins to achieve this feature:
Platform Info: This is my code: var btnChooseFile = document.getElementById('chooseFile');
|
Thanks, I think this will help. I won't be able to test today because I dont have a phone with an sd card slot. But I'll try to spend a few minutes to at least identify the fault in my workplace on monday where I have access to other phones. One other note though, I read other tickets that have a similar issue as you, and it was due to a missing permission declaration. In the meantime, I'd advise you to check your Sorry for being a bit vague in what to look for, I don't have a laptop in front of me at the moment. Alternatively, you can paste the 'AndroidManifest.xml` here so that I can take a look. |
Here is my AndroidManifest.xml file and i can see read & write permission is there
|
Unfortunately I'm unable to reproduce the issue using an emulator or any real devices that I have access to. This doesn't mean the issue doesn't exist obviously, My devices that have an SD card slot are old and aren't running the same OS version as you. This issue may be device specific. I was using the test app that you provided to do my tests. Also worth noting that on my device, the sdcard path looks like |
Hello @breautek , I have tested the same app on Xiaomi M1 A1 having AndroidOne OS and getting the same issue while resolving local file system URL by (resolveLocalFileSystemURL). Even getting same issue on Samsung A7, A20, Note8, Huawei etc But the twist is here that, I was testing day before yesterday and it was working file but now it is not working. The native URL i am getting is the same as before but when i am resolving native URL by resolveLocalFileSystemURL to get fileentry, it is throwing error NOT_FOUND error code 1. Even the app has storage permissions (Read & Write), but still not able to access it. Second thing is very interesting, let me explain you in detail. Now try to access that file. when you select file from external storage (sdcard), it will give native URL like file:///sdcard/image2.png and it will not be resolvable by resolveLocalFileSystemURL function. Now change the file name in internal storage from image1.png to image2.png. When you select file from external storage you will get same native URL file:///sdcard/image1.png, but now it will be resolvable by resolveLocalFileSystemURL The conclusion is resolveLocalFileSystemURL is searching file only in internal storage even if the path is different. But it was supposed to search file on external storage (sdcard). I am searching for a solution. Please help me bro. |
Ok so, if I understand correctly, the issue occurs when you have 2 identical filenames, one on the internal storage, and the other on the external storage. Then if you use In my testing, my sdcard/internal storage definitely didn't had two of the same files with the files I was testing with. So later tonight I can try again with this kind of environment. |
No i mean to say, if you have same file on internal or external device storage then it will work because in the both the cases resolveLocalFileSystemURL is searching only in internal storage. If you don't have same file on external or internal then it will not work. It will work only if you are selecting file from internal storage. The conclusion is, in both the cases it is not working at all with external storage. Just now i have tested it on Galaxy Note3 and it is working fine. It is giving me this file:///storage/extSdCard/ URL for external storage files. |
On my device that has an sdcard slot, this is what the path also looks like for me. I'm not familiar with this codebase, but I'll take a look to see if I can find any bad assumptions... But I can only do this later tonight unfortunately. Of course you are more than welcome to poke around the native code yourself and add logging to the native code to try to find any discrepancies between the phones that do work vs the phones that don't work. So far the pattern appears to be phones that provide a The method in question is located at
This is probably the area of interest: cordova-plugin-file/src/android/FileUtils.java Lines 721 to 735 in 74a4646
If it doesn't enter the |
I am not sure about that, I think file:///sdcard & file:///storage/extSdCard/ both are working but on few devices resolveLocalFileSystemURL throwing an error NOT_FOUND. |
This issue may be related to https://issues.apache.org/jira/browse/CB-10883 Which has a pending PR for a fix for #173, but currently it is in a conflicted state and had no activity for a year. The Jira issue states that this is an issue starting from Android 6 and above, which will explain why I couldn't reproduce the issue on my test device. I found my work's android 6 device, so I'll bring that home tonight and test using that device. |
Just tested with the Samsung Galaxy s5, running Android 6. I have a sopy of images stored in both the internal storage and sd card but I'm still unable to reproduce the issue. Internal storage path: SD Card: |
@azizbohra You can try running logcat to find out more information Perhaps using:
Which will silent all logs except for warnings and errors. You can also look in the source files for
|
Hello i am sharing the logs here, but i don't think this logs contains anything related to this issue. |
Logs when selecting from internal storage 10-05 09:39:18.934 570 617 E ANDR-PERF-MPCTL: Invalid profile no. 0, total profiles 0 only Logs when selecting files from sdcard 10-05 09:41:57.976 570 617 E ANDR-PERF-OPTSHANDLER: Perflock resource /sys/class/devfreq/soc:qcom,llccbw/min_freq not supported |
I have test this paid plugin even that is also not working |
By the looks of that plugin, it doesn't appear to handle external storage whatsoever, or at least it lacks declaring the required permissions to use external storage. Afraid to say I don't think I can be much help unless if I can reproduce this issue, and with all my devices at disposal that just doesn't happen. Afaik these issues are device specific. Later tonight if I find time I'll try to use a virtual external storage on my Android 9 phone to see if it gets reproduced then. But if it doesn't, then I'm out of ideas... And to acknowledge your logs, I don't see anything interesting either... |
Stumbled across this issue aswell. Any new information here? |
Was this ever fixed? I have this same problem, When I try to check if a file exist on the SD card it always returns "not found" Tested with a Motorola Moto G5 with Android 8 Path example: |
Same here. Has anyone found a fix? Cannot find a solution |
Hi , i am using one+ 6 mobile with the latest os. and encounter my application is not able to read files with the same issue? tried on OnePluse5,6,6T all phone however it's not working any fix so far ?? |
Bug Report
Critical Issue. Need a solution. Please help me guys.
Problem
This plugin works perfectly with internal storage. But on some of the smartphones like Samsung A7 & one Huawei, it is not working with the external sdcard. Even after giving external storage path, it is always searching on internal storage.
What is expected to happen?
It should work with internal storage as well as external sdcard storage
What does actually happen?
Not working with external sdcard storage. Even after giving external storage path, it is always searching on internal storage.
Information
I have tested this plugin on Ionic1 project. Mount sdcard on your device. Check any file which exists on sdcard ($cordovaFile.checkFile), it will through error code 1 NOT_FOUND_ERR. Now copy same file on internal storage, it will work as expected. Because it is searching file only on internal storage not on external storage.
Command or Code
$cordovaFile.checkFile('file://sdcard/', "image.jpeg")
.then(function (success) {
// success
}, function (error) {
// error it will through error code 1 NOT_FOUND_ERR
});
Environment, Platform, Device
Ionic1
Samsung A7, Huawei
The text was updated successfully, but these errors were encountered: