无法从 PlayStore 为 Android 12 targetSDK 31 安装应用程序

Posted

技术标签:

【中文标题】无法从 PlayStore 为 Android 12 targetSDK 31 安装应用程序【英文标题】:Can not install app from PlayStore for Android 12 targetSDK 31 【发布时间】:2021-12-23 15:43:47 【问题描述】:

最近用户可以下载应用程序,但下载后,应用程序无法安装

我已经在清单中添加了android:exported="true",但仍然面临这个问题,如果有什么我遗漏的,请帮助我解决它。

build.gradle

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.")


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'
apply plugin: 'com.google.firebase.crashlytics'

android 
    compileSdkVersion 31

    sourceSets 
        main.java.srcDirs += 'src/main/kotlin'
    

    defaultConfig 
        applicationId "packagename"
        minSdkVersion 24
        targetSdkVersion 31
        versionCode 27
        versionName "2.14"
        multiDexEnabled true
    

    buildTypes 
        release 
            signingConfig signingConfigs.debug
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        
    


flutter 
    source '../..'


dependencies 
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation platform('com.google.firebase:firebase-bom:28.3.1')
    implementation 'com.google.firebase:firebase-crashlytics'
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.android.support:multidex:1.0.3'


AndroidManifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="---">

    <application
        android:icon="@mipmap/ic_launcher"
        android:label="AppName"
        android:usesCleartextTraffic="true"
        android:requestLegacyExternalStorage="true">

        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:showWhenLocked="true"
            android:turnScreenOn="true"
            android:windowSoftInputMode="adjustResize">
            
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
           
            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="appdomain.ca"
                    android:pathPrefix="/user"
                    android:scheme="https" />
                <data
                    android:host="appdomain.ca"
                    android:pathPrefix="/post"
                    android:scheme="https" />
                <data
                    android:host="appdomain.ca"
                    android:pathPrefix="/business"
                    android:scheme="https" />
            </intent-filter>

            <meta-data
                android:name="io.flutter.embedding.android.SplashScreenDrawable"
                android:resource="@drawable/launch_background" />
            <meta-data
                android:name="io.flutter.embedding.android.NormalTheme"
                android:resource="@style/NormalTheme" />
        </activity>

        <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@mipmap/ic_notification" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/colorPrimary" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_channel_id"
            android:value="high_importance_channel" />
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
    <queries>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="https" />
        </intent>
        <intent>
            <action android:name="android.intent.action.DIAL" />
            <data android:scheme="tel" />
        </intent>
        <intent>
            <action android:name="android.intent.action.SEND" />
            <data android:mimeType="*/*" />
        </intent>
    </queries>

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <uses-permission android:name="android.permission.INTERNET" />

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>

【问题讨论】:

【参考方案1】:

您是否尝试删除android:requestLegacyExternalStorage="true"。因为 targetSDKVersion 为 31 时该字段无效。

【讨论】:

还是一样,无法安装【参考方案2】:

问题在于flutter_local_notifications旧版本。因此,如果有人遇到同样的问题,请先更新所有依赖项,然后继续。

【讨论】:

以上是关于无法从 PlayStore 为 Android 12 targetSDK 31 安装应用程序的主要内容,如果未能解决你的问题,请参考以下文章

尽管设置为 targetSDK 31,但 Flutter App 无法从 Google 商店为 Android 12 安装

将 android app bundle 上传到 playstore 时出错。。您的 app bundle 的目标是无法识别的语言 jp

从 Playstore 下载内部测试版时,Android 12 beta 5 应用链接不会自动验证

如何停用 Android PlayStore 上的特定应用测试版?

Android 应用程序在设备上显示列表,但从 Playstore 下载时

在我的 android 应用程序中为社区公开使用 Facebook,而不在 Playstore 上发布它