简体   繁体   English

android:exported 需要明确指定<activity> . 针对 Android 12 及更高版本的应用需要指定</activity>

[英]android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify

After upgrading to android 12, the application is not compiling.升级到 android 12 后,应用程序无法编译。 It shows表明

"Manifest merger failed with multiple errors, see logs" “清单合并因多个错误而失败,请参阅日志”

Error showing in Merged manifest:合并清单中显示错误:

Merging Errors: Error: android:exported needs to be explicitly specified for.合并错误:错误:android:需要明确指定导出。 Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined.针对 Android 12 及更高版本的应用需要为android:exported指定一个明确的值,当相应的组件定义了一个 Intent 过滤器时。 See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.有关详细信息,请参阅 https://developer.android.com/guide/topics/manifest/activity-element#exported。 main manifest (this file)主要清单(此文件)

I have set all the activity with android:exported="false" .我已将所有活动设置为android:exported="false" But it is still showing this issue.但它仍然显示这个问题。

My manifest file:我的清单文件:

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

    <uses-sdk tools:overrideLibrary="net.ypresto.androidtranscoder" />

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.READ_PROFILE" />
    <uses-permission
        android:name="android.permission.READ_PHONE_STATE"
        android:maxSdkVersion="22" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

    <uses-feature
        android:name="android.hardware.location"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.location.gps"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.location.network"
        android:required="false" />

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.autofocus"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.microphone"
        android:required="false" />

    <application
        android:name=".Application"
        android:allowBackup="false"
        android:allowClearUserData="true"
        android:appCategory="social"
        android:hardwareAccelerated="true"
        android:icon="@mipmap/ic_app_launch"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:networkSecurityConfig="@xml/network_security_configuration"
        android:requestLegacyExternalStorage="true"
        android:roundIcon="@mipmap/ic_app_launch_round"
        android:theme="@style/ConversationsTheme"
        android:usesCleartextTraffic="true"
        android:windowSoftInputMode="adjustPan|adjustResize"
        tools:replace="android:label"
        tools:targetApi="q">
        <activity
            android:name=".ui.search.GroupSearchActivity"
            android:exported="true" />
        <activity
            android:name=".ui.profileUpdating.FavouritesActivity"
            android:exported="true" />
        <activity
            android:name=".ui.profileUpdating.NameActivity"
            android:exported="true" />
        <activity
            android:name=".ui.CompulsoryUpdateActivity"
            android:exported="true" />
        <activity android:name=".ui.payments.doPayment.DoPaymentActivity"
            android:exported="true" />
        <activity android:name=".ui.individualList.IndividualListActivity"
            android:exported="true" />
        <activity android:name=".ui.payments.setPayment.SetPaymentActivity"
            android:exported="true" />
        <activity android:name=".ui.login.otpActivity.OTPActivity"
            android:exported="true" />
        <activity android:name=".ui.login.loginActivity.LoginActivity"
            android:exported="true" />

        <service android:name=".services.XmppConnectionService" android:exported="true" />

        <receiver android:name=".services.EventReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
                <action android:name="android.intent.action.ACTION_SHUTDOWN" />
                <action android:name="android.media.RINGER_MODE_CHANGED" />
            </intent-filter>
        </receiver>

        <activity
            android:name=".ui.ShareLocationActivity"
            android:label="@string/title_activity_share_location"
            android:exported="true"/>
        <activity
            android:name=".ui.SearchActivity"
            android:label="@string/search_messages"
            android:exported="true" />
        <activity
            android:name=".ui.RecordingActivity"
            android:configChanges="orientation|screenSize"
            android:theme="@style/ConversationsTheme.Dialog"
            android:exported="true" />
        <activity
            android:name=".ui.ShowLocationActivity"
            android:label="@string/title_activity_show_location"
            android:exported="true" />
        <activity
            android:name=".ui.SplashActivity"
            android:theme="@style/SplashTheme"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.ConversationsActivity"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:minWidth="300dp"
            android:minHeight="300dp"
            android:exported="true"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ui.ScanActivity"
            android:screenOrientation="portrait"
            android:exported="true"
            android:theme="@style/ConversationsTheme.FullScreen"
            android:windowSoftInputMode="stateAlwaysHidden" />
        <activity
            android:name=".ui.UriHandlerActivity"
            android:label="@string/app_name"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="xmpp" />
            </intent-filter>
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="https" />
                <data android:host="im.app.in" />
                <data android:pathPrefix="/i/" />
                <data android:pathPrefix="/j/" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SENDTO" />

                <category android:name="android.intent.category.DEFAULT" />

                <data android:scheme="imto" />
                <data android:host="jabber" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.StartConversationActivity"
            android:label="@string/title_activity_start_conversation"
            android:launchMode="singleTop"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.SettingsActivity"
            android:label="@string/title_activity_settings"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.NOTIFICATION_PREFERENCES" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.ChooseContactActivity"
            android:label="@string/title_activity_choose_contact"
            android:exported="true" />
        <activity
            android:name=".ui.BlocklistActivity"
            android:label="@string/title_activity_block_list"
            android:exported="true"/>
        <activity
            android:name=".ui.ChangePasswordActivity"
            android:label="@string/change_password_on_server"
            android:exported="true"/>
        <activity
            android:name=".ui.ChooseAccountForProfilePictureActivity"
            android:enabled="false"
            android:label="@string/choose_account"
            android:exported="true">
            <intent-filter android:label="@string/set_profile_picture">
                <action android:name="android.intent.action.ATTACH_DATA" />

                <category android:name="android.intent.category.DEFAULT" />

                <data android:mimeType="image/*" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.ShareViaAccountActivity"
            android:label="@string/title_activity_share_via_account"
            android:launchMode="singleTop"
            android:exported="true" />
        <activity
            android:name=".ui.EditAccountActivity"
            android:launchMode="singleTop"
            android:exported="true"
            android:windowSoftInputMode="stateHidden|adjustResize" />
        <activity
            android:name=".ui.ConferenceDetailsActivity"
            android:label="@string/action_muc_details"
            android:exported="true"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ui.ContactDetailsActivity"
            android:exported="true"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ui.PublishProfilePictureActivity"
            android:label="@string/mgmt_account_publish_avatar"
            android:exported="true"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".ui.PublishGroupChatProfilePictureActivity"
            android:exported="true"
            android:label="@string/group_chat_avatar" />
        <activity
            android:name=".ui.ShareWithActivity"
            android:label="@string/app_name"
            android:launchMode="singleTop"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <action android:name="android.intent.action.SEND_MULTIPLE" />

                <category android:name="android.intent.category.DEFAULT" />

                <data android:mimeType="text/plain" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <action android:name="android.intent.action.SEND_MULTIPLE" />

                <category android:name="android.intent.category.DEFAULT" />

                <data android:mimeType="*/*" />
            </intent-filter>

            <!-- the value here needs to be the full class name; independent of the configured applicationId -->
            <meta-data
                android:name="android.service.chooser.chooser_target_service"
                android:value="eu.siacs.conversations.services.ContactChooserTargetService" />
        </activity>
        <activity
            android:name=".ui.TrustKeysActivity"
            android:label="@string/trust_omemo_fingerprints"
            android:exported="true"
            android:windowSoftInputMode="stateAlwaysHidden" />
        <activity
            android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
            android:exported="true"
            android:theme="@style/Base.Theme.AppCompat" />
        <activity android:name=".ui.MemorizingActivity"
            android:exported="true" />
        <activity
            android:name=".ui.MediaBrowserActivity"
            android:exported="true"
            android:label="@string/media_browser" />

        <service android:name=".services.ExportBackupService" android:exported="true"/>
        <service android:name=".services.ImportBackupService" android:exported="true"/>
        <service
            android:name=".services.ContactChooserTargetService"
            android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE"
            android:exported="true">
            <intent-filter>
                <action android:name="android.service.chooser.ChooserTargetService" />
            </intent-filter>
        </service>
        <service android:name=".services.CompulsoryUpdateService" android:exported="true"/>

        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.files"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths" />
        </provider>
        <provider
            android:name=".services.BarcodeProvider"
            android:authorities="${applicationId}.barcodes"
            android:exported="false"
            android:grantUriPermissions="true" />

        <activity
            android:name=".ui.ShortcutActivity"
            android:label="@string/contact"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.CREATE_SHORTCUT" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.MucUsersActivity"
            android:exported="true"
            android:label="@string/group_chat_members" />
        <activity
            android:name=".ui.ChannelDiscoveryActivity"
            android:exported="true"
            android:label="@string/discover_channels" />
        <activity
            android:name=".ui.RtpSessionActivity"
            android:autoRemoveFromRecents="true"
            android:exported="true"
            android:launchMode="singleInstance"
            android:supportsPictureInPicture="true" />
    </application>

