我在 Playstore 中有一个 Flutter 应用程序,如果你有 Android 12,它只会弹出一条错误消息:
“无法安装 AppName”
我的 Flutter 版本是 2.5.0
由于我的设置,我希望该应用程序可以安装在 Android 12 上。是否有任何其他可能失败的原因?
这是我的 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'
flutter 医生:在 Android 12 模拟器上安装它,安装失败并显示以下消息:
在我确实将此值添加为我的 appmanifest 后,我再次启动它,我在 Visual Studio 代码中有一个无尽的安装加载图标。我的设备上有应用程序,但点击它后它会立即关闭
最佳答案
您必须将 android:exported 设置为在应用的 AndroidManifest.xml 文件中声明了
还!!!!
你必须为你使用的每个包做同样的事情。我建议不要手动执行此操作,因为这可以通过调用“Pub clear cache”之类的内容来修改,而是尝试将您的包更新到最新版本。
https://medium.com/androiddevelopers/lets-be-explicit-about-our-intent-filters-c5dbe2dbdce0
关于android - 尽管设置为 targetSDK 31,但 Flutter App 无法从 Google 商店为 Android 12 安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69897658/