提问人:Edwin 提问时间:11/23/2021 最后编辑:Edwin 更新时间:12/8/2021 访问量:3510
Android Studio 中的“Manifest merger failed with multiple errors, see logs”(清单合并失败,出现多个错误,请参阅日志)错误
"Manifest merger failed with multiple errors, see logs" error in android studio
问:
我是 kotlin 的新手,我正在练习基础知识。每当我运行一个简单的代码时,它都会拒绝它运行,我得到一个
Execution failed for task ':app:processDebugAndroidTestManifest'.
> Manifest merger failed with multiple errors, see logs
错误。
我不知道是什么原因,请注意,我确实在运行一个函数print("Hello")
这是我的manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hellokotlin">
<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/Theme.HelloKotlin">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
这是我的:gradle.build
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.hellokotlin"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
我从构建输出中得到这个(因为 logcat 是空的)
Executing tasks: [:app:generateDebugSources, :app:createMockableJar, :app:generateDebugAndroidTestSources, :app:compileDebugUnitTestSources, :app:compileDebugAndroidTestSources, :app:compileDebugSources] in project C:\Users\user\AndroidStudioProjects\HelloKotlin
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:compileLintChecks UP-TO-DATE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:generateDebugSources UP-TO-DATE
> Task :app:createMockableJar UP-TO-DATE
> Task :app:preDebugAndroidTestBuild SKIPPED
> Task :app:compileDebugAndroidTestAidl NO-SOURCE
> Task :app:processDebugAndroidTestManifest FAILED
C:\Users\user\AndroidStudioProjects\HelloKotlin\app\build\intermediates\tmp\manifest\androidTest\debug\tempFile1ProcessTestManifest1728079930965623012.xml Error:
android:exported needs to be explicitly specified for <activity>. 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.
C:\Users\user\AndroidStudioProjects\HelloKotlin\app\build\intermediates\tmp\manifest\androidTest\debug\tempFile1ProcessTestManifest1728079930965623012.xml Error:
android:exported needs to be explicitly specified for <activity>. 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.
C:\Users\user\AndroidStudioProjects\HelloKotlin\app\build\intermediates\tmp\manifest\androidTest\debug\tempFile1ProcessTestManifest1728079930965623012.xml Error:
android:exported needs to be explicitly specified for <activity>. 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.
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
> Task :app:checkDebugAarMetadata UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources UP-TO-DATE
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:extractDeepLinksDebug UP-TO-DATE
> Task :app:processDebugMainManifest UP-TO-DATE
> Task :app:processDebugManifest UP-TO-DATE
> Task :app:processDebugManifestForPackage UP-TO-DATE
> Task :app:processDebugResources UP-TO-DATE
> Task :app:compileDebugKotlin
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:compileDebugJavaWithJavac UP-TO-DATE
> Task :app:preDebugUnitTestBuild UP-TO-DATE
> Task :app:javaPreCompileDebugUnitTest UP-TO-DATE
> Task :app:processDebugJavaRes NO-SOURCE
> Task :app:processDebugUnitTestJavaRes NO-SOURCE
> Task :app:checkDebugAndroidTestAarMetadata UP-TO-DATE
> Task :app:generateDebugAndroidTestResValues UP-TO-DATE
> Task :app:javaPreCompileDebugAndroidTest UP-TO-DATE
> Task :app:compileDebugSources UP-TO-DATE
> Task :app:bundleDebugClasses
> Task :app:compileDebugUnitTestKotlin
w: C:\Users\user\AndroidStudioProjects\HelloKotlin\app\src\test\java\com\example\hellokotlin\ExampleUnitTest.kt: (15, 25): This expression will be resolved to Int in further releases. Please add explicit convention call
> Task :app:compileDebugUnitTestJavaWithJavac NO-SOURCE
> Task :app:compileDebugUnitTestSources UP-TO-DATE
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugAndroidTestManifest'.
> Manifest merger failed with multiple errors, see logs
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 13s
20 actionable tasks: 4 executed, 16 up-to-date
提前感谢您的帮助。
更新:
我创建了一个新项目,一个没有活动的项目,它似乎进展顺利。与以前不同,我使用具有活动的项目。但是,我注意到这是一个常见问题,所以如果您能向我解释这一点以供将来参考,我将很高兴,感谢您的帮助。
答:
0赞
Deeksha
11/23/2021
#1
这可能是由于已弃用的 Gradle 功能与您的 Gradle 8.0 版本不兼容
尝试使用以下命令行参数运行 Gradle 构建。--warning-mode=all
它将详细说明使用了哪些已弃用的功能,以及有关修复的文档的链接。
评论
1赞
Edwin
11/25/2021
请问我在哪里运行“--warning-mode=all”??我无法在终端中运行它。
0赞
Deeksha
11/25/2021
请 stackoverflow.com/a/54680263/10087578 或 stackoverflow.com/a/68133369/10087578 参考此链接。它可能会帮助您@Edwin
13赞
Mahmudul Hasan Shohag
12/8/2021
#2
只需将您的依赖项更新到或更高版本即可。这应该可以解决您的问题。androidx.test.ext:junit
1.1.3
androidTestImplementation "androidx.test.ext:junit:1.1.3"
评论