</manifest>

My second manifest file:我的第二个清单文件:

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

    <application tools:ignore="GoogleAppIndexingWarning">
        <activity
            android:name=".ui.ManageAccountActivity"
            android:label="@string/title_activity_manage_accounts"
            android:launchMode="singleTask"
            android:exported="true"/>
        <activity
            android:name=".ui.MagicCreateActivity"
            android:label="@string/create_new_account"
            android:launchMode="singleTask"
            android:exported="true"/>
        <activity
            android:name=".ui.EasyOnboardingInviteActivity"
            android:label="@string/invite_to_app"
            android:launchMode="singleTask" />
        <activity
            android:name=".ui.ImportBackupActivity"
            android:label="@string/restore_backup"
            android:launchMode="singleTask"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />

                <data android:mimeType="application/vnd.conversations.backup" />
                <data android:scheme="content" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />

                <data android:mimeType="application/vnd.conversations.backup" />
                <data android:scheme="file" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="content" />
                <data android:host="*" />
                <data android:mimeType="*/*" />
                <data android:pathPattern=".*\\.ceb" />
                <data android:pathPattern=".*\\..*\\.ceb" />
                <data android:pathPattern=".*\\..*\\..*\\.ceb" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.ceb" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ceb" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="file" />
                <data android:host="*" />
                <data android:mimeType="*/*" />
                <data android:pathPattern=".*\\.ceb" />
                <data android:pathPattern=".*\\..*\\.ceb" />
                <data android:pathPattern=".*\\..*\\..*\\.ceb" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\.ceb" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ceb" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
                <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.ceb" />
            </intent-filter>
        </activity>
    </application>
</manifest>

My gradle file:我的 gradle 文件:

import com.android.build.OutputFile

// Top-level build file where you can add configuration options common to all
// sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.5.21"
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
        gradlePluginPortal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.2'
        classpath 'com.google.gms:google-services:4.3.8'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'

repositories {
    google()
    mavenCentral()
    jcenter()
    maven { url 'https://jitpack.io' }
}

configurations {
    conversationsFreeCompatImplementation
}

