React native app not getting installed in Android 12 devices. It throws Manifest merge failed error while running the application on device. I saw many people facing this issue and adding "android:exported" in manifest resolves it for them but for me after adding "android:exported" does not resolves the issue.
I have added it in all the activities, receivers and services. Tried multiple values for that as well but the issue still persists. I have followed all the steps asked in the similar questions but none of them seems working for me.
These are the similar questions that I already checked.
Manifest merger failed targeting Android 12 Android build failed, after trying to fix an error about targeting Android 12 Manifest merger failed with multiple errors | Android 12 and higher are required to specify an explicit value for `android:exported` Manifest merger failed with multiple errors Android studio React native https://github.com/zo0r/react-native-push-notification/issues/2261
I'm getting this error "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED" when running the build on android device with react-native run-android
java.util.concurrent.ExecutionException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl75501393.tmp/base.apk (at Binary XML file line #209): com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver: Targeting S (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present
and "There was a problem parsing a package" when installing the built apk.
Here are the Manifest and Gradle files.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xx.xxx">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<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"
android:requestLegacyExternalStorage="true">
<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>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="xx"/>
<receiver android:name="io.invertase.firebase.notifications.RNFirebaseNotificationReceiver" android:enabled="true" android:exported="false"/>
<receiver
android:enabled="true"
android:exported="false"
android:name="io.invertase.firebase.notifications.RNFirebaseNotificationsRebootReceiver">
<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"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver android:name="io.invertase.firebase.notifications.RNFirebaseBackgroundNotificationActionReceiver" android:exported="false">
<intent-filter>
<action android:name="io.invertase.firebase.notifications.BackgroundAction" />
</intent-filter>
</receiver>
<receiver android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true" android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.measurement.UPLOAD" />
<action android:name="com.android.vending.INSTALL_REFERRER"/>
</intent-filter>
</receiver>
<service android:name="io.invertase.firebase.notifications.RNFirebaseBackgroundNotificationActionsService" android:exported="false"/>
<!-- Add this line for Message service -->
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<!-- Add this line to enable backgound messaging services -->
<service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" android:exported="false"/>
</application>
</manifest>
android/build.gradle
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "20.1.5948944"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
// classpath('com.google.gms:google-services:4.3.2')
classpath('com.google.gms:google-services:4.3.10')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
android/app/build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
enableHermes: false, // clean and rebuild if changing
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
def jscFlavor = 'org.webkit:android-jsc: '
def enableHermes = project.ext.react.get("enableHermes", false);
android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion 31
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "xx.xx.xx"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion 31
versionCode 1
versionName "1.0"
missingDimensionStrategy 'react-native-camera', 'general'
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
storeFile file('rao.keystore')
storePassword 'Raoinfotech@09'
keyAlias 'rao-keystore'
keyPassword 'Raoinfotech@09'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
defaultConfig.versionCode * 1000 versionCodes.get(abi)
}
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native: " // From node_modules
implementation 'com.google.firebase:firebase-core:9.6.1'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
implementation 'com.google.firebase:firebase-iid'
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath "hermes-debug.aar")
releaseImplementation files(hermesPath "hermes-release.aar")
} else {
implementation jscFlavor
}
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
CodePudding user response:
add in Application in AndroidManifest.xml
tools:replace="android:allowBackup,icon,label,name,theme,roundIcon"
CodePudding user response:
You need to add android:exported
in AndroidManifest.xml of other packages as well, not only to main AndroidManifest.xml. So open Find in Files
dialog(CMD Shift F
) and then search <activity
, there you can add android:exported
.