在Play商店上传应用程序包时出现错误。

4

您上传了一个带有活动、活动别名、服务或广播接收器的APK或Android应用程序包,并带有意图过滤器,但未设置'android:exported'属性。该文件无法在Android 12或更高版本上安装。请参见:developer.android.com/about/versions/12/behavior-changes-12#exported

在上传捆绑包时,在Play商店控制台中遇到此错误。

清单文件代码

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.smartbharat.one">
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
   <application
       android:label="@string/app_name"
       android:icon="@mipmap/ic_launcher"
       android:roundIcon="@mipmap/ic_launcher"
       android:usesCleartextTraffic="true">
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
         <meta-data android:name="com.google.android.geo.API_KEY"
               android:value="AIzaSyDPzRxpT0mhrdEjTipEadB0l8T2tyu3m5E"/>
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@mipmap/ic_notification" />
        <activity
         android:name="com.facebook.FacebookActivity"
         android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
         android:label="@string/app_name" />
        <activity
        android:name="com.facebook.CustomTabActivity"
        android:exported="true">
            <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:scheme="@string/fb_login_protocol_scheme" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MainActivity"
            android:exported="true"
        android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <!-- Displays an Android View that continues showing the launch screen
                 Drawable until Flutter paints its first frame, then this splash
                 screen fades out. A splash screen is useful to avoid any visual
                 gap between the end of Android's launch screen and the painting of
                 Flutter's first frame. -->
            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
         <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
        <!-- 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>
</manifest>
3个回答

3

将目标 SDK 更改为 30 对我有用。


1
哥们,你救了我的一天,我试图解决这个问题很长时间了。 - FtheBuilder
2
Google Play现在需要sdk min 31。因此,它不再起作用。 - Dorbagna

2
看起来您的其中一个活动没有设置导出。
请进行以下替换:
<activity
        android:name="com.yalantis.ucrop.UCropActivity"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>

并且

 <activity
     android:name="com.facebook.FacebookActivity"
     android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
     android:label="@string/app_name" />

使用

<activity
        android:name="com.yalantis.ucrop.UCropActivity"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar"
        android:exported="true" />

并且

 <activity
     android:name="com.facebook.FacebookActivity"
     android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
     android:label="@string/app_name" 
     android:exported="true"/>

得到相同的错误。 - Prime Digital
抱歉,我注意到你有2个活动没有回答,答案已更新。 - LethalMaus

2

这个问题有一个简单的解决方法,就是在您的 build.gradle 文件/文件中将最大支持版本设置为 30 而不是 31。

然而,要支持 31 版本: 从文档中了解到:

**如果您的应用程序针对 Android 12 或更高版本,并包含使用意图过滤器的活动、服务或广播接收器,则必须明确声明这些应用程序组件的 android:exported 属性。 如果应用程序组件包括 LAUNCHER 类别,请将 android:exported 设置为 true。在大多数其他情况下,请将 android:exported 设置为 false。 **

<service android:name="com.example.app.backgroundService"
         android:exported="false">
    <intent-filter>
        <action android:name="com.example.app.START_BACKGROUND" />
    </intent-filter>
</service>

PS:我建议使用 Android Studio 的金丝雀版本构建项目,因为它的清单列表会显示清单中的错误。


1
做了同样的问题,无法上传到应用商店。 - Prime Digital
降级到30? - Narendra_Nath
目标SDK版本30 - Prime Digital

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接