dependencies {
    implementation 'androidx.viewpager:viewpager:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    implementation 'org.sufficientlysecure:openpgp-api:10.0'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'androidx.exifinterface:exifinterface:1.3.2'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation 'androidx.emoji:emoji:1.1.0'
    implementation 'com.google.android.material:material:1.4.0'
    conversationsFreeCompatImplementation 'androidx.emoji:emoji-bundled:1.1.0'
    implementation 'org.bouncycastle:bcmail-jdk15on:1.64'
    //zxing stopped supporting Java 7 so we have to stick with 3.3.3
    //https://github.com/zxing/zxing/issues/1170
    implementation 'com.google.zxing:core:3.4.1'
    implementation 'de.measite.minidns:minidns-hla:0.2.4'
    implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
    implementation 'org.whispersystems:signal-protocol-java:2.8.1'
    implementation 'com.makeramen:roundedimageview:2.3.0'
    implementation "com.wefika:flowlayout:0.4.1"
    implementation 'net.ypresto.androidtranscoder:android-transcoder:0.3.0'
    implementation 'org.jxmpp:jxmpp-jid:1.0.1'
    implementation 'org.osmdroid:osmdroid-android:6.1.10'
    implementation 'org.hsluv:hsluv:0.2'
    implementation 'org.conscrypt:conscrypt-android:2.5.2'
    implementation 'me.drakeet.support:toastcompat:1.1.0'
    implementation "com.leinardi.android:speed-dial:3.2.0"

    implementation "com.squareup.retrofit2:retrofit:2.9.0"
    implementation "com.squareup.retrofit2:converter-gson:2.9.0"
    implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.2"
    implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2'

    implementation 'com.google.guava:guava:30.1.1-android'
    implementation 'org.webrtc:google-webrtc:1.0.32006'

    // Lifecycle Helper
    implementation "androidx.activity:activity-ktx:1.3.0-rc02"
    implementation "androidx.fragment:fragment-ktx:1.3.6"

    //Navigation
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
    implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'

    //CardView
    implementation "androidx.cardview:cardview:1.0.0"

    //Country Code Picker
    implementation 'com.hbb20:ccp:2.5.3'

    //Firebase
    implementation 'com.google.firebase:firebase-bom:28.3.0'
    implementation 'com.google.firebase:firebase-auth-ktx:21.0.1'
    implementation 'androidx.browser:browser:1.3.0'

    //OTP view
    implementation 'com.github.mukeshsolanki:android-otpview-pinview:2.1.2'

    //Retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

    //Gson
    implementation 'com.google.code.gson:gson:2.8.7'

    //Multidex
    implementation 'androidx.multidex:multidex:2.0.1'

    //Round Image
    implementation 'de.hdodenhof:circleimageview:3.1.0'

    // Button with image and text
    implementation 'com.github.Omega-R:OmegaCenterIconButton:0.0.4@aar'

    //Razor pay
    implementation 'com.razorpay:checkout:1.6.10'

    //Mixpanel Tracking
    implementation 'com.mixpanel.android:mixpanel-android:5.9.1'

    //Loading screen
    implementation 'com.wang.avi:library:2.1.3'

    //Loading
    implementation 'com.wang.avi:library:2.1.3'

    //Form
    implementation 'com.quickbirdstudios:surveykit:1.1.0'
}

ext {
    travisBuild = System.getenv("TRAVIS") == "true"
    preDexEnabled = System.getProperty("pre-dex", "true")
    abiCodes = ['armeabi-v7a': 1, 'x86': 2, 'x86_64': 3, 'arm64-v8a': 4]
}

android {
    compileSdkVersion 31

    defaultConfig {
        minSdkVersion 24
        targetSdkVersion 31
        versionCode 44
        versionName "2.0.4"
        multiDexEnabled = true
        archivesBaseName += "-$versionName"
        applicationId "com.app.app"
        resValue "string", "applicationId", applicationId
        def appName = "app"
        resValue "string", "app_name", appName
        buildConfigField "String", "APP_NAME", "\"$appName\""
    }

    splits {
        abi {
            universalApk true
            enable true
        }
    }

    configurations {
        compile.exclude group: 'org.jetbrains' , module:'annotations'
    }

    dataBinding {
        enabled true
    }

    dexOptions {
        // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
        preDexLibraries = preDexEnabled && !travisBuild
        jumboMode true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    flavorDimensions("mode", "distribution", "emoji")

    productFlavors {

        conversations {
            dimension "mode"
        }
        free {
            dimension "distribution"
            versionNameSuffix "+f"
        }
        compat {
            dimension "emoji"
            versionNameSuffix "c"
        }
    }

    sourceSets {
        conversationsFreeCompat {
            java {
                srcDir 'src/freeCompat/java'
                srcDir 'src/conversationsFree/java'
            }
        }
    }

    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            versionNameSuffix "r"
        }
        debug {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            versionNameSuffix "d"
        }
    }


    if (new File("signing.properties").exists()) {
        Properties props = new Properties()
        props.load(new FileInputStream(file("signing.properties")))

        signingConfigs {
            release {
                storeFile file(props['keystore'])
                storePassword props['keystore.password']
                keyAlias props['keystore.alias']
                keyPassword props['keystore.password']
            }
        }
        buildTypes.release.signingConfig = signingConfigs.release
    }

    lintOptions {
        disable 'MissingTranslation', 'InvalidPackage','AppCompatResource'
    }

    subprojects {

        afterEvaluate {
            if (getPlugins().hasPlugin('android') ||
                    getPlugins().hasPlugin('android-library')) {

                configure(android.lintOptions) {
                    disable 'AndroidGradlePluginVersion', 'MissingTranslation'
                }
            }

        }
    }

    packagingOptions {
        exclude 'META-INF/BCKEY.DSA'
        exclude 'META-INF/BCKEY.SF'
    }

    android.applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
            if (baseAbiVersionCode != null) {
                output.versionCodeOverride = (100 * variant.versionCode) + baseAbiVersionCode
            }
        }

    }
}

I had this issue and one of the libraries I used wasn't setting it correctly.我遇到了这个问题,我使用的库之一没有正确设置它。

Find location查找位置

