'Flutter App not installable from Google store for Android 12 despite being set to targetSDK 31
I have a Flutter App in the Playstore and if you have Android 12, it will just pop an Error Message: "AppName cannot be installed"
My Flutter version is 2.5.0
I would expect the app to be installable on Android 12 because of my settings. Are there any òther reasons this could fail?
This is my build.grade:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '25'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.1.0'
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
// apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 31
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "myAppID"
minSdkVersion 21
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
//signingConfig signingConfigs.debug
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug{
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//def multidex_version = "2.0.1"
//implementation 'androidx.multidex:multidex:$multidex_version'
implementation 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'
Installing this on an Android 12 Emulator, the install fails with this message:
After I did add this value as true to my appmanifest, I started it again and I have an endless install loading icon in visual studio code. I have the app on the device, but it will close immidiately after tapping on it
Solution 1:[1]
You have to set android:exported to any <activity>, <activity-alias>,<service>, or <receiver> components that have <intent-filter>s declared in the app’s AndroidManifest.xml file. ALSO!!!! You have to do the same for every package you use. I would advice NOT doing it manually as this could get modified by calling something like "Pub clear cache" and instead try to update your packages to the latest version.
https://medium.com/androiddevelopers/lets-be-explicit-about-our-intent-filters-c5dbe2dbdce0
Solution 2:[2]
When I was stuck for this issue, did not found anything helpful on the web: not many people seems to encountered this.
I tried creating fresh new flutter app, copying its /android folder to my old project; setting android:exported for in AndroidManifest.xml: none of helped for running my app on Android 12 device. (Also there were some Android 11 devices, all of them being SAMSUNG, that our app, of which target sdk was set to 31, could not be installed.
Finally setting targetSdkVersion as 30 and compileSdkVersion as 30, fixed the issue.
SDK version 30 and Android 12? Weird.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | dhcracchiolo |
Solution 2 | kamranbekirovyz |