频道
bg

Error: duplicate files during packaging of APK

coding二月 04, 20151mins
Android 经验错误

错误H1

Android项目构建时报如下错

bash

Error: duplicate files during packaging of APK /Users/snowblink/workspace/NoodlesMobile/app-stu/build/outputs/apk/xxx-debug-unaligned.apk

原因H1

打包apk文件时,资源文件冲突。

解决H1

MavenH2

bash

<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<extractDuplicates>true</extractDuplicates>
</configuration>
</plugin>

GradleH2

bash

packagingOptions {
exclude 'META-INF/notice.txt'
}

总结H1

Android官方文档对构建过程中打包apk的描述

All non-compiled resources (such as images), compiled resources, and the .dex files are sent to the apkbuilder tool to be packaged into an .apk file.

打包apk的过程中构建工具会把所有资源文件拷贝到apk文件中,文件冲突即会报错

评论


新的评论

匹配您的Gravatar头像

Joen Yu

@2022 JoenYu, all rights reserved. Made with love.