First of all, we need to find the exact location and/or cause for the error,首先,我们需要找到错误的确切位置和/或原因,
which can be done with different approaches (see below).这可以通过不同的方法来完成(见下文)。

Find by inspecting merged-manifest (approach #1)通过检查合并清单查找(方法 #1)

You can find it by doing the steps:您可以通过以下步骤找到它:

  • Set target SDK to 30 (to silence 31+ errors).将目标 SDK 设置为 30(以消除 31+ 错误)。

  • Open application's manifest ( AndroidManifest.xml ) and click on " Merged Manifest " tab on bottom of your edit pane:打开应用程序的清单 ( AndroidManifest.xml ) 并单击编辑窗格底部的“ Merged Manifest ”选项卡:
    Android Studio 中的合并清单

    Which if you configure build.gradle like:如果您像这样配置build.gradle

     allprojects { buildDir = "${rootProject.rootDir}/build/${project.name}" }

    Something similar should be in a sub-path like:类似的东西应该在子路径中,例如:

     build/my-app/intermediates/merged_manifest/debug/AndroidManifest.xml
  • Go to the individual manifest file of all the libraries (You can skip this step if the merged manifest is created and you can just look into the merged manifest)转到所有库的单个清单文件(如果创建了合并清单,您可以跳过此步骤,您可以查看合并清单)

  • Search if there's any entry of type activity, service, receiver, or provider which does not have an exported attribute, and for each entry follow below "Fix found entries" section (or see once for how to set exported attribute).搜索是否有任何类型为活动、服务、接收者或提供者的条目没有exported属性,对于每个条目,请遵循“修复找到的条目”部分(或查看一次以了解如何设置exported属性)。

  • Set target SDK back to 31 (or whatever it was before changing to 30).将目标 SDK 设置回 31(或更改为 30 之前的任何值)。

Find by console logs (approach #2)通过控制台日志查找(方法 #2)

  • In Git-bash run something like:在 Git-bash 中运行类似:

     ./gradlew assembleDebug --stacktrace --info | tee my-logs.txt
  • Open my-logs.txt file (which previous step created, in your preferred text-editor).打开my-logs.txt文件(在您首选的文本编辑器中创建上一步)。

  • Now, the exact location is hidden in the logs, hence search in the created my-logs.txt file, for these keywords:现在,确切的位置隐藏在日志中,因此在创建my-logs.txt文件中搜索这些关键字:

    • activity#
    • service#
    • receiver#
    • provider#
  • Which should find something like:应该找到类似的内容:

activity#androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity
ADDED from [androidx.test:core:1.2.0] C:\Users\Admin\.gradle\caches\transforms-3\709730c74fe4dc9f8fd991eb4d1c2adc\transformed\jetified-core-1.2.0\AndroidManifest.xml:27:9-33:20
  • Open AndroidManifest.xml file that previous steps did find, search if there's any entry of type activity , service , receiver , or provider which does not have an exported attribute, and see below "Fix found entries" section (for how to set each entries exported attribute).打开前面步骤确实找到的AndroidManifest.xml文件,搜索是否有任何类型为activityservicereceiverprovider条目没有exported属性,并参见下面的“修复找到的条目”部分(关于如何设置每个条目exported的属性)。

Note that (at time of writting) passing --stacktrace alone did not include location info ;-)请注意(在撰写本文时)仅传递--stacktrace不包括位置信息;-)

Fix found entries修复找到的条目

If the real (not build-generated) source of found entry is in root-project's manifest (or somewhere you can alter), set exported attribute to corresponding need (which is normally false ) therein directly, like:如果找到条目的真实(非构建生成)源位于根项目的清单(或您可以更改的地方)中,则直接将exported的属性设置为相应的需要(通常为false ),例如:

<receiver
    android:name="<name_of_the_entry>"
    android:exported="false or true"
    tools:node="merge" />

Note that both android:exported="..." and tools:node="merge" are set above.请注意,上面设置了android:exported="..."tools:node="merge"

But if found entry's specification is written in the manifest of a third-party library (which's real-source you can't alter), override the specification of said library by adding it to our root-project's manifest, for example like:但是,如果找到的条目的规范写在第三方库的清单中(这是您无法更改的真实源代码),则通过将其添加到我们的根项目清单中来覆盖该库的规范,例如:

<provider
    android:name="com.squareup.picasso.PicassoProvider"
    android:exported="false"
    tools:node="merge"
    tools:overrideLibrary="com.squareup.picasso.picasso" />

Note that this time tools:overrideLibrary="..." is set as well.请注意,这一次tools:overrideLibrary="..."也已设置。

For more information see Documentation ,有关更多信息,请参阅文档
and/or Similar issue in a SDK .和/或SDK 中的类似问题

Fixing such issue can be a bit cumbersome, cause the IDE doesn't provide details on the error, it just tells you that there is an Activity, Receiver or Service without the exported parameter, but does not tell you which one it is.修复这样的问题可能有点麻烦,因为 IDE 没有提供错误的详细信息,它只是告诉你有一个没有导出参数的 Activity、Receiver 或 Service,但没有告诉你它是哪一个。 As Jakos recommend, you can manually check the merged manifest, or use this script in case the generated manifest is too large.正如 Jakos 建议的那样,您可以手动检查合并的清单,或者使用此脚本以防生成的清单太大。

After that you can modify the affected entries by adding the exported attribute if it is part of your project, or override it if it's part of a library with:之后,如果它是项目的一部分,您可以通过添加导出的属性来修改受影响的条目,或者如果它是库的一部分,则覆盖它:

<activity android:name="name_of_the_activity_inside_library>"
    android:exported="false|true"
    tools:node="merge" />

