1

When i am try to share my directory image via share plug in ! Image is not going to share ! Asking me permission what is that ??? Can any one give me solution on it

    FlatButton(
           onPressed: () async {
            Directory dir = await getApplicationDocumentsDirectory();
            File testFile = new File("${dir.path}/image.png");
            FlutterShareFile.shareImage(dir.path, "image.png", ShareFileType.image);
          },
        )

I am getting this type of warning :

E/DatabaseUtils( 8123): java.lang.SecurityException: Permission Denial: reading androidx.core.content.FileProvider uri content://com.photogranth.watermark.contentprovider/images/image.png from pid=6574, uid=1000 requires the provider be exported, or grantUriPermission() E/DatabaseUtils( 8123): at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:742) E/DatabaseUtils( 8123): at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:615) E/DatabaseUtils( 8123): at android.content.ContentProvider$Transport.enforceFilePermission(ContentProvider.java:606) E/DatabaseUtils( 8123): at android.content.ContentProvider$Transport.openTypedAssetFile(ContentProvider.java:520) E/DatabaseUtils( 8123): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:307) E/DatabaseUtils( 8123): at android.os.Binder.execTransactInternal(Binder.java:1021) E/DatabaseUtils( 8123): at android.os.Binder.execTransact(Binder.java:994)

Raees Khatib
  • 63
  • 11

1 Answers1

1

Did you add this to your AndroidManifest.xml file?

<application>
...
<provider
    android:name="androidx.core.content.FileProvider"
    android:authorities="${applicationId}.provider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/provider_paths"/>
</provider>
</application>
Huthaifa Muayyad
  • 11,321
  • 3
  • 17
  • 49
  • yes i added this code unfourtunetlly error comes again ===>> * What went wrong: Task 'assembleAarRelease' not found in root project 'flutter_plugin_android_lifecycle'. * Try: Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 0s Exception: The plugin flutter_plugin_android_lifecycle could not be built due to the issue above. – Raees Khatib Mar 27 '21 at 07:28
  • where are you adding this to your XML, this error `'assembleAarRelease' not found in root project` sometimes it means having it in the wrong place. Also, go to your `compileSdkVersion` in build.gradle `compileSdkVersion to 30` or 29, instead of 28 if it's 28. Report back please on what happens. – Huthaifa Muayyad Mar 27 '21 at 07:34
  • here is my xml : – Raees Khatib Mar 27 '21 at 08:17
  • Look into this post https://stackoverflow.com/questions/30790768/using-applicationid-in-library-manifest and see please – Huthaifa Muayyad Mar 27 '21 at 08:24