aarajput / wc_flutter_share

A Flutter plugin for sharing files & text with other applications.
Apache License 2.0
35 stars 19 forks source link

Permission Denial #12

Closed jonjon1123 closed 4 years ago

jonjon1123 commented 4 years ago

I am getting the following exception on Android when using this library:

E/DatabaseUtils(20807): java.lang.SecurityException: Permission Denial: reading com.wisecrab.wc_flutter_share.WcFlutterShareFileProvider uri content://app.bowlr.fileprovider.github.com%2Fcom%2Fwisecrab%2Fwc-flutter-share/files/bowlr-support-data-2020-03-08-09-03-26.txt from pid=19698, uid=1000 requires the provider be exported, or grantUriPermission()
E/DatabaseUtils(20807):     at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:729)
E/DatabaseUtils(20807):     at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:602)
E/DatabaseUtils(20807):     at android.content.ContentProvider$Transport.query(ContentProvider.java:231)
E/DatabaseUtils(20807):     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:104)
E/DatabaseUtils(20807):     at android.os.Binder.execTransactInternal(Binder.java:1021)
E/DatabaseUtils(20807):     at android.os.Binder.execTransact(Binder.java:994)

It seems like the library is not requesting permissions correctly. If I go into the system-level app settings and grant the app storage permissions everything works fine.

aarajput commented 4 years ago

Can you please show me your manifest file?

MaskyS commented 4 years ago

Possibly related: https://github.com/flutter/plugins/pull/970#issuecomment-600528306

jonjon1123 commented 4 years ago

@aarajput I am assuming you mean my AndroidManifest.xml file. If so, here it is:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="app.com">

    <!-- The INTERNET permission is required for development. Specifically,
         flutter needs it to communicate with the running application
         to allow setting breakpoints, to provide hot reload, etc.
    -->
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="App"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- This keeps the window background of the activity showing
                 until Flutter renders its first frame. It can be removed if
                 there is no splash screen (such as the default splash screen
                 defined in @style/LaunchTheme). -->
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <meta-data android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id"/>

        <activity android:name="com.facebook.FacebookActivity"
            android:configChanges=
                    "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name" />

        <activity
            android:name="com.facebook.CustomTabActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="@string/fb_login_protocol_scheme" />
            </intent-filter>
        </activity>
    </application>
</manifest>
9thwall commented 4 years ago

I'm having the exact same issue here. Was this closed without a fix?

aarajput commented 4 years ago

It could be because your merged manifest has multiple providers.

aarajput commented 4 years ago

Thank you @stonega for your contribution. I have released 0.2.2 version with your fix.

stonega commented 4 years ago

Thank you @stonega for your contribution. I have released 0.2.2 version with your fix.

Thanks!