UPDATE: The manifest merge task seems to fail without generating the manifest when targeting android S and this problems are detected, so my advise is to compile the app using a targetSdk lower than 31, and then inspect the generated manifest either manually or using the script I linked.更新:当针对 android S 并且检测到此问题时,清单合并任务似乎失败而没有生成清单,因此我的建议是使用低于 31 的 targetSdk 编译应用程序,然后手动或使用脚本检查生成的清单我链接了。 (you can find the merged manifest on the build folder or by inspecting the generated apk) (您可以在 build 文件夹中或通过检查生成的 apk 找到合并的清单)

For instrumented test, if you are using compose test, make sure you add androidx.test.ext:junit in addition to compose.ui dependencies对于插桩测试,如果您使用的是 compose 测试,请确保在 compose.ui 依赖项之外添加androidx.test.ext:junit

androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.0.4"

Check your build.gradle file for:检查你的build.gradle文件:

debugImplementation "androidx.fragment:fragment-testing:<version>"

and if present change it to:如果存在,请将其更改为:

androidTestImplementation "androidx.fragment:fragment-testing:<version>"

It should always have been androidTestImplementation but there was some dependency issue before and it was necessary to use debugImplementation as a workaround.它应该始终是androidTestImplementation但之前存在一些依赖问题,因此有必要使用debugImplementation作为解决方法。 The IDE actually prompted you to do this. IDE 实际上会提示您执行此操作。 But evidently it is fixed for SDK 31, and if you leave it as debugImplementation you get the android:exported -missing manifest error which comes from a manifest.xml in a dependent package.但显然它已针对 SDK 31 进行了修复,如果将其保留为 debugImplementation,则会出现android:exported -missing manifest 错误,该错误来自依赖包中的manifest.xml

Change targetSdkVersion back to 30 targetSdkVersion回 30
You can leave compileSdkVersion at 31您可以将compileSdkVersion为 31
Then hit Run然后点击运行

After the build has failed go to AndroidManifest.xml and in the bottom click merged manifest see which activities which have intent-filter but don't have exported=true attribute.构建失败后转到 AndroidManifest.xml 并在底部单击合并的清单,查看哪些活动具有intent-filter但没有exported=true属性。 Or you can just get the activities which are giving error.或者您可以只获取给出错误的活动。

Add these activities to your App manifest with android:exported="true" and app tools:node="merge" this will add exported attribute to the activities giving error.使用android:exported="true"和 app tools:node="merge"将这些活动添加到您的应用清单中,这会将导出的属性添加到给出错误的活动中。 Example:例子:

     <activity
                android:name="<activity which is giving error>"
                android:exported="true"
                tools:node="merge" />

You will have to do this once, you can remove this once the library developers update their libs.您必须这样做一次,一旦库开发人员更新他们的库,您就可以将其删除。

由于目标 sdk 更新为 31 android 12,因此您必须在 manifest.xml 中的活动午餐器中进行 android 导出

 android:exported="true"

The problem in my case was the test:core:1.3.0 (see screen shot).我的问题是 test:core:1.3.0 (见屏幕截图)。

I had to override the manifest entries for this library and declare the android:exported property:我必须重写这个库的清单条目并声明android:exported属性:

<activity android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
android:exported="true"
tools:node="merge"/>

<activity android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity"
android:exported="true"
tools:node="merge"/>

<activity android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity"
android:exported="true"
tools:node="merge"/>

在此处输入图像描述

<activity
     android:name=".MainActivity"
     android:exported="true" <** add this line on AndroidManifest.xml**
     android:launchMode="singleTop"
     android:theme="@style/LaunchTheme"
 </activity>

I'm not sure what you're using to code, but in order to set it in Android Studio, open the manifest of your project and under the "activity" section, put android:exported="true" (or false if that is what you prefer).我不确定你用什么来编码,但是为了在 Android Studio 中设置它,打开你的项目的清单并在“活动”部分下,把android:exported="true" (或者如果是 false是你喜欢的)。 I have attached an example.我附上了一个例子。

If your app targets Android 12 or higher, you must declare these attribution tags in your app's manifest file.如果您的应用面向 Android 12 或更高版本,则必须在应用的清单文件中声明这些归因标签。 If the app component includes the LAUNCHER category, set android:exported to true.如果应用组件包含 LAUNCHER 类别,请将 android:exported 设置为 true。

 <activity
        android:name="com.test.activity.SplashActivity"
        android:clearTaskOnLaunch="true"
        android:label="@string/app_name"
        android:launchMode="singleTop"
        android:noHistory="true"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar"
        android:exported="true">

Also check receiver or service in Androidmanifest, if you are using any receiver or service set android:exported="true" or false according requirement.还要检查 Androidmanifest 中的接收器或服务,如果您根据要求使用任何接收器或服务集 android:exported="true" 或 false。

   <receiver
        android:name="com.test.receiver.ShareReceiver"
        android:exported="true">
        <intent-filter>
            <action android:name="com.test.fcm.android.action.broadcast" />
        </intent-filter>
    </receiver>

   <service
        android:name="com.google.android.gms.tagmanager.InstallReferrerService"
        android:exported="true" />

Also update all your gradle dependency.还要更新你所有的 gradle 依赖。

I have updated following dependency as per requirement.我已根据要求更新了以下依赖项。

testImplementation 'junit:junit:4.13.2' 
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.razorpay:checkout:1.6.15'

Hope it will help you as well.希望它也能帮助你。

I happen to know that issue in the android 12 specifically.我碰巧在 android 12 中特别知道这个问题。 There is already a bug raised in Android SDK. Android SDK 中已经出现了一个错误。 In the solution of your problem here is a file you can add in android studio and run the method.在您的问题的解决方案中,您可以在 android studio 中添加一个文件并运行该方法。

Enable android exported file 启用 android 导出文件

Then run the def methods and try to build.然后运行 ​​def 方法并尝试构建。 It is tried and tested working method.它是久经考验的工作方法。

If you sure about adding exported to every element in manifest file and still got this error, simply :如果您确定要将导出添加到清单文件中的每个元素并且仍然出现此错误,只需:

  1. switch to project directory and open merged manifest file in app\build\intermediates\merged_manifest切换到项目目录并在 app\build\intermediates\merged_manifest 中打开合并的清单文件
  2. search for any component that contains intent-filter and didn't have exported attribute搜索任何包含意图过滤器且没有导出属性的组件
  3. override this component in your manifest file by copy past it to your main manifest file通过将其复制到主清单文件来覆盖清单文件中的此组件

tip: if you can't find merged file because it's already failed to generate it .temporary downgrade to targetSdkVersion 30 and compileSdkVersion 30 and build project to generate this file and then follow above steps and then upgrade to 31 (android 12)提示:如果您找不到合并文件,因为它已经无法生成它。临时降级到 targetSdkVersion 30 和 compileSdkVersion 30 并构建项目以生成此文件,然后按照上述步骤然后升级到 31(android 12)

Found this solution here , works for me. 在这里找到了这个解决方案,对我有用。 This is given by official razorpay github.这是由官方 razorpay github 提供的。 They've mentioned they'll fix it in next release.他们已经提到他们将在下一个版本中修复它。

<receiver
    android:name="com.razorpay.RzpTokenReceiver"
    android:exported="false">
    <intent-filter>
        <action android:name="rzp.device_token.share" />
    </intent-filter>
</receiver>

<activity
    android:name="com.razorpay.CheckoutActivity"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:exported="true"
    android:theme="@style/CheckoutTheme">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <data
            android:host="rzp.io"
            android:scheme="io.rzp" />
    </intent-filter>
</activity>

如果您正在使用 flutter ,将flutter_local_notifications升级到最新版本(现在是 9.3.2)可能会解决此错误。

Case 1: No submodules or libraries案例 1:没有子模块或库

This issue started with SDK 31. If you don't have any libraries or submodules add此问题从 SDK 31 开始。如果您没有任何库或子模块,请添加

android:exported="true" <!-- or false as required -->

You can right click on the tag and Android Studio will suggest you.您可以右键单击标签,Android Studio 会建议您。

Case 2: With submodules or libraries案例 2:使用子模块或库

If you have other libraries or modules that you are importing, you have to override them too.如果您有其他要导入的库或模块,您也必须覆盖它们。 For that see the tab 'Merged Manifest'.为此,请参阅“合并清单”选项卡。 OR You can open或者你可以打开

<ProjectRoot>/app/build/intermediates/merged_manifest/<your flavor>/AndroidManifest.xml <ProjectRoot>/app/build/intermediates/merged_manifest/<你的风格>/AndroidManifest.xml

in an editor.在编辑器中。 I prefer the second method as Merged manifest doesn't allow to search from Android Studio.我更喜欢第二种方法,因为合并清单不允许从 Android Studio 搜索。

  1. Copy <activity>, <receiver> or any others causing build errors.复制 <activity>、<receiver> 或任何其他导致构建错误的内容。
  2. Paste them to Main Manifest将它们粘贴到主清单
  3. Add android:exported="true" or android:exported="false" as required根据需要添加 android:exported="true" 或 android:exported="false"
  4. Rebuild重建

Case 3: If None of the above works案例3:如果以上都不起作用

If none of the above works, you will have to wait until your library provider makes necessary changes.如果上述方法都不起作用,您将不得不等到您的图书馆提供商进行必要的更改。 Until they make changes, you may revert SDK version to 30 or lower.在他们做出更改之前,您可以将 SDK 版本恢复到 30 或更低版本。 Lowering sdk should fix the issue temporarily.降低 sdk 应该可以暂时解决这个问题。

My problem was that we were using older hilt version 2.38.1:我的问题是我们使用的是较旧的刀柄版本 2.38.1:

"com.google.dagger:hilt-android:2.38.1"
"com.google.dagger:hilt-android-gradle-plugin:2.38.1"
"com.google.dagger:hilt-android-compiler:2.38.1"
"com.google.dagger:hilt-android-testing:2.38.1"

"com.google.dagger:hilt-android-testing:2.38.1" under the hood depends on core testing library 1.3.0, which does set exported properties.引擎盖下的“com.google.dagger:hilt-android-testing:2.38.1”依赖于核心测试库 1.3.0,它确实设置了导出的属性。

To fix this, make sure you are using latest dagger hilt version (2.40.5 works):要解决此问题,请确保您使用的是最新的匕首刀柄版本(2.40.5 有效):

"com.google.dagger:hilt-android:2.40.5"
"com.google.dagger:hilt-android-gradle-plugin:2.40.5"
"com.google.dagger:hilt-android-compiler:2.40.5"
"com.google.dagger:hilt-android-testing:2.40.5" 

In my case I update fragment-testing to 1.5.3 version and this helped me:就我而言,我将fragment-testing更新为1.5.3版本,这对我有帮助:

dependencies {
    debugImplementation androidx.fragment:fragment-testing:1.5.3
}

I was getting this error thrown what targeting sdk 31 and found that the solution was in my build.gradle file.我收到这个错误,什么目标 sdk 31,发现解决方案在我的 build.gradle 文件中。 I was using implementation on my compose test dependency instead of testImplementation .我在我的 compose 测试依赖项上使用implementation而不是testImplementation

Seems unrelated I know but when you look at your merge manifest with a misused test dependency you will see tags added for InstrumentedActivity which will be missing the exported=true field.我知道似乎无关,但是当您查看带有误用测试依赖项的合并清单时,您会看到为InstrumentedActivity添加的标签,这些标签将缺少exported=true字段。

只需更新所有依赖项,它应该可以工作

Quoting official docs about this behavior change in android 12 , you should look for activities containing intent-filter and those are the ones that need to be updated by setting explicitly the value of android:exported .引用有关 android 12 中此行为更改的官方文档,您应该查找包含intent-filter的活动,这些活动需要通过明确设置android:exported的值来更新。

Build logs should point exactly to the activity with undeclared exported flag that stopped your build.构建日志应准确指向带有停止构建的未声明导出标志的活动。 You should see something like this between the last lines of the console's output of install gradle's commands:您应该在install gradle 命令的控制台输出的最后几行之间看到类似这样的内容:

> java.util.concurrent.ExecutionException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/xxxxx.tmp/base.apk (at Binary XML file line #129): YOUR.FULLY.QUALIFIED.NAME.FAILING.ACTIVITY: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present

YOUR.FULLY.QUALIFIED.NAME.FAILING.ACTIVITY should point you to the specific activity that is blocking your build. YOUR.FULLY.QUALIFIED.NAME.FAILING.ACTIVITY应该指向阻止构建的特定活动。

Here is also the link to the implications of setting android:exported .这也是设置android:exported 含义的链接

For people with problems still using Flutter, in addition to putting exported=true in the application's <activity, you need to put it in the <activity of the installed plugins.对于还在使用 Flutter 有问题的人,除了将exported=true 放在应用程序的<activity 中外,还需要将其放在已安装插件的<activity 中。 As I use the simpleauthflutter package, it generates an activity in androidmanifest and I put exported=true.当我使用 simpleauthflutter 包时,它会在 androidmanifest 中生成一个活动,并且我设置了exported=true。 That's the only way to work.这是唯一的工作方式。 It will look like this:它看起来像这样:

This is the most common issue after upgrading your TargetSDK 32 or Android Studio with API Android 12 support.这是使用 API Android 12 支持升级 TargetSDK 32 或 Android Studio 后最常见的问题。

To relate this was my error:与此相关的是我的错误:

在此处输入图像描述

The errors were:错误是:

 Error:
    android:exported needs to be explicitly specified for element <receiver#com.onesignal.BootUpReceiver>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
D:\iptvapp\iptvapp\app\src\main\AndroidManifest.xml:99:9-103:20 Error:
    android:exported needs to be explicitly specified for element <receiver#com.onesignal.UpgradeReceiver>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

Then by using the merged Mainfest Clikc on the Libirary that has error for instacne onesingal.然后通过使用合并的 Mainfest Clikc 对 instacne onesingal 有错误的库。

在此处输入图像描述

Then copy the error if its the receiver part and add it to your main manifest file as follows with然后复制错误(如果它是接收器部分)并将其添加到您的主清单文件中,如下所示

android:exported安卓:导出

set to true on.设置为真。

and them还有他们

 <receiver android:name="com.onesignal.BootUpReceiver"  android:exported="true">
                <intent-filter>
                    <action android:name="android.intent.action.BOOT_COMPLETED" />
                    <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                </intent-filter>
            </receiver>
            <receiver android:name="com.onesignal.UpgradeReceiver" android:exported="true" >
                <intent-filter>
                    <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
                </intent-filter>
            </receiver>

worked like a charm!像魅力一样工作!

Add添加

tools:node="merge"

to

<activity...

and upgrade和升级

androidx.core.test 

to latest version.到最新版本。

Will work like a charm :)会像魅力一样工作:)

Copy and paste the gradle script above the root build.gradle file将 gradle 脚本复制并粘贴到根 build.gradle 文件上方

Gradle Script for Android 12 Required Merge Gradle Android 的脚本 12 需要合并

And execute the task并执行任务

doAddAndroidExportedIfNecessary doAddAndroidExportedIfNecessary

(for Add Automatically the tag required to missing activity - service - receiver ) (对于自动添加缺少活动所需的标签 - 服务 - 接收器)

doAddAndroidExportedForDependencies doAddAndroidExportedForDependencies

(for Add Automatically the tag required to Dependencies missing activity - service - receiver ) (对于自动添加依赖项缺少活动所需的标签 - 服务 - 接收器)

Hope this script can resolved your problem希望这个脚本可以解决你的问题

This error occur when we make the targetSkdVersion=31 for latest version 12, and the error cause if we have not use android:exported="true" in the launcher activity and android:exported="false" in other intent_filter,service or broadcast receiver.当我们为最新版本 12 设置 targetSkdVersion=31 时会发生此错误,如果我们没有在启动器活动中使用 android:exported="true"在其他 intent_filter、服务或广播中使用 android:exported="false" 则错误原因接收者。 We should write android:exported="true" only for launcher activity like this:我们应该只为这样的启动器活动编写 android:exported="true" :

 <activity 
         android:name="com.abc.MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

and write android:exported="false" for service or broadcast receiver etc, like these:并为服务或广播接收器等编写 android:exported="false" ,如下所示:

      <service android:name="com.startapp.sdk.adsbase.InfoEventService"
        android:exported="false"/>
    <service
        android:name="com.startapp.sdk.adsbase.PeriodicJobService"
        android:permission="android.permission.BIND_JOB_SERVICE"
        android:exported="false"/>

    <receiver android:name="com.startapp.sdk.adsbase.remoteconfig.BootCompleteListener"
        android:exported="false">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

