Obsolete
Status Update
Comments
dn...@google.com <dn...@google.com>
dn...@google.com <dn...@google.com> #3
Hi,
Can you provide the below requested information to better understand the issue:
Android build
Which Android build are you using? (e.g. KVT49L)
Device used
Which device did you use to reproduce this issue?
Steps to reproduce
What steps do others need to take in order to reproduce the issue themselves?
Frequency
How frequently does this issue occur? (e.g 100% of the time, 10% of the time)
Expected output
What do you expect to occur?
Current output
What do you see instead?
Can you provide the below requested information to better understand the issue:
Android build
Which Android build are you using? (e.g. KVT49L)
Device used
Which device did you use to reproduce this issue?
Steps to reproduce
What steps do others need to take in order to reproduce the issue themselves?
Frequency
How frequently does this issue occur? (e.g 100% of the time, 10% of the time)
Expected output
What do you expect to occur?
Current output
What do you see instead?
ko...@appcube.info <ko...@appcube.info> #4
You should really try to read and to understand the reported issue, bofore asking for the information - all information is already provided. It is a system limitation (actually IMHO a bug in the Android system, the build version and the device do not matter). My expectation is, that the FileProvider can be used to serve files from the app related directory created on the secondary external storage (like removable SD card). But this is not the case.
ContextCompat.getExternalFilesDirs() returns all directories that can be used for handling files on the external storage. But only the first directory in the list is supported by the FileProvider.
ContextCompat.getExternalFilesDirs() returns all directories that can be used for handling files on the external storage. But only the first directory in the list is supported by the FileProvider.
dn...@google.com <dn...@google.com> #5
Please provide complete source code to test this issue on android 7 build.
Also please provide bugreport to analyze this issue further.
Android bug report:
After reproducing the issue, navigate to developer settings, ensure ‘USB debugging’ is enabled, then enable ‘Bug report shortcut’. To take bug report, hold the power button and select the ‘Take bug report’ option.
Note: Please upload the files to google drive and share the folder to android-bugreport@google.com, then share the link here.
Also please provide bugreport to analyze this issue further.
Android bug report:
After reproducing the issue, navigate to developer settings, ensure ‘USB debugging’ is enabled, then enable ‘Bug report shortcut’. To take bug report, hold the power button and select the ‘Take bug report’ option.
Note: Please upload the files to google drive and share the folder to android-bugreport@google.com, then share the link here.
ko...@appcube.info <ko...@appcube.info> #6
dn...@google.com <dn...@google.com> #7
Can you please provide the device information on which you have tested?
Device used
Which device did you use to reproduce this issue?
Device used
Which device did you use to reproduce this issue?
ko...@appcube.info <ko...@appcube.info> #8
You can reproduce this issue on every device or AVD with a removable SD card.
dn...@google.com <dn...@google.com> #9
We are getting crash when i click on "SHARE FROM REMOVABLE SD CARD" button in AVD.
Can you please check this issue on AVD with latest sdk and let us know the observed results.
Also once you execute the scenario in AVD, please capture bugreport and share with us.
Android bug report:
After reproducing the issue, navigate to developer settings, ensure ‘USB debugging’ is enabled, then enable ‘Bug report shortcut’. To take bug report, hold the power button and select the ‘Take bug report’ option.
Note: Please upload the files to google drive and share the folder to android-bugreport@google.com, then share the link here.
Can you please check this issue on AVD with latest sdk and let us know the observed results.
Also once you execute the scenario in AVD, please capture bugreport and share with us.
Android bug report:
After reproducing the issue, navigate to developer settings, ensure ‘USB debugging’ is enabled, then enable ‘Bug report shortcut’. To take bug report, hold the power button and select the ‘Take bug report’ option.
Note: Please upload the files to google drive and share the folder to android-bugreport@google.com, then share the link here.
ko...@appcube.info <ko...@appcube.info> #10
"We are getting crash when i click on "SHARE FROM REMOVABLE SD CARD" button in AVD."
Nice, then you are able to reproduce the issue yourself and also capture the bug report with all needed information. The example code is also well documented, so your colleagues will have no problems to understand the issue.
Nice, then you are able to reproduce the issue yourself and also capture the bug report with all needed information. The example code is also well documented, so your colleagues will have no problems to understand the issue.
dn...@google.com <dn...@google.com> #11
We have passed this defect on to the development team and will update this issue with more information as it becomes available.
da...@gmail.com <da...@gmail.com> #12
I have the same issue. Did anyone fix it?
cc...@derago.de <cc...@derago.de> #13
we have the same problem in our app. Hope there will be a fix soon.
ci...@gmail.com <ci...@gmail.com> #14
NO fix yet? I'm facing the same issue, cannot share audio files (recordings) from the secondary storage (SD card) ...this is critical..please fix it. FileProvider has no support for Context.getExternalFilesDirs(null).get(1)
ha...@gmail.com <ha...@gmail.com> #15
I am facing the same problem and it seems to be very hard to create a workaround. One need to completely rewrite android.support.v4.content.FileProvider, because the important code resides within
private static PathStrategy parsePathStrategy(Context context, String authority)
The code is
File target = null;
if (TAG_ROOT_PATH.equals(tag)) {
target = DEVICE_ROOT;
...
} else if (TAG_EXTERNAL_FILES.equals(tag)) {
File[] externalFilesDirs = ContextCompat.getExternalFilesDirs(context, null);
if (externalFilesDirs.length > 0) {
target = externalFilesDirs[0];
}
...
}
Only the first entry in the array "File[] externalFilesDirs" is processed, which is wrong! Especially because the first entry of "External"FilesDir on all my test devices is the "internal" phone storage. But I want to provide also content from the external SD card using "FileProvider.getUriForFile()".
In a quick-and-dirty-hack I cloned the FileProvider code and replace the above code by:
} else if (TAG_EXTERNAL_FILES.equals(tag)) {
File[] externalFilesDirs = ContextCompat.getExternalFilesDirs(context, null);
if (externalFilesDirs.length > 0) {
target = externalFilesDirs[0];
if (externalFilesDirs.length > 1) {
for (int i = 1; i < externalFilesDirs.length; i++) {
File target2 = externalFilesDirs[i];
if (Integer.toString(i).equals(path)) {
strat.addRoot(name, buildPath(target2, "."));
target = null;
}
}
}
}
}
Then I changed my "provider_paths.xml" to:
<paths xmlns:android="http://schemas.android.com/apk/res/android ">
<external-path name="external" />
<files-path name="app_files" />
<external-files-path name="app_external0" />
<external-files-path name="app_external1" path="1" />
</paths>
Now it works, as I would expect it:
- One can define multiple "external-files-path" with different names for different volumes.
In the mRoots HashMap then we'll have:
external /storage/emulated/0
app_files /data/user/0/com.mydomain.myapp/files
app_external0 = /storage/emulated/0/Android/data/com.mydomain.myapp/files
app_external1 = /storage/0123-4567/Android/data/com.mydomain.myapp/files
The only change, you have to make is to find a proper syntax for this. If
private static PathStrategy parsePathStrategy(Context context, String authority)
The code is
File target = null;
if (TAG_ROOT_PATH.equals(tag)) {
target = DEVICE_ROOT;
...
} else if (TAG_EXTERNAL_FILES.equals(tag)) {
File[] externalFilesDirs = ContextCompat.getExternalFilesDirs(context, null);
if (externalFilesDirs.length > 0) {
target = externalFilesDirs[0];
}
...
}
Only the first entry in the array "File[] externalFilesDirs" is processed, which is wrong! Especially because the first entry of "External"FilesDir on all my test devices is the "internal" phone storage. But I want to provide also content from the external SD card using "FileProvider.getUriForFile()".
In a quick-and-dirty-hack I cloned the FileProvider code and replace the above code by:
} else if (TAG_EXTERNAL_FILES.equals(tag)) {
File[] externalFilesDirs = ContextCompat.getExternalFilesDirs(context, null);
if (externalFilesDirs.length > 0) {
target = externalFilesDirs[0];
if (externalFilesDirs.length > 1) {
for (int i = 1; i < externalFilesDirs.length; i++) {
File target2 = externalFilesDirs[i];
if (Integer.toString(i).equals(path)) {
strat.addRoot(name, buildPath(target2, "."));
target = null;
}
}
}
}
}
Then I changed my "provider_paths.xml" to:
<paths xmlns:android="
<external-path name="external" />
<files-path name="app_files" />
<external-files-path name="app_external0" />
<external-files-path name="app_external1" path="1" />
</paths>
Now it works, as I would expect it:
- One can define multiple "external-files-path" with different names for different volumes.
In the mRoots HashMap then we'll have:
external /storage/emulated/0
app_files /data/user/0/com.mydomain.myapp/files
app_external0 = /storage/emulated/0/Android/data/com.mydomain.myapp/files
app_external1 = /storage/0123-4567/Android/data/com.mydomain.myapp/files
The only change, you have to make is to find a proper syntax for this. If
[Deleted User] <[Deleted User]> #16
I have the same issue! Where is the fix?
ob...@gmail.com <ob...@gmail.com> #17
+1 I want it fixed too! :]
gr...@gmail.com <gr...@gmail.com> #18
+1 I have the same problem in my app.
ph...@sprylab.com <ph...@sprylab.com> #19
wa...@gmail.com <wa...@gmail.com> #20
Hey guys, after reading the FileProvider source code, there is a special tag not covered in official reference.
And use this tag, you can serve files at everywhere.
Just add this line to your fileprovider xml.
<root-path name="root" path="." />
And use this tag, you can serve files at everywhere.
Just add this line to your fileprovider xml.
<root-path name="root" path="." />
ci...@gmail.com <ci...@gmail.com> #21
No news yet? I'm wandering if using scoped directory access shouldn't be an alternate solution...Very strange and very disturbing that there is no feedback yet from Google team on this subject. If they don't want to allow FileProvider to support files on removable storage, than they should tell us what solution exists for a developer to make his app be able to share files that it creates in its own private space on removable SD card.
is...@google.com <is...@google.com>
su...@gmail.com <su...@gmail.com> #22
Please do something, please. I don't know why it's so hard for Google team to fix this bug. Since January 2017 and still be "new". It's really a big bug.
am...@gmail.com <am...@gmail.com> #23
Having the same problem. As some people suggested using
<root-path name="root" path="." /> solve the issue, however, is not elegant. Since apparently the FileProvider will serve any file under the app domain. Also it may break in future release.
<root-path name="root" path="." /> solve the issue, however, is not elegant. Since apparently the FileProvider will serve any file under the app domain. Also it may break in future release.
au...@gmail.com <au...@gmail.com> #24
Incredible to see this still not fixed after 2 years, even though a working solution has kindly been provided in #15 (thanks a lot) !!!
Using root-path may be fine in some cases but it will expose all the app files, which may be a problem for some apps.
Using root-path may be fine in some cases but it will expose all the app files, which may be a problem for some apps.
ma...@gmail.com <ma...@gmail.com> #25
Any news on this one?
This bug is really annoying ...
This bug is really annoying ...
ra...@google.com <ra...@google.com>
gu...@thegrizzlylabs.com <gu...@thegrizzlylabs.com> #26
What's the recommended way to serve files from secondary external storages with FileProvider?
Description
The current implementation of the FileProvider does not support <paths> elements for all directories returned by ContextCompat.getExternalFilesDirs() (only the first directory is supported).