当前位置: 首页 > 知识库问答 >
问题:

定位S(版本31和更高版本)要求在意图过滤器存在时为android:exported定义一个显式值

单于正业
2023-03-14

我需要将sdk版本升级到31,因为我尝试使用react native vision camera包

在那里建议升级到sdk版本31

这是https://mrousavy.com/react-native-vision-camera/docs/guides/troubleshooting/#android链接

这是我现在的AndroidManifest.html。按照堆栈溢出帖子中的其他帖子。我已经在主活动中添加了“android:exported=true”。但是错误仍然存在

定位 S(版本 31 及更高版本)要求在存在意向过滤器时定义 android:导出的显式值]

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

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


        <application
            android:name=".MainApplication"
            android:label="@string/app_name"
            android:icon="@mipmap/ic_launcher"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:allowBackup="false"
            android:theme="@style/AppTheme">

         <!-- Change the value to true to enable pop-up for in foreground on receiving remote notifications (for prevent duplicating while showing local notifications set this to false) -->
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
                    android:value="false"/>
        <!-- Change the resource name to your App's accent color - or any other color you want -->
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
                    android:resource="@color/white"/> <!-- or @android:color/{name} to use a standard color -->

        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
            </intent-filter>
        </receiver>

                 <service
            android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>


            <activity
                android:name=".MainActivity"
                android:exported="true"
                android:label="@string/app_name"
                android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
                android:launchMode="singleTask"
                android:windowSoftInputMode="adjustResize">
                <intent-filter>
                        <action android:name="android.intent.action.MAIN" />
                        <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
</manifest>

这是错误日志

> Task :app:installDebug FAILED
Installing APK 'app-debug.apk' on 'Pixel_2_API_32(AVD) - 12' for app:debug

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
357 actionable tasks: 7 executed, 350 up-to-date
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Unable to install /Users/kerrydss/Desktop/Work/bhg-ecommerce-rn/android/app/build/outputs/apk/debug/app-debug.apk
com.android.ddmlib.InstallException: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl227096480.tmp/base.apk (at Binary XML file line #76): ***com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present***
        at com.android.ddmlib.internal.DeviceImpl.installRemotePackage(DeviceImpl.java:1224)
       

当我尝试将android:exported=true添加到接收器行时=“com.diam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver在inter-filter之上,应用程序已成功构建,但始终会退出。对于firebase推送通知的inter-filter,文档建议使用android:export=false。当我使用false时,应用程序不会构建

当我更改SDK版本时,我开始得到这个错误

buildscript {
    ext {
        ext {
        googlePlayServicesVersion = "+" // default: "+"
        firebaseMessagingVersion = "21.1.0" // default: "21.1.0"
       //working version without camera package
       // buildToolsVersion = "29.0.3"
       // minSdkVersion = 21
       // compileSdkVersion = 29
       // targetSdkVersion = 29
       // ndkVersion = "20.1.5948944"


         buildToolsVersion = "30.0.0"
         minSdkVersion = 26
         compileSdkVersion = 31
         targetSdkVersion = 31
         ndkVersion = "20.1.5948944"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.1.2")
        classpath('com.google.gms:google-services:4.3.1')
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

共有1个答案

宫坚
2023-03-14

也许您正在使用第三方库,这些库添加了一些缺少导出属性的新组件。当您打开一个包含清单的xml文件时,请单击“合并清单”选项卡:查看是否有组件,如果找到它,只需将其添加到具有android:exported=“false”或“true”属性的清单中即可。所有组件,例如:活动,接收器,服务必须包含android:导出字段。

 类似资料: