用Ant构建Android的时候AAPT重复文件错误 [英] Android aapt duplicate files error when building with ant

查看:554
本文介绍了用Ant构建Android的时候AAPT重复文件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是用蚂蚁做一个构建系统,我们有两个构建目标,开发和发布的Andr​​oid项目。

I am using ant to make a build system for our android project which has two build targets, Dev and Release.

这涉及到我自己的之一,我的build.xml替换默认的 -package资源目标。它从这样的:

This involves replacing the default -package-resources target with my own one in my build.xml. It goes from this:

<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>

要这样:

<target name="-package-resources" depends="-crunch">
    <!-- only package resources if *not* a library project -->
    <echo message="Packaging resources with ${package.internal} as a package name" />
    <do-only-if-not-library elseText="Library project: do not package resources..." >
        <exec executable="${aapt}" failonerror="true">
                <arg value="package" />
                <arg value="-f" />
                <arg value="-v" />
                <arg value="-M" />
                <arg path="${out.manifest.abs.file}" />
                <arg value="-A" />
                <arg path="${asset.absolute.dir}" />
                <arg value="-I" />
                <arg path="${project.target.android.jar}" />
                <arg value="-m" />
                <arg value="-J" />
                <arg path="${out.absolute.dir}" />
                <arg value="-F" />
                <arg path="${out.absolute.dir}/${resource.package.file.name}" />
                <arg value="-S" />
                <arg path="${out.res.absolute.dir}" />
                <arg path="${resource.absolute.dir}" />
                <arg value="--no-crunch" />
        <arg value="--rename-manifest-package" />
        <arg value="${package.internal}" />
        </exec>
    </do-only-if-not-library>
</target>

然而,当我启动建设,它没有这一步,出现以下错误:

However, when I launch the build, it fails on this step with the following error:

-package-resources:
     [echo] Packaging resources with dev.appname.android as a package name
     [exec] Found 4 custom asset files in /appname/app/native/android/appname/assets
     [exec] Processing raw dir '/appname/app/native/android/appname/res'
     [exec] /appname/app/native/android/appname/res/drawable/map_marker.png: error: Duplicate file.
     [exec] /appname/app/native/android/appname/bin/res/drawable/map_marker.png: Original is here.

不知道如何继续在这里。我的理解是, -f 标志应采取覆盖文件的照顾。

Not sure how to proceed here. My understanding was that the -f flag should take care of overwriting files.

推荐答案

原来,这是我自己的错;以下,

Turns out this was my own fault; the following,

<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}" />

这篇关于用Ant构建Android的时候AAPT重复文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