Welcome to follow my public numberEfficient Android Development“Focuses on Android project efficiency and development experience, covering topics such as infrastructure, Kotlin Multiplatform, Gradle construction and optimization, etc. At the same time, we also talk about overseas work and life, and push the latest Podcast of” Two-part radio “.
“Build North” is a series of articles exploring Android building. It covers Gradle, Android Gradle Plugin, Kotlin Script, and other tools, as well as related architecture applications. To find the problem to solve the problem as the starting point, transfer new knowledge to improve production efficiency as the foothold.
I wrote an article about how the Library Module can’t debug because of the buildTypes default. In fact, the Debug package was only fixed and a hidden problem was ignored when the Release package was printed.
AssembleDebug will not find the rebuild or assembleRelease classes. For example, module A has Clazz, and module B references Clazz.
Since the problem is inferred only when cross-referencing, it can be inferred that proGuard has a problem. Disable ProGuard for Module Release If you think back to the Android packaging order, it looks like this:
- Package each Library Module separately (Module confusion)
- Unpack all dependencies, both local and remote, with application Module
So, facing different situations, there should be different obfuscation strategies:
-
If it is a local Library module, you can choose not to do library obfuscation, but only global obfuscation, so that the above module reference does not find the class, and only need to maintain a configuration file;
-
If it is output to an external SDK, there are generally two types:
-
Closed source: For example, AUtonavi SDK, UMENG SDK, etc., will generally do AAR confusion, but will isolate a package or a class to provide API (that is, the API in the documentation), this package/class will keep, but a large number of specific implementation will implement confusion. And try to put some sensitive content, algorithm with JNI and other ways to do call.
-
Open source: The various open source libraries on Github, for example, generally do not do AAR confusion, but provide a configuration item on consumerProguardFiles to ensure that key parts of the library code are not confused, as follows (see the official user guide)
android { defaultConfig { consumerProguardFiles 'lib-proguard-rules.txt'}... }Copy the code
-
Welcome to comment like, and follow my public accountEfficient Android Development.