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

React Native集成OneSignal后构建失败:依赖冲突求助

Fixing Manifest Merger Conflict After Installing react-native-onesignal

Hey there, let's tackle this manifest merger error you're facing after adding OneSignal to your React Native project. The issue boils down to conflicting versions of Android Support Library dependencies—your project has com.android.support:cardview-v7:26.0.1 and OneSignal is pulling in com.android.support:support-v4:26.1.0, which causes the manifest merger to throw a fit when it sees two different values for the android.support.VERSION meta-data.

Here are two reliable ways to fix this:

Option 1: Override the Version in AndroidManifest.xml

This directly follows the error message's suggestion:

  • First, make sure your root <manifest> tag includes the tools namespace. If it doesn't, add it:
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              package="com.your.app.package">
    
  • Next, inside the <application> tag, add (or modify if it already exists) the meta-data entry for android.support.VERSION, using the tools:replace attribute to force the correct version:
    <application ...>
        <!-- Your existing app components go here -->
        
        <meta-data
            android:name="android.support.VERSION"
            android:value="26.1.0"
            tools:replace="android:value" />
    </application>
    
    Use the higher version (26.1.0) here since it's the one OneSignal relies on, which should be backward-compatible with your existing code.

This prevents similar conflicts from popping up in the future by forcing all Android Support Library dependencies to use the same version:

  • Open your app-level build.gradle file (located at android/app/build.gradle)
  • Add this block outside the android { ... } section:
    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.android.support') {
                if (!requested.name.startsWith('multidex')) {
                    details.useVersion '26.1.0'
                }
            }
        }
    }
    
    This tells Gradle to use version 26.1.0 for every Support Library dependency, eliminating version mismatches entirely.

After making either change, clean and rebuild your project—this should resolve the manifest merger error and let you build your app with OneSignal integrated.

内容的提问来源于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 03:29:55