Kerry
Kerry

Reputation: 454

Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present

I need to upgrade the sdk version to 31 because I tried to use react native vision camera package

In there it is recommend to upgrade to sdk version 31

here is the link https://mrousavy.com/react-native-vision-camera/docs/guides/troubleshooting/#android

This is my current AndroidManifest.html. As per other post from stack overflow post. I already added "android:exported=true" to the main activity. But the error still here

Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]

<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>

This is the error log

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

When I try to add android:exported=true to the receiver line receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver above inter-filter the app is successfully built but always quit For inter-filter for firebase push notification the document recommend to use android:export=false. When I use false the app won't build

I start getting this error when I change the SDK version

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
    }
}

Upvotes: 2

Views: 1800

Answers (2)

deadwin
deadwin

Reputation: 1

AndroidManifest.xml
<receiver android:name=".NotificationReceiver" android:exported="true">

Upvotes: 0

Eagle
Eagle

Reputation: 180

Maybe you are using third party libraries that add some new components with a missing exported property. Click on the tab "Merged Manifest" when you have an xml file open with the manifest: see if there is a component and if it is found, just add it to your manifest with the android:exported="false" or "true" property. All components such as: activity, receivers, service must contain the android:exported field.

Upvotes: 1

Related Questions