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

React Native Android 12-清单合并失败

干京
2023-03-14

反应原生应用程序未安装在Android 12设备上。在设备上运行应用程序时,它会抛出清单合并失败错误。我看到很多人面临这个问题,在清单中添加“android:导出”可以为他们解决问题,但对我来说,添加“android:导出”后并不能解决问题。

我已将其添加到所有活动,接收器和服务中。也尝试了多个值,但问题仍然存在。我已经遵循了类似问题中提出的所有步骤,但似乎没有一个对我有用。

这些是我已经检查过的类似问题。

针对Android 12的清单合并失败Android构建失败,在尝试修复有关针对Android 12的错误清单合并失败并出现多个错误后|Android 12及更高版本需要为“android:导出”指定显式值清单合并失败并出现多个错误Android Studio React本机https://github.com/zo0r/react-native-push-notification/issues/2261

我得到这个错误"INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"运行在android设备上与react-本机run-android构建

java.util.concurrent.ExecutionException: com.android.builder.testing.api.DeviceException: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: 安装过程中解析失败PackageLI: /data/app/vmdl75501393.tmp/base.apk (在二进制 XML 文件行 #209): com.google.android.gms.measure.appMeasurementInstallReferrer 接收者:目标 S (版本 31 及以上版本) 要求在存在意图过滤器时定义 android:导出 的显式值

和安装内置apk时“解析包出现问题”。

这是货物清单和文件。

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

共有2个答案

万俟均
2023-03-14

你需要添加android:导出在AndroidManifest.xml的其他软件包以及,不仅是主AndroidManifest.xml.所以打开查找文件对话框(CMD Shift F),然后搜索

冉昊
2023-03-14

在Android手册中添加应用程序.xml

工具:替换="android:允许备份、图标、标签、名称、主题、圆形图标"

 类似资料:
  • 错误:任务“:app:ProcessDebugManifest”执行失败。 清单合并失败:来自AndroidManifest.xml:13:9-42的属性application@icon value=(@mipmap/appiconnew)也存在于[com.pnikosis:materialish-progress:1.0]AndroidManifest.xml:13:9-45 value=(@d

  • 我似乎得到了这样的错误:

  • 问题内容: 我正在将当前项目的大型应用程序移至Android Studio和Gradle中。我目前陷入以下问题: 我尝试将以下属性添加到主文件: 这些属性定义都不起作用。我究竟做错了什么? 问题答案: 试试看: 将此添加到 将此添加到 基于此,它应该覆盖所有元素。“将低优先级声明替换为带注释的声明。”

  • 清单合并失败:属性Application@AppComponentFactory value=(android.support.v4.app.CoreComponentFactory)来自[com.android.support:support-compat:28.0.0]AndroidManifest.xml:22:18-91 也存在于[androidx.core:core:1.0.0]andr

  • 我在移动我目前的项目巨大的应用程序到Android Studio和Gradle的过程中。我目前被困在以下问题上: 我尝试将以下属性添加到主文件中: 这些属性定义都不起作用。我做错了什么?

  • 我得到下面的错误信息。 错误:任务执行失败:app:processDebugManifest。清单合并失败:uses-sdk:minSdkVersion 1不能小于库中声明的版本4[com . Android . support:multi dex:1 . 0 . 1]C:\ Users \ Nitesh \ Downloads \ sun calculator(1)\ sun calculato

  • 错误:清单合并失败:属性application@appcomponentFactory value=(Android.support.v4.app.coreComponentFactory)来自[com.android.support:support-compat:28.0.0]AndroidMANIFEST.xml:22:18-91也存在于[AndroidX.core:core:1.0.0]An

  • 问题内容: 如何合并列表列表? 进入 如果我可以在合并列表之前在每个项目的开头和结尾添加一个值(例如html标签),那就更好了。 即,最终结果将是: 问题答案: 要串联列表,可以使用 要添加HTML标签,您可以使用列表推导。