1

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.

shizhen
  • 12,251
  • 9
  • 52
  • 88
Jude Bautista
  • 160
  • 1
  • 16
  • check the answer at [Why some package-private classes are not obfuscated by Proguard?](https://stackoverflow.com/a/52771418/8034839) – shizhen Feb 22 '19 at 04:53

1 Answers1

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.

shizhen
  • 12,251
  • 9
  • 52
  • 88
  • Hello, @shizhen, can you teach me how can i put the privateClass to an internal package ?. step by step? thank you for helping me – Jude Bautista Feb 22 '19 at 05:34
  • "put into internal package" means nothing special but rename your package name to something like `com.example.your.library.internal`, this way of package name management is to facilitate your subsequent obfuscation rules. – shizhen Feb 22 '19 at 05:36
  • Also check my another answer here: https://stackoverflow.com/a/52771418/8034839 for cross understanding. – shizhen Feb 22 '19 at 05:37