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

升级至SDK33后Manifest合并失败:需指定android:exported属性

升级SDK到33后Manifest合并失败问题解决

错误提示

Manifest merger failed : android:exported needs to be explicitly specified for element <activity#com.firebase.ui.auth.ui.provider.GitHubLoginActivity>。针对Android 12及更高版本的应用,当对应组件定义了intent filter时,必须为其显式指定android:exported属性值。

已检查的配置

项目Manifest文件

<?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools">

 <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name="com.logista.otbokhly_Driver.activities.DriversActivity"
            android:label="@string/drivers_list"
            android:exported="true" tools:node="merge" />
        <activity android:name="com.logista.otbokhly_Driver.activities.UserChatActivity"  android:exported="true" tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.activities.OrderBillActivity"
            android:label="@string/order_bill"
            android:screenOrientation="fullSensor"  android:exported="true" tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.activities.DriverDetailsActivity"
            android:screenOrientation="portrait"  android:exported="true" tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.activities.DriverBalanceActivity"
            android:screenOrientation="portrait"  android:exported="true" tools:node="merge" />
        <activity
            android:name="com.logista.otbokhly_Driver.activities.NotificationActivity"
            android:label="@string/title_notification"
            android:screenOrientation="portrait"  android:exported="true" tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.activities.ProfileActivity"
            android:screenOrientation="portrait"  android:exported="true" tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.activities.SignUpActivity"
            android:screenOrientation="portrait"  android:exported="true" tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.activities.LogInActivity"
            android:screenOrientation="portrait"  android:exported="true" tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.activities.SplashActivity"
            android:screenOrientation="portrait"
            android:exported="true" tools:node="merge">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" android:exported="true"/>

                <category android:name="android.intent.category.LAUNCHER" android:exported="true"/>
            </intent-filter>
        </activity>
        <activity
            android:name="com.logista.otbokhly_Driver.activities.ChatActivity"
            android:screenOrientation="portrait"  android:exported="true" tools:node="merge"/>
        <activity android:name="com.logista.otbokhly_Driver.activities.SendFormActivity" android:exported="true"  tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.activities.ContactUsActivity"
            android:label="@string/title_contact_us"
            android:screenOrientation="portrait"  android:exported="true" tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.activities.HomeActivity"
            android:screenOrientation="portrait"  android:exported="true" tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.invice_for_user"
            android:screenOrientation="portrait"  android:exported="true" tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.document_page"
            android:screenOrientation="portrait"  android:exported="true" tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.notification_act"
            android:screenOrientation="portrait"  android:exported="true" tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.invoice"
            android:screenOrientation="portrait"  android:exported="true" tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.edit_profile"
            android:screenOrientation="portrait"  android:exported="true" tools:node="merge"/>

        <activity android:name="com.logista.otbokhly_Driver.weiting_order"  android:exported="true" tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.homeActivity"
            android:label="@string/title_activity_home"
            android:theme="@style/AppTheme.NoActionBar"  android:exported="true" />
        <activity android:name="com.logista.otbokhly_Driver.registration"  android:exported="true" tools:node="merge"/>
        <activity
            android:name="com.logista.otbokhly_Driver.MainActivity"
            android:configChanges="orientation|screenSize|keyboardHidden"
            android:windowSoftInputMode="stateVisible|adjustResize"  android:exported="true" tools:node="merge"/>

        <service
            android:name="com.logista.otbokhly_Driver.services.LocationService"
            android:enabled="true"
            android:exported="false" tools:node="merge"/>

        <uses-library
            android:name="org.apache.http.legacy"
            android:required="false" android:exported="true"/>
    </application>
    <uses-permission android:name="android.permission.INTERNET"
        tools:ignore="ManifestOrder" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!--    <uses-permission android:name="android.permission.READ_PHONE_STATE" />-->

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

</manifest>

项目根目录Gradle配置

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        mavenLocal()
        mavenCentral()
        maven { url 'https://maven.google.com' } //<<--Insert this above google()
        maven { url "https://www.jitpack.io" }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0'
       // classpath 'com.google.gms:google-services:4.3.3'
        classpath 'com.google.gms:google-services:4.3.14' // or latest version

        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        mavenCentral()
        maven { url 'https://maven.google.com' } //<<--Insert this above google()
        maven { url "https://www.jitpack.io" }
        google()
        jcenter()

    }

    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.android.support'
                        && !details.requested.name.contains('multidex') ) {
                    details.useVersion "27.1.1"
                }
                if (details.requested.group == 'androidx.core'
                        && !details.requested.name.contains('androidx') ) {
                    details.useVersion "1.0.1"
                }
            }
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

解决方案

方案一:升级Firebase UI Auth依赖

Firebase UI Auth旧版本未适配Android 12+的android:exported要求,找到模块级build.gradle中的firebase-ui-auth依赖,升级到7.2.0及以上版本(该版本开始支持Android 12相关规范):

implementation 'com.firebaseui:firebase-ui-auth:7.2.0'

升级后,库自身Manifest会包含正确的android:exported属性,无需手动配置。

方案二:手动在Manifest中声明该Activity

如果暂时无法升级依赖,可在自己的AndroidManifest.xml的<application>标签内添加以下代码,显式指定android:exported属性:

<activity
    android:name="com.firebase.ui.auth.ui.provider.GitHubLoginActivity"
    android:exported="true"
    tools:node="merge" />

注:该Activity用于GitHub登录跳转,需要接收外部Intent,因此设为android:exported="true";若组件仅内部使用则设为false。

额外检查

升级SDK到33后,需确保所有第三方依赖库的组件(Activity、Service、Receiver等)都符合Android 12+要求,若出现其他类似合并错误,可参照上述两种方案处理。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 12:15:43