How to Obfuscated Jar or AAR files

北慕城南 提交于 2019-12-11 12:40:25

问题


Can someone help me about, obfuscated or give me example to do this?

I created an .aar file and .jar file and put the class of getter and setter that will give value if they access on it.

but the thing in need to put the hidden values that someone will not see what is the value on it.

     package com.example.test;
     public class MyClass  extends  privateClass{
            String testing;
            public MyClass() {
              this.testing = getStringExample();
            }
            public String getTesting() {
                return testing;
            }
            public void setTesting(String testing) {
                this.testing = testing;
            }
     }

and this class must be hide/obfuscated to the other developers if i give my library

    package com.example.test;

    public class privateClass {
        String getStringExample()
        {
             return "TEST RESULT";
        }
    }

Note: I tried to put proguard too, and check the library but still they can see my private class, , i tried to use interface and extends the class but still the same,

here is my proguard example:

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontwarn ccom.example.test.R*
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class
-keepclassmembers class com.example.test.** { *; }
-keep class com.example.eyefixdata.** {
    void set*(***);
    void set*(int, ***);
    boolean is*();
    boolean is*(int);
    *** get*();
    *** get*(int);
}

Please save my day. hope you help me. Thanks in advance.


回答1:


You can move your private classes/interfaces to other packages, e.g. put your privateClass to an internal package package com.example.your.library.internal; to distinguish with your public classes/interfaces.


package com.example.your.library.internal;

public class privateClass {
    String getStringExample()
    {
        return "TEST RESULT";
    }
}

And add below line to your proguard configuration

-keep public class com.example.your.library.* { public *; }

Note that you should use single wild char * to NOT obfuscate the internal packages.



来源:https://stackoverflow.com/questions/54819602/how-to-obfuscated-jar-or-aar-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!