Skip to content

[image_picker] No longer able to select photos from Google Photos #121744

Closed
flutter/packages
#3370

Description

@DanMossa

Steps to Reproduce

My Android device has updated to use the new Photo Picker (https://developer.android.com/training/data-storage/shared/photopicker)

I used to be able to view and select images from my google photos app or anywhere else, but now I'm only able to select an image that have been taken with this phone.

Expected results:
I expect to be able to still select an image from somewhere else on my device.

Actual results:
I can only select a photo from Photos or Albums. Albums only has Camera, Screenshots, and Downloads.

Code sample
    final imagePicker = ImagePicker();
    final XFile? pickedFile = await imagePicker.pickImage(
      source: ImageSource.gallery,
      requestFullMetadata: false,
    );
Logs
[!] Flutter (Channel stable, 3.7.3, on macOS 13.2 22D49 darwin-arm64, locale en-US)
    • Flutter version 3.7.3 on channel stable at /Users/daniel/fvm/versions/3.7.3
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/2.18.0/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/daniel/fvm/versions/3.7.3. Consider adding /Users/daniel/fvm/versions/3.7.3/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 9944297138 (3 weeks ago), 2023-02-08 15:46:04 -0800
    • Engine revision 248290d6d5
    • Dart version 2.19.2
    • DevTools version 2.20.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0-rc1)
    • Android SDK at /Users/daniel/Library/Android/sdk
    • Platform android-33, build-tools 32.0.0-rc1
    • Java binary at: /Users/daniel/.sdkman/candidates/java/current/bin/java
    • Java version OpenJDK Runtime Environment Temurin-17.0.4.1+1 (build 17.0.4.1+1)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (version 2022.1)
    • Android Studio at /Users/daniel/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9619390/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] IntelliJ IDEA Ultimate Edition (version 2022.3.2)
    • IntelliJ at /Users/daniel/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 71.3.6
    • Dart plugin version 223.8617.8

[✓] IntelliJ IDEA Ultimate Edition (version 2022.3.2)
    • IntelliJ at /Users/daniel/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/223.8617.56/IntelliJ IDEA.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.75.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.58.0

[✓] Connected device (3 available)
    • Pixel 7 Pro (mobile) • 2A211FDH300687            • android-arm64  • Android 13 (API 33)
    • iPhone (mobile)      • 00008020-001069A00A43002E • ios            • iOS 16.3.1 20D67
    • Chrome (web)         • chrome                    • web-javascript • Google Chrome 110.0.5481.177

[✓] HTTP Host Availability
    • All required HTTP hosts are available

Before After

