一段时间以来,我一直在使用 Eclipse 导出创建我的应用程序 .apk,但我现在想使用 ant 进行构建,以便可以自定义该过程。按照其他地方的建议,我使用“android create project”命令在临时项目中生成合适的 build.xml 文件(然后对其进行修改)。
当我构建时,它在包步骤中失败并出现重复文件错误:
-package:
[apkbuilder] Current build type is different than previous build: forced apkbuilder run.
[apkbuilder] Creating MyApp-debug-unaligned.apk and signing it with a debug key...
[apkbuilder] Found duplicate file for APK: res/drawable-mdpi/icon.png
[apkbuilder] Origin 1: /home/chris/temp/MyApp/MyApp.ap_
[apkbuilder] Origin 2: /home/chris/git/MyApp/MyApp/res/drawable-mdpi/icon.png
...
/home/chris/android-sdk-linux_x86/tools/ant/build.xml:310: com.android.sdklib.build.DuplicateFileException: Duplicate files at the same path inside the APK
我的蚂蚁属性是:
source.dir=/home/chris/git/MyApp/MyApp
out.dir=/home/chris/temp/MyApp
这似乎是 res 目录的内容与构建期间创建的中间 .ap_ 资源包文件之间的冲突。我不明白为什么包装会包含来自这两个来源的内容,因为重复似乎是不可避免的结果。
我最初认为问题是由 res 子目录(drawable-hdpi、drawable-ldpi、drawable-mdpi)引起的,它们都包含一个同名的文件(icon.png),但我尝试以不同的方式命名它们,错误仍然发生。在任何情况下,Eclipse 导出构建都可以毫无问题地处理它们。
使用 ant 构建时,此问题出现类似 Android aapt 重复文件错误,但在这种情况下,该人正在创建自己的 build.xml,而我使用的是 android sdk 中提供的。
任何帮助都感激不尽。