You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native(分离版)安装OneSignal后Android Studio编译失败:清单合并错误

Fixing Manifest Merge Conflict with OneSignal in React Native

Hey there, let's get this annoying manifest merge error sorted out for your React Native (detached) app with OneSignal. This is a super common Android support library version clash, and here's how to fix it step by step:

Understanding the Problem

The error boils down to conflicting support library versions:

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.2) from [com.android.support:appcompat-v7:26.0.2] AndroidManifest.xml:28:13-35 is also present at [com.android.support:exifinterface:26.0.1] AndroidManifest.xml:25:13-35 value=(26.0.1). Suggestion: add 'tools:replace="android:val...

In short, OneSignal is pulling in an older exifinterface library, which clashes with the newer appcompat-v7 version your project uses. The Android manifest merger can't decide which version to use, so it throws this error.

Solution 1: Force a Unified Support Library Version

This is my go-to fix for these conflicts—we'll tell Gradle to use the same version for all support library dependencies:

  1. Open the root-level build.gradle file of your Android project (not the one inside the app module).
  2. Add the following configurations block inside the allprojects section:
    allprojects {
        repositories {
            // ... keep your existing repository entries here
        }
    
        configurations.all {
            resolutionStrategy {
                // Force exifinterface to match your appcompat-v7 version (26.0.2 here)
                force 'com.android.support:exifinterface:26.0.2'
                // If you upgrade your support library version later, update this number too
            }
        }
    }
    

Solution 2: Use tools:replace to Override the Conflict

If you want to follow the error message's direct suggestion, here's how to implement it:

  1. First, make sure your AndroidManifest.xml includes the tools namespace at the top:
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        package="com.your_app_package_name">
    
  2. Inside the <application> tag, add a meta-data entry to explicitly set the version and override conflicting declarations:
    <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">
    
        <!-- Add this to resolve the version conflict -->
        <meta-data
            android:name="android.support.VERSION"
            android:value="26.0.2"
            tools:replace="android:value" />
    
        <!-- Rest of your application content (activities, services, etc.) -->
    </application>
    

Final Step: Clean & Rebuild

After applying either fix, clear old build artifacts and rebuild to make sure changes take effect:

  • In Android Studio: Go to Build > Clean Project, then Build > Rebuild Project.
  • Or via terminal:
    ./gradlew clean
    ./gradlew assembleDebug
    

That should resolve the manifest merge error and let you compile your app with OneSignal integrated smoothly!

内容的提问来源于stack exchange,提问作者Mizlul

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 02:29:31