Closed arbaaz360 closed 1 year ago
facing same issue with all platforms. Any Updates ?
Hi, I-m affected by this issue too.
I read about this exception in other libraries too, so waiting for someone to solve it...
You can check if you had made any mistake in configuring You can check from README.md of this repo
For me it solved by adding,
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.clear();
}
to MainActivity.java
just after OnCreate()
function.
Like This :-
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializes the Bridge
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(FileSharerPlugin.class);
}});
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.clear();
}
}
Leave Comment, if it solves or not
Thank you for answering, but I-m afraid it didn't.
I already had that override on my MainActivity.java, the issue is not happening on a physical device running Android < 10
I also tried to add <application android:requestLegacyExternalStorage="true" ...> to my Manifest as I saw somewhere (apparently related to this issue), obviously no luck either
I released the new version 3.0.0
today.
If you can and it is still relevant please test this issue with the new version. (Capacitor 3.0.0 required)
I keep this issue open a few days and close it afterwards if there is no feedback.
BR Michael
Howdy @moberwasserlechner, I too am facing this issue when sharing to Instagram. Instagram is opened successfully with the correct data, however, upon returning the app, it crashes.
@moberwasserlechner I am facing the same issue:
2022-05-01 02:03:11.328 2157-2450/com.company.appName E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading com.byteowls.capacitor.filesharer.FileSharerProvider uri content://com.company.appName.filesharer.fileprovider/capfilesharer/appName-Sunday-2022%2005%201_02%203%2009_GMT8.jpg from pid=31221, uid=1000 requires the provider be exported, or grantUriPermission()
at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:912)
at android.content.ContentProvider.semEnforceReadPermission(ContentProvider.java:830)
at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:708)
at android.content.ContentProvider$Transport.query(ContentProvider.java:247)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:107)
at android.os.Binder.execTransactInternal(Binder.java:1215)
at android.os.Binder.execTransact(Binder.java:1179)
2022-05-01 02:03:11.331 2157-2450/com.company.appName E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading com.byteowls.capacitor.filesharer.FileSharerProvider uri content://com.company.appName.filesharer.fileprovider/capfilesharer/appName-Sunday-2022%2005%201_02%203%2009_GMT8.jpg from pid=31221, uid=1000 requires the provider be exported, or grantUriPermission()
at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:912)
at android.content.ContentProvider.semEnforceReadPermission(ContentProvider.java:830)
at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:708)
at android.content.ContentProvider$Transport.enforceFilePermission(ContentProvider.java:698)
at android.content.ContentProvider$Transport.openTypedAssetFile(ContentProvider.java:557)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:327)
at android.os.Binder.execTransactInternal(Binder.java:1215)
at android.os.Binder.execTransact(Binder.java:1179)
this is my android manifest
<?xml version='1.0' encoding='utf-8'?>
<manifest package="com.company.appName" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="@string/admob_app_id" />
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/title_activity_main" android:launchMode="singleTask" android:name="com.company.appName.MainActivity" android:theme="@style/AppTheme.NoActionBarLaunch">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
</provider>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
and this is file_paths.xml
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="my_images" path="." />
<cache-path name="my_cache_images" path="." />
</paths>
looking at code I couldn't figure out the issue, maybe need to change androidx.core.content.FileProvider
package to android.support.v4.content.FileProvider
https://developer.android.com/reference/android/support/v4/content/FileProvider#ProviderDefinition
i'm using
"@byteowls/capacitor-filesharer": "^3.0.0",
and the device i'm testing on is android 12.0 API Level 31
@moberwasserlechner I am facing the same issue:
2022-05-01 02:03:11.328 2157-2450/com.company.appName E/DatabaseUtils: Writing exception to parcel java.lang.SecurityException: Permission Denial: reading com.byteowls.capacitor.filesharer.FileSharerProvider uri content://com.company.appName.filesharer.fileprovider/capfilesharer/appName-Sunday-2022%2005%201_02%203%2009_GMT8.jpg from pid=31221, uid=1000 requires the provider be exported, or grantUriPermission() at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:912) at android.content.ContentProvider.semEnforceReadPermission(ContentProvider.java:830) at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:708) at android.content.ContentProvider$Transport.query(ContentProvider.java:247) at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:107) at android.os.Binder.execTransactInternal(Binder.java:1215) at android.os.Binder.execTransact(Binder.java:1179) 2022-05-01 02:03:11.331 2157-2450/com.company.appName E/DatabaseUtils: Writing exception to parcel java.lang.SecurityException: Permission Denial: reading com.byteowls.capacitor.filesharer.FileSharerProvider uri content://com.company.appName.filesharer.fileprovider/capfilesharer/appName-Sunday-2022%2005%201_02%203%2009_GMT8.jpg from pid=31221, uid=1000 requires the provider be exported, or grantUriPermission() at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:912) at android.content.ContentProvider.semEnforceReadPermission(ContentProvider.java:830) at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:708) at android.content.ContentProvider$Transport.enforceFilePermission(ContentProvider.java:698) at android.content.ContentProvider$Transport.openTypedAssetFile(ContentProvider.java:557) at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:327) at android.os.Binder.execTransactInternal(Binder.java:1215) at android.os.Binder.execTransact(Binder.java:1179)
this is my android manifest
<?xml version='1.0' encoding='utf-8'?> <manifest package="com.company.appName" xmlns:android="http://schemas.android.com/apk/res/android"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true"> <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="@string/admob_app_id" /> <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/title_activity_main" android:launchMode="singleTask" android:name="com.company.appName.MainActivity" android:theme="@style/AppTheme.NoActionBarLaunch"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <provider android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /> </provider> </application> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> </manifest>
and this is file_paths.xml
<?xml version="1.0" encoding="utf-8"?> <paths xmlns:android="http://schemas.android.com/apk/res/android"> <external-path name="my_images" path="." /> <cache-path name="my_cache_images" path="." /> </paths>
looking at code I couldn't figure out the issue, maybe need to change
androidx.core.content.FileProvider
package toandroid.support.v4.content.FileProvider
https://developer.android.com/reference/android/support/v4/content/FileProvider#ProviderDefinitioni'm using
"@byteowls/capacitor-filesharer": "^3.0.0",
and the device i'm testing on is android 12.0 API Level 31
Umm, You can try making a separate poc. Just featuring file sharing and Make Sure you do the setup carefully. I am saying this because i believe there is nothing wrong with the plugin.
Earlier, I also had issues with this plugin but after fixing a few errors i made while setting it up, I worked.
@KrishPro thanks, but what kind of bug did you have? it was in angular or android side? bcs both are building just fine and it happens only if I click on the sharing, even the try catch around the capacitor connection doesn't throw any exception and the only way to capture the error message is through logcat. since I posted almost every setting that I have in my application, could you point out where to look at? maybe I can give it a try and reinstall the package again, but looking at the setting, it's quite basic standard that doesn't look anything wrong with them
You can check if you had made any mistake in configuring You can check from README.md of this repo
For me it solved by adding,
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.clear(); }
to
MainActivity.java
just afterOnCreate()
function. Like This :-public class MainActivity extends BridgeActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initializes the Bridge this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{ // Additional plugins you've installed go here // Ex: add(TotallyAwesomePlugin.class); add(FileSharerPlugin.class); }}); } @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.clear(); } }
Leave Comment, if it solves or not
@KrishPro looking at this, it's not part of the ReadMe.md (anymore) and capacitor installation should take care of the installation, do I still need to add these stuffs?
See #25 And tell if my comments there solve the issue for you.
1) https://github.com/moberwasserlechner/capacitor-filesharer#platform-android 2) In my app's AndroidManifest I have a custom FileProvider configured
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
3) Current tests show that these permission should not be needed by the plugin but I'm only started to bring my app to Capacitor 4 (I know there is Cap5 but it's to much effort to do it right now).
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
4) Relates to #42 and #32. It seems to me that this issue mixes problems
Capacitor version:
Run
npx cap doctor
:Library version:
Your Plugin Configuration
Affected Platform(s):
Current Behavior
I am able to share files on WhatsApp without any problems except that after sharing the file if you press back, you don't get back to the app. The app has to be restarted.
Expected Behavior
Upon successful sharing of file on whatApp and then clicking on android back button , user should get back to the app. The app shouldnt crash and should be have to be started again.
Sample Code or Sample Application Repo
Reproduction Steps
Just share a picture via whatsapp and then get back to the app. You would find that it gets restarted.
Other Information
The following error gets logged in android studio console as soon as you click share: