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

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

问题描述

我正在使用 ant 为我们的 android 项目创建一个构建系统,它有两个构建目标,Dev 和 Release.

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

这涉及用我自己的 build.xml 目标替换默认的 -package-resources 目标.从这里开始:

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天全站免登陆