here is the permissions on my AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
here is my build.gradle file
android {
compileSdkVersion 34
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "xxxxxxx"
minSdkVersion 22
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
}
When I try to open the gallery, the app will open the app settings, but unfortunately I can’t find ‘Photo and videos’ permission at all to be allowed in ‘settings’ for Android 11 like the image below, I can only see ‘Files and Media’ permission which still I can’t open the photo gallery. I don’t have this issue on Android 13
I expect the app will open the gallery notification like this, instead of open the app settings
currently I am using Flutter and using Permission Handle Library and I use this code to ask permission to access the gallery
final status = await Permission.photos.request();
but it seems the status is always denied
or permanentlyDenied
so thats why I always open the app setting
if (status == PermissionStatus.denied || status == PermissionStatus.permanentlyDenied) {
openAppSettings();
throw NoImageException("Photo gallery image permission is not granted");
}
2
Answers
I can solve it using the code below, in you AndroidManifest.xml
still in you AndroidManifest.xml add this one attribute on your
application
xmlon your flutter (dart) I use the code below, I use Permission Handler and also Device Info Plus
try exported true in mainefest and
shrinkResources false
minifyEnabled false
in app section. build.gradle