1

我想混淆我的纯 Java 库,但我不确定如何在我的 build.xml 文件中使用 dexguard。有人可以给我举个例子吗?我当前的代码如下:

<property file="build.properties"/> 

<taskdef resource="build.properties"
classpath="dexguard.jar" />

<target name="build">
    <antcall target="clean"/>
</target>   

<target name="clean">
    <delete dir="build"/>
    <antcall target="compile"/>
</target>

<target name="compile">
    <mkdir dir="build/classes"/>
    <javac srcdir="src" destdir="build/classes"/>
    <antcall target="jar"/>
</target>

<target name="jar" >
    <mkdir dir="build/jar"/>
    <jar destfile="build/jar/testlib.jar" basedir="build/classes">

    </jar>
    <antcall target="obfuscate"/>
</target>

<target name="obfuscate" 
description="Obfuscate compiled classes">
<dexguard>
      -libraryjars "dexguard.jar"
      -injars      build/jar/testlib.jar
      -outjars     build/jar/testlib_obf.jar
</dexguard>

<target name="run">
    <java jar="build/jar/testlib.jar" fork="true"/>
</target>

4

1 回答 1

0

使用 Gradle。

task obfDexguard(type: com.guardsquare.dexguard.gradle.DexGuardTask) {
    configuration 'dexguard.txt'

    injars  "build/jar/testlib.jar"
    outjars "build/jar/testlib_obf.jar"
}
于 2015-12-11T12:51:26.443 回答