Closed krishnagopinath closed 4 years ago
Running into same issue on Android 10 Samsung Galaxy S10e.
@krishnagopinath @jefflnorton Did you find a solution for this? Maybe you can test whether it still happens with the latest 3.0.1 version
I have the same issue using 3.0.1 version. Any ideas?
Have you tested to see you can read from cordova.file.externalDataDirectory
? It might be that you do not have required rights to read from cordova.file.dataDirectory
I have the same issue using 3.0.1 version. Any ideas?
Do you have cordova-camera-plugin v4.2.0 installed? There might be a problem with this and camera plugin conflicting - see https://github.com/apache/cordova-plugin-camera/issues/597#issuecomment-627968308
I'm seeing the same issue on Android 9, using version 3.0.1 of the plugin.
I did have the cordova-camera-plugin installed, but removed it and still have the same problem.
Also tested with both cordova.file.externalDataDirectory
and cordova.file.dataDirectory
.
@galfert Did externalDataDirectory
work for you? When I tested this via the emulator it worked fine. I'm still experiencing issues with dataDirectory
.
The cordova-camera-plugin is installed in my case and is version 4.1.0 and it works fine when opening/saving images.
I looked into the Java source and xml for file paths and compared them with the solutions on stackoverflow. It looks ok but dunno why it's throwing the error.
Edit: I was able to fix it via removing the camera plugin reference in the manifest.xml. The dataDirectory
started to work. Going to use @ryaa's fork of the camera plugin. Looks like a provider conflict of some kind.
@galfert @pwlin I have researched the issue and find out that it is arises due to the cordova-plugin-camera
have the same authority
in the manifest file. It is needs just to update authority
in the FileOpener2.java
file and in the manifest.
FileOpener2.java
change all the strings from:
https://github.com/pwlin/cordova-plugin-file-opener2/blob/master/src/android/io/github/pwlin/cordova/plugins/fileopener2/FileOpener2.java#L119
https://github.com/pwlin/cordova-plugin-file-opener2/blob/master/src/android/io/github/pwlin/cordova/plugins/fileopener2/FileOpener2.java#L127...FileProvider.getUriForFile(context, cordova.getActivity().getPackageName() + ".provider", file);
to
... FileProvider.getUriForFile(context, cordova.getActivity().getPackageName() + ".fileOpener2.provider", file);
AndroidManifest.xml
from:
<provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="io.github.pwlin.cordova.plugins.fileopener2.FileProvider">
to
<provider android:authorities="${applicationId}.fileOpener2.provider" android:exported="false" android:grantUriPermissions="true" android:name="io.github.pwlin.cordova.plugins.fileopener2.FileProvider">
@pwlin I can create PR if needed
@AlexMiniApps Thanks for your findings. If you send a PR, I'll merge it right away.
@pwlin please review the PR https://github.com/pwlin/cordova-plugin-file-opener2/pull/302
@AlexMiniApps I have merged your PR and pushed a new version 3.0.3
to NPM. Can you please test it works?
@pwlin I have checked. It works. Thanks!
I can confirm it to be working as well now. Thanks a lot!
Expected Behaviour
PDF file must open in a PDF reader app that's installed in the Android phone.
Actual Behaviour
An error is thrown when
cordova.plugins.fileOpener2.open
is invoked with the PDF path.This is code snippet I use to open the file:
The file definitely exists:
The manifest file (
platforms/android/app/src/main/AndroidManifest.xml
) contains the following snippet as expected:I checked existed issues #225 , #195 and #98 . None of the solutions listed worked for me 😢
Platform and Version (eg. Android 5.0 or iOS 9.2.1)
Android 10
(Android) What device vendor (e.g. Samsung, HTC, Sony...)
Google Pixel 2
Cordova CLI info
Plugin version
I installed the plugin via github, because
npm
did not have v3.0.0Other Relevant plugins that I have installed: