1

我正在使用 ANT 构建工具构建我的 android 应用程序。

  1. 当它使用 dexgaurd 在我的本地机器上运行时,它构建得很好。
  2. 不使用 dexgaurd 时,它在服务器上运行良好。
  3. 使用 dexgaurd 时,它在服务器上失败。

服务器规格:

             total       used       free     shared    buffers     cached

Mem:          7978       7328        649          0         32        391
-/+ buffers/cache:       6904       1073
Swap:         8188        486       7702

以下是错误:

[dexguard] java.lang.OutOfMemoryError: PermGen space
[12:10:04]
[dexguard-package-helper] The following error occurred while executing this line:
/abc/def/custom_rules.xml:60: java.lang.OutOfMemoryError: PermGen space
[12:10:04]
[ant] The following error occurred while executing this line:
/abc/def/custom_rules.xml:127: The following error occurred while executing this line:
/abc/def/custom_rules.xml:60: java.lang.OutOfMemoryError: PermGen space

以下是发生错误的行:

<dexguard
            verbose="${verbose}"
            keystore="${key.store}"
            keystorepassword="${key.store.password}"
            keyalias="${key.alias}"
            keypassword="${key.alias.password}"
            printseeds="${obfuscate.absolute.dir}/seeds.txt"
            printusage="${obfuscate.absolute.dir}/usage.txt"
            printmapping="${obfuscate.absolute.dir}/mapping.txt"
60 - >      configuration="@{configuration}">
            <configuration file="proguard-project.txt" />
            <configuration file="dexguard-project.txt" />
            <configuration file="dexguard-project-${build.target}.txt" />
            <dexguard-options />
            <libraryjar refid="project.target.class.path" />
        </dexguard>

<dexguard-package-helper
      127 ->           configuration="${dexguard.dir}/lib/dexguard-${build.target}.pro">
                    <dexguard-options>
                        <injar path="${out.classes.absolute.dir}"     filter="**.class" />
                        <injar path="${source.absolute.dir}"          filter="!**.java,!.hg**,!**/.hg**,!.git**,!**/.git**,!.svn**,!**/.svn**,!CVS,!CVS/**,!**/CVS,!**/CVS/**,!.cvsignore,!**/.cvsignore,!SCCS,!SCCS/**,!**/SCCS,!**/SCCS/**,!**.orig,!**~,lib/*/*.so,!**.so,!**.keep,!**.DS_Store,!**.aidl,!**.rs,!**.rsh,!**.d,!**.java,!**.scala,!**.scc,!**.swp,!**.bak,!**thumbs.db,!**picasa.ini,!**package.html,!**overview.html,!**.AIDL,!**.RS,!**.RSH,!**.D,!**.JAVA,!**.SCALA,!**.SCC,!**.SWP,!**.BAK,!**THUMBS.DB,!**PICASA.INI,!**PACKAGE.HTML,!**OVERVIEW.HTML" />
                        <injar refid="project.all.jars.path"          filter="!org/w3c/dom/**,!org/xml/sax/**,!org/xmlpull/v1/**,!org/json/JSON*,!org/apache/commons/logging/Log.class,org/apache/http/Consts.class,org/apache/http/HttpHeaders.class,org/apache/http/entity/ContentType.class,org/apache/http/util/Args.class,org/apache/http/util/Asserts.class,org/apache/http/util/CharsetUtils.class,org/apache/http/util/NetUtils.class,org/apache/http/util/TextUtils.class,!org/apache/http/*,!org/apache/http/auth/*,!org/apache/http/auth/params/*,!org/apache/http/client/*,!org/apache/http/client/entity/*,!org/apache/http/client/methods/*,!org/apache/http/client/params/*,!org/apache/http/client/protocol/*,!org/apache/http/client/utils/*Utils.class,!org/apache/http/conn/*,!org/apache/http/conn/params/*,!org/apache/http/conn/routing/*,!org/apache/http/conn/scheme/*,!org/apache/http/conn/ssl/*,!org/apache/http/conn/util/*,!org/apache/http/cookie/*,!org/apache/http/cookie/params/*,!org/apache/http/entity/*,!org/apache/http/impl/*,!org/apache/http/impl/auth/*,!org/apache/http/impl/client/*,!org/apache/http/impl/conn/*,!org/apache/http/impl/conn/tsccm/*,!org/apache/http/impl/cookie/*,!org/apache/http/impl/entity/*,!org/apache/http/impl/io/*,!org/apache/http/io/*,!org/apache/http/message/*,!org/apache/http/params/*,!org/apache/http/protocol/*,!org/apache/http/util/*,META-INF/services/**,!META-INF/**,!.hg**,!**/.hg**,!.git**,!**/.git**,!.svn**,!**/.svn**,!CVS,!CVS/**,!**/CVS,!**/CVS/**,!.cvsignore,!**/.cvsignore,!SCCS,!SCCS/**,!**/SCCS,!**/SCCS/**,!**.orig,!**~,**.class,lib/*/*.so,!**.so,!**.keep,!**.DS_Store,!**.aidl,!**.rs,!**.rsh,!**.d,!**.java,!**.scala,!**.scc,!**.swp,!**.bak,!**thumbs.db,!**picasa.ini,!**package.html,!**overview.html,!**.AIDL,!**.RS,!**.RSH,!**.D,!**.JAVA,!**.SCALA,!**.SCC,!**.SWP,!**.BAK,!**THUMBS.DB,!**PICASA.INI,!**PACKAGE.HTML,!**OVERVIEW.HTML" />
                        <injar path="${out.native.libs.absolute.dir}" filter="lib/*/*.so" />
                        <injar path="${out.absolute.dir}/${resource.package.file.name}" />
                        <outjar path="${out.final.file}" />
                    </dexguard-options>
                </dexguard-package-helper>

以下是环境变量及其值:ANT_OPTS

[echo] ant build config -Xms1024m -Xmx2048m -XX:PermSize=1024m -XX:MaxPermSize=2048m -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled

我已将 XX:MaxPermSize 更改为 4096 但它仍然给出相同的错误。无论 -Xms -Xmx -XX 值是什么,它在这一点上始终失败。我是否必须为环境添加一些其他值才能开始正常工作。这类问题的一般解决方案是增加 -XX:MaxPermSize 中的内存值,但这无济于事

更多上下文:蚂蚁构建了 8 个应用程序。构建工作正常,直到第 6 个应用程序,它们都有类似的 custom_rules.xml 文件。但是在构建第 7 个应用程序时它失败了。

如果您需要更多信息,请在评论部分提及,我会添加它。我在谷歌上搜索了很多关于这个问题并尝试使用解决方案来解决它,但从未成功。

4

0 回答 0