Add these dependencies:
implementation("com.google.android.gms:play-services-base:18.3.0")
This is your manifest file
<manifest>
<application>
<!-- 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>
<!-- Play Services Availability -->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
<!-- Required Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
Add these dependencies:
implementation("com.google.android.gms:play-services-auth:20.7.0")
implementation("androidx.activity:activity:1.8.0")
Then use this code to implement photo picker:
val pickSingleMedia = registerForActivityResult(PickVisualMedia()) { uri ->
if (uri != null) {
// Handle selected media
}
}
// Launch picker
pickSingleMedia.launch(PickVisualMediaRequest(PickVisualMedia.ImageOnly))
The manifest entry you showed is no longer needed. The new ActivityResult API handles photo picking across API levels automatically.
please let me know if still you are in problem. Thanks