Включите "JSON In Java" в запутанную банку, используя proguard - PullRequest
0 голосов
/ 02 июля 2019

Есть идеи, что может быть не так с моей конфигурацией?

Я строю обфусцированную банку, которую я хочу включить в эту банку org.json банку.

Построить вывод из 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[]);
}
...