使用proguard

时间:2019-07-02 11:01:28

标签: java json proguard obfuscation

任何想法我的配置可能出什么问题吗?

我构建了一个模糊的jar,我想在其中添加org.json jar。

gradle jar生成输出。.

> Task :obfuscate FAILED
Warning: tool.cli.Executor: can't find referenced class org.json.JSONObject
Warning: tool.cli.Executor: can't find referenced class org.json.JSONObject
Warning: tool.cli.Executor: can't find referenced class org.json.JSONObject
Warning: tool.cli.Executor: can't find referenced class org.json.JSONObject
Warning: tool.cli.Executor: can't find referenced class org.json.JSONObject
Warning: tool.cli.Executor: can't find referenced class org.json.JSONObject
Warning: there were 6 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)

来自build.gradle的摘要。

// Build runnable jar
task obfuscate(type: proguard.gradle.ProGuardTask) {
    configuration 'proguard.txt'

    injars "$libsDir/$nonObfuscatedJar"
    outjars "$libsDir/uploader.jar"
    libraryjars "${System.getProperty('java.home')}/lib/rt.jar"
}

jar {
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    archiveName = "$nonObfuscatedJar"
    from sourceSets.main.output.classesDir
    include '**/cli/*.class'
    manifest {
        attributes 'Main-Class': 'tool.cli.Uploader'
    }
    exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}
jar.finalizedBy(project.tasks.obfuscate)

来自proguard.txt的摘要。

-keep interface org.json.** { *; }
-keep class org.json.** { *;}
-keepclassmembers class * {
   public <init> (org.json.JSONObject);
}
-keep public class tool.cli.Uploader {
    public static void main(java.lang.String[]);
}

0 个答案:

没有答案