Skip to content

image_picker and WRITE_EXTERNAL_STORAGE #63282

Closed

Description

@rlecheta

Hi, I work for a bank and the security doesn't allow the app to use the WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE.
I realized that this permission was added to the manifest of my app.
Is there a way to avoid this permission using the image_picker plugin?

Activity

  1. darshankawar commented on Aug 10, 2020

    @darshankawar
    Member

    Hi @rlecheta,
    What api level does your app target ?
    Per the plugin's official documentation, for api > 29, no configuration is required and for api <= 29, there's a flag android:requestLegacyExternalStorage="true".
    If you are on api <=29, you may try to set above flag to false and see if you see any issues while using the plugin.

  2. added
    in triagePresently being triaged by the triage team
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 10, 2020
  3. rlechetaudemy commented on Aug 10, 2020

    @rlechetaudemy

    Hi, with this flag:
    android:requestLegacyExternalStorage="false"

    My build never completes, it complains something about the cloud_firestore plugin:

    logs
    Launching lib/main.dart on Android SDK built for x86 in debug mode...
    Running Gradle task 'assembleDebug'...
    
    FAILURE: Build failed with an exception.
    
    What went wrong:
    Execution failed for task ':app:processDebugResources'.
    A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    Android resource linking failed
    android/app/src/main/AndroidManifest.xml:14:5-57:19: AAPT: error: attribute android:requestLegacyExternalStorage not found.
    
    Try:
    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 11s
    The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
    Running Gradle task 'assembleAarRelease'...
    Building plugin flutter_money_formatter...
    Running Gradle task 'assembleAarRelease'...
    ✓ Built build/app/outputs/repo.
    Building plugin cloud_firestore...
    Exception: The plugin cloud_firestore could not be built due to the issue above.

    In my build.gradle I have:
    minSdkVersion 21
    targetSdkVersion 29

  4. darshankawar commented on Aug 11, 2020

    @darshankawar
    Member

    Hi @rlecheta @rlechetaudemy (assuming you are same person with different usernames)with WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE entries intact in manifest file, do you get any error while building or does it prohibit to use image_picker plugin ?

  5. rlecheta commented on Aug 11, 2020

    @rlecheta
    Author

    Hi, it throws the same exception, with or without the WRITE/READ permissions. Now my manifest is like this and I got the same error:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="..."> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <application android:name="io.flutter.app.FlutterApplication" android:icon="@mipmap/ic_launcher" android:label="Gama Saúde" android:requestLegacyExternalStorage="false" >

  6. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 11, 2020
  7. darshankawar commented on Aug 12, 2020

    @darshankawar
    Member

    @rlecheta,
    Usually if you have minSdkVersion 21 and targetSdkVersion 29, then you won't explicitly need to specify the permissions in manifest.
    I am on same settings and tried the official image_picker plugin example on latest Stable (1.20.1). When I try to access gallery or camera, it by default asks you for the permission as below:

    63282

  8. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 12, 2020
  9. rlecheta commented on Aug 13, 2020

    @rlecheta
    Author

    Hi @darshankawar , sure it works like you explained. But please, read again what I explain in the first post.
    The problem is that I didn't put the WRITE/READ permission in my Manifest, but during the manifest merge, the plugin put it there. If you Analyse your apk, you are going to see both permissions there, even if you don't wanna it.
    My app doesn't pass the security requirements of my company because that.
    It's very important that Flutter plugins doesn't put any unnecessary permissions on the Manifest if they are not necessary.
    And finally, we are talking about some official plugin.

  10. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 13, 2020
  11. darshankawar commented on Aug 14, 2020

    @darshankawar
    Member

    This will probably need for analysis, so keeping this issue open.

  12. TahaTesser commented on Feb 11, 2021

    @TahaTesser
    Contributor

    Hi @rlecheta
    You can avoid this by using image_picker locally in your project and removing the permission line

    I don't think write permission would be removed from the package itself
    Closing as there is an easy solution to this. If you disagree, please write in the comments and I will reopen it.
    Thank you

  13. github-actions commented on Aug 5, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  14. locked as resolved and limited conversation to collaborators on Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    p: image_pickerThe Image Picker plugin.packageflutter/packages repository. See also p: labels.r: solvedIssue is closed as solved

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions