清单合并因多个错误而失败 | Android 12 及更高版本需要为 `android:exported` 指定一个明确的值
Manifest merger failed with multiple errors | Android 12 and higher are required to specify an explicit value for `android:exported`
我是 java 和 android 的新手。在 运行 模拟器上,我遇到了这个合并冲突问题。
完整的错误信息:
Execution failed for task ':processDefaultsDebugMainManifest'.
Manifest merger failed with multiple errors, see logs
Error: android:exported needs to be explicitly specified for element <activity#com.squareup.leakcanary.internal.DisplayLeakActivity>. 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. main manifest (this file), line 35
这里
AndroidManifest.xml
<?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="com.iab.omid.sampleapp">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application
android:networkSecurityConfig="@xml/network_security_config"
android:name=".AdApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".AdListActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
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=".AdDetailActivity"
android:label="@string/title_ad_detail"
android:parentActivityName=".AdListActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.iab.omid.sampleapp.AdListActivity"/>
</activity>
</application>
和build.gradle
buildscript {
ext {
targetCompatibility = JavaVersion.VERSION_1_8
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
}
}
apply plugin: 'com.android.application'
repositories {
google()
maven {
url "https://plugins.gradle.org/m2/"
}
}
android {
compileSdk 32
flavorDimensions ""
defaultConfig {
applicationId "com.iab.omid.sampleapp"
minSdkVersion 18
targetSdkVersion 32
versionCode 1020
versionName "1.1.3"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
buildConfigField("String", "PARTNER_NAME", "\"com.iab.omid.sampleapp\"")
buildConfigField("String", "VENDOR_KEY", "\"dummyVendor\"")
buildConfigField("String", "VALIDATION_SCRIPT_URL", "\"complianceomsdk.iabtechlab.com\"")
// This override URL will only change URLs seen in Charles proxy for Html ads
buildConfigField("String", "VALIDATION_SCRIPT_URL_OVERRIDE", "\"complianceomsdk.iabtechlab.com\"")
buildConfigField("String", "VERIFICATION_URL", "\"https://s3-us-west-2.amazonaws.com/omsdk-files/compliance-js/omid-validation-verification-script-v1.js\"")
buildConfigField("String", "VERIFICATION_PARAMETERS", "\"http://omid-android-reference-app/sendMessage?msg=\"")
buildConfigField("String", "HTML_DISPLAY_AD", "\"https://omsdk-files.s3-us-west-2.amazonaws.com/creatives/html_display_creative.html\"")
buildConfigField("String", "HTML_VIDEO_AD", "\"https://omsdk-files.s3-us-west-2.amazonaws.com/creatives/html_video_creative.html\"")
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
defaults {
}
instrumentationTest {
buildConfigField("String", "VERIFICATION_URL", "\"https://omsdk-files.s3-us-west-2.amazonaws.com/fullstack/fullstack-verification-script.js\"")
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion '32.0.0'
}
dependencies {
implementation fileTree(include: ['*.aar'], dir: '../')
implementation 'com.google.android.exoplayer:exoplayer:2.10.5', {
exclude group: 'com.android.support'
}
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'commons-io:commons-io:2.4'
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.3.8'
implementation 'org.apache.commons:commons-lang3:3.6'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation 'androidx.annotation:annotation:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'org.mockito:mockito-android:4.3.1'
androidTestImplementation 'com.azimolabs.conditionwatcher:conditionwatcher:0.2'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
task downloadOMSDKJS(type:Exec) {
if (!file('./src/main/res/raw/omsdk_v1.js').exists()) {
workingDir '../'
commandLine 'sh', './scripts/download-omsdk-js.sh'
} else {
// We need a dummy execCommand here.
commandLine 'sh'
}
}
preBuild.dependsOn downloadOMSDKJS
我已经在 Whosebug 上尝试了许多其他可用的解决方案,但仍然没有取得任何进展。
如果需要分享更多详细信息以解决此问题,请在评论中告诉我。
您的图书馆可能在 activity
上定义了“intent_filter”
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
如果您的应用程序面向 API 31+,则属性“exported”是必需的。
因此,由于该库的开发人员没有针对 API31,因此导出的标志对他而言不是强制性的。他在没有导出属性的情况下构建了它。
所以您可以做的是重新定义清单上的特定 class 以明确声明它是否导出。例如:
<activity android:name="com.squareup.leakcanary.internal.DisplayLeakActivity"
android:exported="true"/>
我是 java 和 android 的新手。在 运行 模拟器上,我遇到了这个合并冲突问题。
完整的错误信息:
Execution failed for task ':processDefaultsDebugMainManifest'.
Manifest merger failed with multiple errors, see logs
Error: android:exported needs to be explicitly specified for element <activity#com.squareup.leakcanary.internal.DisplayLeakActivity>. 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. main manifest (this file), line 35
这里 AndroidManifest.xml
<?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="com.iab.omid.sampleapp">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application
android:networkSecurityConfig="@xml/network_security_config"
android:name=".AdApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".AdListActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
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=".AdDetailActivity"
android:label="@string/title_ad_detail"
android:parentActivityName=".AdListActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.iab.omid.sampleapp.AdListActivity"/>
</activity>
</application>
和build.gradle
buildscript {
ext {
targetCompatibility = JavaVersion.VERSION_1_8
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
}
}
apply plugin: 'com.android.application'
repositories {
google()
maven {
url "https://plugins.gradle.org/m2/"
}
}
android {
compileSdk 32
flavorDimensions ""
defaultConfig {
applicationId "com.iab.omid.sampleapp"
minSdkVersion 18
targetSdkVersion 32
versionCode 1020
versionName "1.1.3"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
buildConfigField("String", "PARTNER_NAME", "\"com.iab.omid.sampleapp\"")
buildConfigField("String", "VENDOR_KEY", "\"dummyVendor\"")
buildConfigField("String", "VALIDATION_SCRIPT_URL", "\"complianceomsdk.iabtechlab.com\"")
// This override URL will only change URLs seen in Charles proxy for Html ads
buildConfigField("String", "VALIDATION_SCRIPT_URL_OVERRIDE", "\"complianceomsdk.iabtechlab.com\"")
buildConfigField("String", "VERIFICATION_URL", "\"https://s3-us-west-2.amazonaws.com/omsdk-files/compliance-js/omid-validation-verification-script-v1.js\"")
buildConfigField("String", "VERIFICATION_PARAMETERS", "\"http://omid-android-reference-app/sendMessage?msg=\"")
buildConfigField("String", "HTML_DISPLAY_AD", "\"https://omsdk-files.s3-us-west-2.amazonaws.com/creatives/html_display_creative.html\"")
buildConfigField("String", "HTML_VIDEO_AD", "\"https://omsdk-files.s3-us-west-2.amazonaws.com/creatives/html_video_creative.html\"")
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
defaults {
}
instrumentationTest {
buildConfigField("String", "VERIFICATION_URL", "\"https://omsdk-files.s3-us-west-2.amazonaws.com/fullstack/fullstack-verification-script.js\"")
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion '32.0.0'
}
dependencies {
implementation fileTree(include: ['*.aar'], dir: '../')
implementation 'com.google.android.exoplayer:exoplayer:2.10.5', {
exclude group: 'com.android.support'
}
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'commons-io:commons-io:2.4'
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.3.8'
implementation 'org.apache.commons:commons-lang3:3.6'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation 'androidx.annotation:annotation:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'org.mockito:mockito-android:4.3.1'
androidTestImplementation 'com.azimolabs.conditionwatcher:conditionwatcher:0.2'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
task downloadOMSDKJS(type:Exec) {
if (!file('./src/main/res/raw/omsdk_v1.js').exists()) {
workingDir '../'
commandLine 'sh', './scripts/download-omsdk-js.sh'
} else {
// We need a dummy execCommand here.
commandLine 'sh'
}
}
preBuild.dependsOn downloadOMSDKJS
我已经在 Whosebug 上尝试了许多其他可用的解决方案,但仍然没有取得任何进展。
如果需要分享更多详细信息以解决此问题,请在评论中告诉我。
您的图书馆可能在 activity
上定义了“intent_filter”debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
如果您的应用程序面向 API 31+,则属性“exported”是必需的。
因此,由于该库的开发人员没有针对 API31,因此导出的标志对他而言不是强制性的。他在没有导出属性的情况下构建了它。
所以您可以做的是重新定义清单上的特定 class 以明确声明它是否导出。例如:
<activity android:name="com.squareup.leakcanary.internal.DisplayLeakActivity"
android:exported="true"/>