Android Library Project 工程依赖:manifestmerger.enabled=true

本文详细介绍了在Android开发中使用library项目时遇到的问题及解决方法,包括manifest文件的合并、assets目录文件的自动合并、SDK版本一致性确认等关键步骤。

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

Android可以通过use library来引用另一个Project,实际开发过程中遇到了很多稀奇古怪的问题,总结如下:

1. 通常情况下library 工程的AndroidManifest.xml中的 <uses-permission>、<meta-data> 等元素会被merge 到主工程的AndroidManifest.xml中,但是像<service>、<receiver>、<activity>等元素却不会merge过去。不知道是什么原因,Android 真TMD要逆天了。

2. library 工程的assets目录下的文件也不会自动merge 到主工程。

解决办法:
1. 在主Project的project.properties里加上如下一句,编译时就可以自动合并library 工程和主工程的manifest 文件了。

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
<span style="background-color: rgb(255, 255, 102);">manifestmerger.enabled=true</span> 
2. 实际编译过程中可能会报错:You should be confirmed some point like ADT version, Also Minimum and target SDK should be same as library project.
你应该确保adt版本ADT(可能是 20.0.1以上),并且两个工程的<uses-sdk>必须保持一致。
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19"/>
构建进程终止异常: C:\Users\liangh\.jdks\corretto-11.0.24\bin\java.exe -Xmx700m -Djava.awt.headless=true "-Djna.boot.library.path=D:\Idea2024\IntelliJ IDEA Community Edition 2024.1/lib/jna/amd64" -Djna.nosys=true -Djna.noclasspath=true -Dexternal.project.config=C:\Users\liangh\AppData\Local\JetBrains\IdeaIC2024.1\projects\gywycode.2a47e16a\external_build_system -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Didea.IntToIntBtree.page.size=32768 -Djdt.compiler.useSingleThread=true -Daether.connector.resumeDownloads=false -Dio.netty.initialSeedUniquifier=-7772580090291254657 -Dfile.encoding=GBK -Duser.language=zh -Duser.country=CN -Didea.paths.selector=IdeaIC2024.1 -Djps.language.bundle=C:/Users/liangh/AppData/Roaming/JetBrains/IdeaIC2024.1/plugins/zh.241.271/lib/zh.241.271.jar "-Didea.home.path=D:/Idea2024/IntelliJ IDEA Community Edition 2024.1" -Didea.config.path=C:/Users/liangh/AppData/Roaming/JetBrains/IdeaIC2024.1 -Didea.plugins.path=C:/Users/liangh/AppData/Roaming/JetBrains/IdeaIC2024.1/plugins -Djps.log.dir=C:/Users/liangh/AppData/Local/JetBrains/IdeaIC2024.1/log/build-log "-Djps.fallback.jdk.home=D:/Idea2024/IntelliJ IDEA Community Edition 2024.1/jbr" -Djps.fallback.jdk.version=17.0.11 -Dio.netty.noUnsafe=true -Djava.io.tmpdir=C:/Users/liangh/AppData/Local/JetBrains/IdeaIC2024.1/compile-server/gywycode_af3c8cba/_temp_ -Djps.backward.ref.index.builder=true -Djps.backward.ref.index.builder.fs.case.sensitive=false "-Djps.kotlin.home=D:\Idea2024\IntelliJ IDEA Community Edition 2024.1\plugins\Kotlin\kotlinc" -Dkotlin.incremental.compilation=true -Dkotlin.incremental.compilation.js=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path=\"C:\Windows\Temp\kotlin-idea-11626471297649951508-is-running\" -Dide.propagate.context=false -classpath "D:/Idea2024/IntelliJ IDEA Community Edition 2024.1/plugins/java/lib/jps-launcher.jar" org.jetbrains.jps.cmdline.Launcher "D:/Idea2024/IntelliJ IDEA Community Edition 2024.1/plugins/java/lib/jps-builders.jar;D:/Idea202
最新发布
08-07
failed The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin. :app:mergeDebugResources :app:mapDebugSourceSetPaths :app:checkDebugAarMetadata :app:processDebugMainManifest :app:javaPreCompileDebug :app:mergeDebugAssets :app:checkDebugDuplicateClasses :app:mergeDebugNativeLibs :app:dataBindingMergeDependencyArtifactsDebug :JetpackMvvm:compileDebugKotlin :JetpackMvvm:bundleLibRuntimeToJarDebug org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'. org.gradle.api.internal.artifacts.transform.TransformException: Failed to transform agentweb-4.1.3.aar (com.just.agentweb:agentweb:4.1.3) to match attributes {artifactType=android-res, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}. org.gradle.internal.resolve.ArtifactNotFoundException: Could not find agentweb-4.1.3.aar (com.just.agentweb:agentweb:4.1.3). org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'. org.gradle.api.internal.artifacts.transform.TransformException: Failed to transform agentweb-4.1.3.aar (com.just.agentweb:agentweb:4.1.3) to match attributes {artifactType=android-res, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}. org.gradle.internal.resolve.ArtifactNotFoundException: Could not find agentweb-4.1.3.aar (com.just.agentweb:agentweb:4.1.3). org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspa
03-14
C:\huanjing\apache-tomcat-10.1.43\bin\catalina.bat run [2025-07-07 06:36:11,829] 工件 MVC-project:war exploded: 正在等待服务器连接以启动工件部署… Using CATALINA_BASE: "C:\Users\12524\AppData\Local\JetBrains\IntelliJIdea2025.1\tomcat\1e48c713-fd14-4371-ba65-0ae810dd2d86" Using CATALINA_HOME: "C:\huanjing\apache-tomcat-10.1.43" Using CATALINA_TMPDIR: "C:\huanjing\apache-tomcat-10.1.43\temp" Using JRE_HOME: "C:\Users\12524\.jdks\openjdk-24.0.1" Using CLASSPATH: "C:\huanjing\apache-tomcat-10.1.43\bin\bootstrap.jar;C:\huanjing\apache-tomcat-10.1.43\bin\tomcat-juli.jar" Using CATALINA_OPTS: "" 07-Jul-2025 18:36:12.540 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server.服务器版本: Apache Tomcat/10.1.43 07-Jul-2025 18:36:12.542 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 服务器构建: Jul 1 2025 21:30:20 UTC 07-Jul-2025 18:36:12.542 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 服务器版本号: 10.1.43.0 07-Jul-2025 18:36:12.542 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 操作系统名称: Windows 11 07-Jul-2025 18:36:12.542 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS.版本: 10.0 07-Jul-2025 18:36:12.542 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 架构: amd64 07-Jul-2025 18:36:12.543 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java 环境变量: C:\Users\12524\.jdks\openjdk-24.0.1 07-Jul-2025 18:36:12.543 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java虚拟机版本: 24.0.1+9-30 07-Jul-2025 18:36:12.543 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM.供应商: Oracle Corporation 07-Jul-2025 18:36:12.543 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\12524\AppData\Local\JetBrains\IntelliJIdea2025.1\tomcat\1e48c713-fd14-4371-ba65-0ae810dd2d86 07-Jul-2025 18:36:12.543 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\huanjing\apache-tomcat-10.1.43 07-Jul-2025 18:36:12.545 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.util.logging.config.file=C:\Users\12524\AppData\Local\JetBrains\IntelliJIdea2025.1\tomcat\1e48c713-fd14-4371-ba65-0ae810dd2d86\conf\logging.properties 07-Jul-2025 18:36:12.545 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 07-Jul-2025 18:36:12.545 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dcom.sun.management.jmxremote= 07-Jul-2025 18:36:12.545 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dcom.sun.management.jmxremote.port=1099 07-Jul-2025 18:36:12.545 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dcom.sun.management.jmxremote.ssl=false 07-Jul-2025 18:36:12.545 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dcom.sun.management.jmxremote.password.file=C:\Users\12524\AppData\Local\JetBrains\IntelliJIdea2025.1\tomcat\1e48c713-fd14-4371-ba65-0ae810dd2d86\jmxremote.password 07-Jul-2025 18:36:12.545 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dcom.sun.management.jmxremote.access.file=C:\Users\12524\AppData\Local\JetBrains\IntelliJIdea2025.1\tomcat\1e48c713-fd14-4371-ba65-0ae810dd2d86\jmxremote.access 07-Jul-2025 18:36:12.545 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.rmi.server.hostname=127.0.0.1 07-Jul-2025 18:36:12.545 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djdk.tls.ephemeralDHKeySize=2048 07-Jul-2025 18:36:12.545 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources 07-Jul-2025 18:36:12.545 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dsun.io.useCanonCaches=false 07-Jul-2025 18:36:12.545 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: --add-opens=java.base/java.lang=ALL-UNNAMED 07-Jul-2025 18:36:12.546 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: --add-opens=java.base/java.lang.reflect=ALL-UNNAMED 07-Jul-2025 18:36:12.546 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: --add-opens=java.base/java.io=ALL-UNNAMED 07-Jul-2025 18:36:12.546 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: --add-opens=java.base/java.util=ALL-UNNAMED 07-Jul-2025 18:36:12.547 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED 07-Jul-2025 18:36:12.547 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED 07-Jul-2025 18:36:12.547 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dcatalina.base=C:\Users\12524\AppData\Local\JetBrains\IntelliJIdea2025.1\tomcat\1e48c713-fd14-4371-ba65-0ae810dd2d86 07-Jul-2025 18:36:12.548 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dcatalina.home=C:\huanjing\apache-tomcat-10.1.43 07-Jul-2025 18:36:12.548 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.io.tmpdir=C:\huanjing\apache-tomcat-10.1.43\temp WARNING: A restricted method in java.lang.System has been called WARNING: java.lang.System::load has been called by org.apache.tomcat.jni.Library in an unnamed module (file:/C:/huanjing/apache-tomcat-10.1.43/lib/tomcat-jni.jar) WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module WARNING: Restricted methods will be blocked in a future release unless native access is enabled 07-Jul-2025 18:36:12.556 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent 在java.library.path:[C:\Users\12524\.jdks\openjdk-24.0.1\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\MySQL\MySQL Server 8.2\bin;C:\Users\12524\AppData\Local\Microsoft\WindowsApps;;.]上找不到基于APR的Apache Tomcat本机库,该库允许在生产环境中获得最佳性能 07-Jul-2025 18:36:12.675 信息 [main] org.apache.coyote.AbstractProtocol.init 初始化协议处理器 ["http-nio-8080"] 07-Jul-2025 18:36:12.687 信息 [main] org.apache.catalina.startup.Catalina.load 服务器在[337]毫秒内初始化 07-Jul-2025 18:36:12.727 信息 [main] org.apache.catalina.core.StandardService.startInternal 正在启动服务[Catalina] 07-Jul-2025 18:36:12.727 信息 [main] org.apache.catalina.core.StandardEngine.startInternal 正在启动 Servlet 引擎:[Apache Tomcat/10.1.43] 07-Jul-2025 18:36:12.740 信息 [main] org.apache.coyote.AbstractProtocol.start 开始协议处理句柄["http-nio-8080"] 07-Jul-2025 18:36:12.784 信息 [main] org.apache.catalina.startup.Catalina.start [95]毫秒后服务器启动 已连接到服务器 [2025-07-07 06:36:12,945] 工件 MVC-project:war exploded: 正在部署工件,请稍候… 07-Jul-2025 18:36:13.884 信息 [RMI TCP Connection(2)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars 至少有一个JAR被扫描用于TLD但尚未包含TLD。 为此记录器启用调试日志记录,以获取已扫描但未在其中找到TLD的完整JAR列表。 在扫描期间跳过不需要的JAR可以缩短启动时间和JSP编译时间。 [2025-07-07 06:36:13,938] 工件 MVC-project:war exploded: 工件已成功部署 [2025-07-07 06:36:13,938] 工件 MVC-project:war exploded: 部署已花费 994 毫秒 07-Jul-2025 18:36:22.744 信息 [Catalina-utility-2] org.apache.catalina.startup.HostConfig.deployDirectory 把web 应用程序部署到目录 [C:\huanjing\apache-tomcat-10.1.43\webapps\manager] 07-Jul-2025 18:36:22.791 信息 [Catalina-utility-2] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[C:\huanjing\apache-tomcat-10.1.43\webapps\manager]的部署已在[46]毫秒内完成
07-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值