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

react本机清单合并失败

毋胜涝
2023-03-14

添加react-native-admob库后,我收到下一条错误消息

清单合并失败:[com.android.support:support-compat:28.0.0]AndroidManifest.xml:22:18-91中的属性application@AppComponentFactory value=(Android.support.v4.app.CoreComponentFactory)也出现在[AndroidX.Core:Core:1.0.0]AndroidManifest.xml:22:18-86 value=(AndroidX.Core.App.CoreComponentFactory中。建议:将'tools:replace=“android:AppComponentFactory”‘添加到AndroidManifest.xml:7:5-117的元素中以覆盖。

我尝试按照建议添加'tools:replace=“android:AppComponentFactory”,但构建仍然失败。

"dependencies": {
    "@react-native-community/async-storage": "^1.4.0",
    "formik": "^1.5.4",
    "mobx": "^5.9.4",
    "mobx-react": "^5.4.3",
    "native-base": "^2.12.1",
    "react": "16.8.3",
    "react-native": "0.59.5",
    "react-native-admob": "^2.0.0-beta.5",
    "react-native-check-box": "^2.1.7",
    "react-native-gesture-handler": "^1.2.1",
    "react-native-iphone-x-helper": "^1.2.0",
    "react-native-modal": "^10.0.0",
    "react-native-numeric-input": "^1.6.5",
    "react-native-pose": "^0.9.0",
    "react-native-swipeable": "^0.6.0",
    "react-native-vector-icons": "^6.4.2",
    "react-navigation": "^3.9.1",
    "styled-components": "^4.2.0"
  }
apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.rntodo"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    buildTypes {
        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:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            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 =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    implementation project(':react-native-admob')
    implementation 'com.google.android.gms:play-services-ads:16.0.0'
    implementation project(':@react-native-community_async-storage')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-gesture-handler')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

// 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'
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

AndroidManifest.xml

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

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

    <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">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        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" />
    </application>

</manifest>

我不确定我从哪里依赖AndroidX.core:core:1.0.0。请告诉我如何解决清单合并冲突。谢谢

共有1个答案

司徒阳曜
2023-03-14

lib引用了旧的Android支持库中的一些文件和类。从0.60开始,使用AndroidX支持库,而不是Android-support。这意味着所有的依赖都必须依赖它。

幸运的是,有一个工具可以将lib转换为新的格式。它被称为jetifier:https://www.npmjs.com/package/jetifier。您可以使用它并将其添加为yarn/npm post install脚本,以便在每个yarn/npm安装后将其应用于所有node_modules依赖项。

您的库还有另一种选择,因为另一位作者报告说,他创建了react-native-admob的分叉,并将其更新到最新的AndroidX支持库,请参阅https://github.com/sbugert/react-native-admob/issues/459

 类似资料:
  • 突然,当我在android手机中编译我的项目时,我在manifest合并时得到了这个错误 任务“:app:ProcessDebugManifest”执行失败。清单合并失败:属性application@appcomponentFactory value=(Android.support.v4.app.coreComponentFactory)来自[com.android.support:suppor

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