简体   繁体   English

如何使用ProGuard(或任何其他方式)隐藏库Jar中的公共类?

[英]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)? 有没有办法使用ProGuard或任何其他方式隐藏特定的公共类(如Android SDK中使用的@hide表示法)?

the whole point of obfuscatin is that it hides the method for people on the outside, but references inside the library are updated. obfuscatin的重点在于它隐藏了外部人员的方法,但更新了库内的引用。 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 ... 那么Proguard有很多选项来混淆或保持公共类,扩展特定类的类,成员......

Maybe a facade ( http://en.wikipedia.org/wiki/Facade_pattern ) would help. 也许门面( http://en.wikipedia.org/wiki/Facade_pattern )会有所帮助。 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. 它提供了一个减少外部世界,同时它保留了图书馆内的所有花里胡哨。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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