Java 使用ant构建时出现Android aapt重复文件错误
我正在使用ant为我们的android项目创建一个构建系统,它有两个构建目标:开发和发布 这涉及到在my build.xml中将默认的Java 使用ant构建时出现Android aapt重复文件错误,java,android,ant,aapt,Java,Android,Ant,Aapt,我正在使用ant为我们的android项目创建一个构建系统,它有两个构建目标:开发和发布 这涉及到在my build.xml中将默认的-package-resources目标替换为我自己的目标。它是这样的: <target name="-package-resources" depends="-crunch"> <!-- only package resources if *not* a library project --> <do-only-if
-package-resources
目标替换为我自己的目标。它是这样的:
<target name="-package-resources" depends="-crunch">
<!-- only package resources if *not* a library project -->
<do-only-if-not-library elseText="Library project: do not package resources..." >
< aapt executable="${aapt}"
command="package"
versioncode="${version.code}"
versionname="${version.name}"
debug="${build.is.packaging.debug}"
manifest="${out.manifest.abs.file}"
assets="${asset.absolute.dir}"
androidjar="${project.target.android.jar}"
apkfolder="${out.absolute.dir}"
nocrunch="${build.packaging.nocrunch}"
resourcefilename="${resource.package.file.name}"
resourcefilter="${aapt.resource.filter}"
libraryResFolderPathRefid="project.library.res.folder.path"
libraryPackagesRefid="project.library.packages"
previousBuildType="${build.last.target}"
buildType="${build.target}"
ignoreAssets="${aapt.ignore.assets}"
>
<res path="${out.res.absolute.dir}" />
<res path="${resource.absolute.dir}" />
<!-- <nocompress /> forces no compression on any files in assets or res/raw -->
<!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw -->
</aapt>
</do-only-if-not-library>
</target>
我不知道该怎么做。我的理解是,
-f
标志应该负责覆盖文件。这里的问题是同一个资源文件被发现了两次
[exec]/appname/app/native/android/appname/res/drawable/map_marker.png:错误:文件重复。[exec]/appname/app/native/android/appname/bin/res/drawable/map_marker.png:原文在这里
在运行Ant构建时,建议您关闭Eclipse,因为它会自动将res/*转储到bin
还要确保在运行aapt之前有一个清理垃圾箱的干净目标。希望两者都能解决你的问题
当我尝试使用以下build.properties构建时,它会成功。我使用的build.properties如下所示
sdk.dir=<sdk.dir>
source.dir=src
gen.dir=gen
resource.dir=res
asset.dir=res/assets
external.libs.dir=libs
out.dir=bin
target=android-10
target.api=android-10
sdk.dir=
source.dir=src
gen.dir=gen
resource.dir=res
asset.dir=res/assets
external.libs.dir=libs
out.dir=bin
target=android-10
api=android-10
希望能有帮助…原来这是我自己的错;以下:
<arg value="-S" />
<arg path="${out.res.absolute.dir}" />
<arg path="${resource.absolute.dir}" />
应该是:
<arg value="-S" />
<arg path="${out.res.absolute.dir}" />
<arg value="-S" />
<arg path="${resource.absolute.dir}" />
我停止了eclipse,进行了一次ant清理
,然后再次启动构建。但结果完全一样。更糟糕的是,文件正被crunch目标复制过来。你能不能也分享一下target crunch,我想这会有帮助我没有改变它。它位于sdk.target的tools/ant/folder中的build.xml中,crunch自身执行aapt,输入作为res文件夹,输出作为bin文件夹。所以我相信现在你需要跳过target-package-resourcescorrect-me中的res文件夹,我之前错了。看起来您用作build.xml输入的build.properties可能存在问题
<arg value="-S" />
<arg path="${out.res.absolute.dir}" />
<arg path="${resource.absolute.dir}" />
<arg value="-S" />
<arg path="${out.res.absolute.dir}" />
<arg value="-S" />
<arg path="${resource.absolute.dir}" />