but if these services or broadcast receiver or used in the implemented library which mean it will be inside the manifest file of the library.但是如果这些服务或广播接收器或在实现的库中使用,这意味着它将在库的清单文件中。 so we will copy those service and broadcast receiver etc from those library manifest file and will paste in our main activity manifest, as like above i have copied the intent_fileter,services or broadcast receiver of the start.io sdk implented in my app to my main mainfest file.所以我们将从那些库清单文件中复制那些服务和广播接收器等,并将粘贴到我们的主要活动清单中,如上所述,我已经复制了开始的 intent_fileter、服务或广播接收器。io sdk 在我的应用程序中实现到我的主要主要文件。

How to copy merger manifest file to main manifest file如何将合并清单文件复制到主清单文件

  • open your project's AndroidManifest.xml.打开项目的 AndroidManifest.xml。
  • at the bottom of the window, click on the Merged Manifest tab.在 window 的底部,单击 Merged Manifest 选项卡。
  • look for any activity that includes an intent-filter tag and is missing the android:exported attribute查找任何包含 intent-filter 标签且缺少 android:exported 属性的活动
  • now copy all those to main manifest file.现在将所有这些复制到主清单文件。

Search by phrase "intent-filter" and then add " android:exported="false" to every top xml element按短语“intent-filter”搜索,然后将“android:exported="false"添加到每个顶部 xml 元素

<receiver
        android:name=".listener.SmsListener"
        android:enabled="true"
        android:exported="false"
        >
        <intent-filter android:priority="1000">
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
        </intent-filter>
</receiver>
My problem was that I didn't find all missing android:exported我的问题是我没有找到所有丢失android:exported

I kept looking for missing android:exported="true|false" .我一直在寻找丢失的android:exported="true|false" Added it everywhere I saw.在我看到的任何地方都添加了它。 Problem still persisted.问题仍然存在。

Solution解决方案

I had buildToolsVersion = "28.0.3" in gradle so the merge manifest error logs didn't help me at all.我在 gradle 中有buildToolsVersion = "28.0.3"所以合并清单错误日志对我没有任何帮助。

So I upgraded to buildToolsVersion = "31.0.0" and the merge manifest showed me where the missing export was located.所以我升级到buildToolsVersion = "31.0.0"并且合并清单向我显示了丢失的导出所在的位置。

Go to the AndroidManifest.xml Click Merged Manifest tab and Find the Keword in project EG: Error: android:exported needs to be explicitly specified for element <activity#com.cpa.accountManagement.ui.authenticated.splash.SplashActivity>. Go 到 AndroidManifest.xml 单击 Merged Manifest 选项卡并在项目 EG 中找到 Keword:错误:android:需要为元素 <activity#com.cpa.accountManagement.ui.authenticated.splash.SplashActivity> 明确指定导出。 Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined.针对 Android 12 及更高版本的应用需要为android:exported指定一个明确的值,当相应的组件定义了一个 Intent 过滤器时。 See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.有关详细信息,请参阅https://developer.android.com/guide/topics/manifest/activity-element#exported accountManagement.app main manifest (this file), line 52 accountManagement.app 主清单(此文件),第 52 行

Find the "SplashActivity" Tag and add android:exported="true"找到“SplashActivity”标签并添加 android:exported="true"

For those who are still facing this error and did not find a solution...对于那些仍然面临这个错误并且没有找到解决方案的人......

add this is manifest file:添加这是清单文件:

<service
       android:name="org.jitsi.meet.sdk.ConnectionService"
       android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
       android:exported="true">
       <intent-filter>
           <action android:name="android.telecom.ConnectionService" />
       </intent-filter>
</service>

Just add these in build.gradle...只需在 build.gradle 中添加这些...

androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.3.3"

Works like charm!像魅力一样工作!

for me adding exported=true in activity section worked对我来说,在活动部分添加exported=true有效

just add this in your AndroidManifest.xml只需将其添加到您的 AndroidManifest.xml

android:exported="true"

inside your <activity>在你的<activity>里面

Temporary solution临时解决方案

change compileSdk, targetSdk to将 compileSdk、targetSdk 更改为

compileSdk 30 targetSdk 30 compileSdk 30 targetSdk 30

in gradle file在 gradle 文件中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 android:exported 需要明确指定<receiver> . 在 Flutter 中面向 Android 12 及更高版本的应用 - android:exported needs to be explicitly specified for <receiver>. Apps targeting Android 12 and higher In Flutter Android:exported 需要明确指定<service> .针对 Android 12 及更高版本的应用程序</service> - Android:exported needs to be explicitly specified for <service>.Apps targeting Android 12 and higher android:exported 需要明确指定<service> . 针对 Android 12 的应用程序</service> - android:exported needs to be explicitly specified for <service>. Apps targeting Android 12 android:exported 需要明确指定<activity></activity> - android:exported needs to be explicitly specified for <activity> 清单合并失败:需要明确指定 android:exported<activity> - Manifest merger failed : android:exported needs to be explicitly specified for <activity> Manifest合并失败:android:exported needs to be explicitly specified for<receiver></receiver> - Manifest merger failed : android:exported needs to be explicitly specified for <receiver> "我设置了 android:exported 但我仍然收到错误:android:exported 需要明确指定<receiver>" - I set android:exported but I am still getting error: android:exported needs to be explicitly specified for <receiver> 清单合并失败:需要为元素显式指定 android:exported <service#com.marianhello.bgloc.sync.authenticatorservice></service#com.marianhello.bgloc.sync.authenticatorservice> - Manifest merger failed : android:exported needs to be explicitly specified for element <service#com.marianhello.bgloc.sync.AuthenticatorService> Android应用程序活动中的导出属性 - Exported attribute in activity of android apps Android Studio 错误:“清单合并失败:针对 Android 12 的应用程序” - Android Studio error: "Manifest merger failed: Apps targeting Android 12"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM