android 清单文件AndroidManifest.xml报错Execution failed for task ‘:app:processDebugMainManifest‘.

文章介绍了在遇到AndroidManifest.xml错误时,如何通过在gradle.properties文件中添加android.enableJetifier=true和android.useAndroidX=true这两行配置来解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

报错AndroidManifest.xml:

 解决办法:

在gradle.properties文件添加

android.enableJetifier=true

android.useAndroidX=true

plugins { id 'com.android.application' } android { namespace 'com.example.flowershop' compileSdk 34 defaultConfig { applicationId "com.example.onlinebookstore" minSdk 21 targetSdk 34 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'com.google.android.material:material:1.4.0' implementation 'com.github.getActivity:XXPermissions:20.0' implementation ('com.github.bumptech.glide:glide:4.16.0'){ exclude group : 'androidx.annotation' } annotationProcessor 'com.github.bumptech.glide:compiler:4.16.0' }下面是报错信息Executing tasks: [testDebugUnitTest] in project E:\7.flower-shop\flower-shop\app Starting Gradle Daemon... Connected to the target VM, address: '127.0.0.1:61278', transport: 'socket' Gradle Daemon started in 3 s 461 ms > Task :app:preBuild UP-TO-DATE > Task :app:preDebugBuild UP-TO-DATE > Task :app:javaPreCompileDebug UP-TO-DATE > Task :app:checkDebugAarMetadata UP-TO-DATE > Task :app:generateDebugResValues UP-TO-DATE > Task :app:mapDebugSourceSetPaths UP-TO-DATE > Task :app:generateDebugResources UP-TO-DATE > Task :app:mergeDebugResources UP-TO-DATE > Task :app:packageDebugResources UP-TO-DATE > Task :app:parseDebugLocalResources UP-TO-DATE > Task :app:createDebugCompatibleScreenManifests > Task :app:extractDeepLinksDebug UP-TO-DATE > Task :app:processDebugMainManifest FAILED Incorrect package="com.example.onlinebookstore" found in source AndroidManifest.xml: E:\7.flower-shop\flower-shop\app\src\main\AndroidManifest.xml. Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported. Recommendation: remove package="com.example.onlinebookstore" from the source AndroidManifest.xml: E:\7.flower-shop\flower-shop\app\src\main\AndroidManifest.xml. > Task :app:preDebugUnitTestBuild UP-TO-DATE > Task :app:javaPreCompileDebugUnitTest UP-TO-DATE > Task :app:processDebugUnitTestJavaRes NO-SOURCE FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugMainManifest'. > Incorrect package="com.example.onlinebookstore" found in source AndroidManifest.xml: E:\7.flower-shop\flower-shop\app\src\main\AndroidManifest.xml. Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported. Recommendation: remove package="com.example.onlinebookstore" from the source AndroidManifest.xml: E:\7.flower-shop\flower-shop\app\src\main\AndroidManifest.xml. * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. >
06-03
Executing tasks: [testDebugUnitTest] in project E:\7.flower-shop\onlinebookstore\app Starting Gradle Daemon... Connected to the target VM, address: '127.0.0.1:64529', transport: 'socket' Gradle Daemon started in 2 s 741 ms > Task :app:preBuild UP-TO-DATE > Task :app:preDebugBuild UP-TO-DATE > Task :app:javaPreCompileDebug UP-TO-DATE > Task :app:checkDebugAarMetadata UP-TO-DATE > Task :app:generateDebugResValues UP-TO-DATE > Task :app:mapDebugSourceSetPaths > Task :app:generateDebugResources UP-TO-DATE > Task :app:mergeDebugResources UP-TO-DATE > Task :app:packageDebugResources UP-TO-DATE > Task :app:parseDebugLocalResources UP-TO-DATE > Task :app:createDebugCompatibleScreenManifests UP-TO-DATE > Task :app:extractDeepLinksDebug UP-TO-DATE > Task :app:processDebugMainManifest FAILED package="com.example.onlinebookstore" found in source AndroidManifest.xml: E:\7.flower-shop\onlinebookstore\app\src\main\AndroidManifest.xml. Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported, and the value is ignored. Recommendation: remove package="com.example.onlinebookstore" from the source AndroidManifest.xml: E:\7.flower-shop\onlinebookstore\app\src\main\AndroidManifest.xml. E:\7.flower-shop\onlinebookstore\app\src\main\AndroidManifest.xml:37:9-39:40 Error: Element activity#com.example.onlinebookstore.activity.LoginActivity at AndroidManifest.xml:37:9-39:40 duplicated with element declared at AndroidManifest.xml:20:9-59 E:\7.flower-shop\onlinebookstore\app\src\main\AndroidManifest.xml Error: Validation failed, exiting See https://developer.android.com/r/studio-ui/build/manifest-merger for more information about the manifest merger. > Task :app:preDebugUnitTestBuild UP-TO-DATE > Task :app:javaPreCompileDebugUnitTest UP-TO-DATE > Task :app:processDebugUnitTestJavaRes NO-SOURCE FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugMainManifest'. > 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. BUILD FAILED in 11s 12 actionable tasks: 2 executed, 10 up-to-date 21:36:10: Execution finished 'testDebugUnitTest'. Disconnected from the target VM, address: '127.0.0.1:64529', transport: 'socket'
最新发布
06-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Z_Try

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值