Activity

  1. danagbemava-nc commented on Mar 2, 2023

    @danagbemava-nc
    Member

    Hi @DanMossa, I believe this is a limitation of the new Photo Picker on android 13 and not an issue with the plugin. I can't seem to find any API from the new picker that would allow that. Are you aware of any such API?

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 2, 2023
  3. DanMossa commented on Mar 2, 2023

    @DanMossa
    Author

    I appreciate the quick response! @danagbemava-nc
    Unfortunately I'm not familiar with the Android APIs. But I've been looking around and I'm wondering if any of these links help?

    https://developers.google.com/drive/picker/reference
    https://issuetracker.google.com/issues/264952941

    EDIT: I've noticed that when using an older image_picker, the issue doesn't happen.
    Works when my pubspec.lock shows

      image_picker:
        dependency: "direct main"
        description:
          name: image_picker
          sha256: f98d76672d309c8b7030c323b3394669e122d52b307d2bbd8d06bd70f5b2aabe
          url: "https://pub.dev"
        source: hosted
        version: "0.8.6+1"
      image_picker_android:
        dependency: transitive
        description:
          name: image_picker_android
          sha256: b1cbfec0f5aef427a18eb573f5445af8c9c568626bf3388553e40c263d3f7368
          url: "https://pub.dev"
        source: hosted
        version: "0.8.5+5"
    

    I was able to confirm that this issue happens once my pubspec.lock shows

      image_picker:
        dependency: "direct main"
        description:
          name: image_picker
          sha256: "715d68a53d6bcc2eae26005097dc74c375a04c0d7c0e657da84deebbbbbf51ed"
          url: "https://pub.dev"
        source: hosted
        version: "0.8.6+4"
      image_picker_android:
        dependency: transitive
        description:
          name: image_picker_android
          sha256: "845f793834d5d3af887ce39e3c97186996928cd43c8350a23e5499268398cc16"
          url: "https://pub.dev"
        source: hosted
        version: "0.8.5+8"
    

    This indicates that the issue comes from image_picker. Or at the least, this package shouldn't change that functionality until the Photo Picker is more mature.

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 2, 2023
  5. lukehutch commented on Mar 3, 2023

    @lukehutch
    Contributor

    I have the same issue. The app I'm developing used to present a view (via image_picker) that allowed me to choose images from either Drive or Google Photos, for the logged-in Google account. However, I made a bunch of changes to dependencies, and now suddenly when I rebuilt the app, the photo picker view only shows the following options:

    image

    I have no idea which change disabled the ability of image_picker to pick photos in Drive or Google Photos, but this is a major step back from the old functionality.

  6. lukehutch commented on Mar 3, 2023

    @lukehutch
    Contributor

    In my case, downgrading the dependency version from 0.8.6+3 to 0.8.6+1 did not solve the problem (and in fact I checked, and the version was 0.8.6+3 both before and after the file picker broke).

    At this point I have no idea how to restore the old behavior. Something changed in the project, and I have no idea what.

  7. DanMossa commented on Mar 3, 2023

    @DanMossa
    Author

    In my case, downgrading the dependency version from 0.8.6+3 to 0.8.6+1 did not solve the problem (and in fact I checked, and the version was 0.8.6+3 both before and after the file picker broke).

    At this point I have no idea how to restore the old behavior. Something changed in the project, and I have no idea what.

    Downgrading the dependency didn't actually help me either. I had to go into my pubspec.lock and revert the changes there. :/

  8. lukehutch commented on Mar 3, 2023

    @lukehutch
    Contributor

    @DanMossa Thanks, that worked for me too. (Now I finally understand what pubspec.lock does :-D )

    So this is indeed breakage in some recent version of image_picker.

  9. lukehutch commented on Mar 3, 2023

    @lukehutch
    Contributor

    The UI when things are working, for comparison:

    image

  10. danagbemava-nc commented on Mar 3, 2023

    @danagbemava-nc
    Member

    So this is indeed breakage in some recent versions of image_picker.

    Hi @lukehutch, technically, this is not a breakage. The plugin was recently updated to use the more privacy-focused photo picker of android 13 to fulfill the request in #104250. So you could say this is the correct behavior of the photo picker.

    This is the PR in question flutter/packages#3267.

    @DanMossa, since this is the intended behavior of the new photo picker API and will likely be the behavior going forward(according to https://issuetracker.google.com/issues/264952941#comment4), would it help if we documented that on newer versions of android users may not be able to access external image providers?

  11. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 3, 2023
  12. DanMossa commented on Mar 3, 2023

    @DanMossa
    Author

    So this is indeed breakage in some recent versions of image_picker.

    Hi @lukehutch, technically, this is not a breakage. The plugin was recently updated to use the more privacy-focused photo picker of android 13 to fulfill the request in #104250. So you could say this is the correct behavior of the photo picker.

    This is the PR in question flutter/packages#3267.

    @DanMossa, since this is the intended behavior of the new photo picker API and will likely be the behavior going forward(according to https://issuetracker.google.com/issues/264952941#comment4), would it help if we documented that on newer versions of android users may not be able to access external image providers?

    Yeah! I think it would be helpful to put in the changelog or something that this changes functionally until the photopicker implements an API to select external image providers.

    In an ideal world this would be a major version change.

  13. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 3, 2023
  14. self-assigned this
    on Mar 3, 2023
  15. tarrinneal commented on Mar 3, 2023

    @tarrinneal
    Contributor

    Thanks for raising this issue.

    We're going to add a config option to decide which version of the picker you would like to use while we wait for the cloud features to be added to the new image picker.

    This will default to the old version, so you shouldn't need to change anything to get this feature back.

  16. added
    P1High-priority issues at the top of the work list
    and removed
    in triagePresently being triaged by the triage team
    on Mar 3, 2023
  17. lukehutch commented on Mar 3, 2023

    @lukehutch
    Contributor

    How exactly does the new dialog improve privacy, especially if it is going to add back in the cloud features?

    +1 on making this configurable.

  18. stuartmorgan-g commented on Mar 3, 2023

    @stuartmorgan-g
    Contributor

    In my case, downgrading the dependency version from 0.8.6+3 to 0.8.6+1 did not solve the problem

    This is because the change is in image_picker_android (specifically 0.8.5+7 of that package), not image_picker. That's what you'd need to temporarily pin if you want to avoid the change for now.

  19. added
    packageflutter/packages repository. See also p: labels.
    a: pluginsSupport for writing, building, and running plugin packages
    on Mar 6, 2023
  20. removed
    a: pluginsSupport for writing, building, and running plugin packages
    on Mar 6, 2023
  21. added
    r: fixedIssue is closed as already fixed in a newer version
    on Mar 9, 2023
  22. github-actions commented on Mar 23, 2023

    @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.

  23. locked as resolved and limited conversation to collaborators on Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listp: image_pickerThe Image Picker plugin.packageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions