简体   繁体   中英

How to hide public classes in library Jar using ProGuard (or any other way)?

I want to build a library, but I don't want some classes to be exposed to the developer, but I do want them to be exposed to my library code and tests easily.

Is there a way to hide specific public classes using ProGuard or in any other way (like the @hide notation used in Android SDK)?

the whole point of obfuscatin is that it hides the method for people on the outside, but references inside the library are updated. Typically, you'll have a

void myMethodWithAVeryExplicitName() {
    // Do Stuff
}

void otherMethod() {
    // Call the first method
    myMethodWithAVeryExplicitName();
}

It will be obfuscated as :

void a() {
    // Do Stuff
}

void b() {
    // Call the first method
    a();
}

Then Proguard has a lot of options for obfuscating or keeping public classes, classes that extend specific classes, members ...

Maybe a facade ( http://en.wikipedia.org/wiki/Facade_pattern ) would help. The purpose of this pattern is similar with your problem. It offers a reduced to the outside world while it keeps all the bells and whistles inside the library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM