Automatic install of the backported version of the Android Photo Picker not playing nicely with Android Studio
Asked Answered
I

2

37

I'm trying to implement the new Android Photo Picker but I'm running into an issue when trying to setup the automatic install of the backported photo picker module on older devices.

According to the docs we need to add the following to our app's manifest file to allow this:

<!-- Trigger Google Play services to install the backported photo picker module -->
<service android:name="com.google.android.gms.metadata.ModuleDependencies"
         android:enabled="false"
         android:exported="false">
    <intent-filter>
        <action android:name="com.google.android.gms.metadata.MODULE_DEPENDENCIES" />
    </intent-filter>
    <meta-data android:name="photopicker_activity:0:required" android:value="" />
</service>

However, when I do that, I get an error in Android Studio about "com.google.android.gms.metadata.ModuleDependencies" not being recognized or resolved.

enter image description here

How can we fix this?

Inflame answered 12/4, 2023 at 13:50 Comment(5)
If nothing else, you could try adding a dependency on com.google.android.gms:play-services-home, version 16.0.0-beta1 or higher. Google's docs for Matter integration show the same sort of com.google.android.gms.metadata.MODULE_DEPENDENCIES <service> element. If that works, you might then be able to identify the specific dependency that contains the class.Mali
It seems some one logged an Issue : Track it here : issuetracker.google.com/issues/279636992Chanda
I tried adding com.google.android.gms:play-services-home:16.0.0-beta1, it doesn't include com.google.android.gms.metadata.ModuleDependencies either.Arrogance
have the same issue, any workarounds? is there an updated issue tracker link for this?Keeler
issuetracker.google.com/issues/280659181 looks similarOgham
I
32

The docs weren't correct as reported in this issue.

The recommendation is to add a tools:ignore="MissingClass" attribute and to also suppress AndroidDomInspection:

<!--
    Prompt Google Play services to install the backported photo picker module
    https://developer.android.com/training/data-storage/shared/photopicker#device-availability
-->
<!--suppress AndroidDomInspection -->
<service android:name="com.google.android.gms.metadata.ModuleDependencies"
    android:enabled="false"
    android:exported="false"
    tools:ignore="MissingClass">
    <intent-filter>
        <action android:name="com.google.android.gms.metadata.MODULE_DEPENDENCIES" />
    </intent-filter>
    <meta-data android:name="photopicker_activity:0:required" android:value="" />
</service>
Inflame answered 29/5, 2023 at 17:22 Comment(0)
A
0

It seems like this is solved by adding the following attribute: tools:ignore="MissingClass" to the XML node with the ModuleDependencies class. The documentation was updated: https://developer.android.com/training/data-storage/shared/photopicker#device-availability

Arrogance answered 21/5, 2023 at 6:26 Comment(3)
Adding tools:ignore="MissingClass" does nothing for me. I'm still seeing Unresolved package 'gms', Unresolved package 'metadata' and Unresolved class 'ModuleDependencies' Inflame
That's just an IDE error right? It's because the class is does not exist. It does compile however.Arrogance
We've always been able to compile with the IDE error. Adding that attribute does nothingInflame

© 2022 - 2024 — McMap. All rights reserved.