A plug-in tool for componentization of Android App — make business components and functional components library aware of the creation and exit of the main project Application; One of the inevitable problems encountered in Android componentization development is component/module initialization. Componentization is decoupling. Each component/module has different functions. For example, different components/modules need to initialize some third-party SDKS in application or this component/module needs to perform some operations during application initialization. English


[TOC]

The latest version

The module com.qckiss.library:lifecycle.proxy com.qckiss.plugin:lifecycle.register
The latest version 1.0.0 1.0.0

I. Function introduction

The Library can sense the creation of the main project Application and do what it needs

Transform incremental compilation is enabled

Two, basic functions

  1. Add dependencies and configurations

    // Apply plugin: 'com.android. Application 'apply plugin: 'com. Qckiss. Plugin. Lifecycleregister / / scan configuration scanPackageNames {scanAll = false / / false by default; Library,true Scan all names = ["com/xxx1","com/xxx2"] // package name separator "/"}Copy the code
    // Main project and libraries
    dependencies {
            // Replace with the latest version number
            implementation 'com.qckiss.library:lifecycle.proxy:x.x.x'
        }
    Copy the code
        / / project build. Gradle
        dependencies {
        	...
            classpath 'com.qckiss.plugin:lifecycle.register:x.x.x'
        }
    
        allprojects {
            repositories {
                maven{
                    url 'https://raw.githubusercontent.com/qcks/public-maven-repo/master'}}}Copy the code
  2. Library adds the tag annotation @marklibApplictionProxy

    /** * priority A smaller value indicates a higher registration priority */
    @MarkLibApplictionProxy(priority = 2)
    public class ModelaApplicationProxy implements IApplicationProxy {
        @Override
        public void onCreate(Application application) {
        Log.i("ModelA"."ApplicationProxy onCreate");
        }
    
        @Override
        public void onExitAllActivity(a) {
            // Not yet implemented
            Log.i("ModelA"."ApplicationProxy onExitAllActivity"); }}Copy the code
  3. The onCreate method of the shell Application adds the tag annotation @MarkrecapTurelibProxy

    
    public class MyApplication extends BaseApplication {
        @MarkRecaptureLibProxy
        @Override
        public void onCreate(a) {
            super.onCreate(); }}Copy the code
  4. Add obfuscation rules (if using Proguard)

    -keep public class com.qckiss.liblifecycleproxy.**{*; } -keep class * implements com.qckiss.liblifecycleproxy.IApplicationProxyCopy the code

Three, operation steps

Like plus star small gift copy and paste everyone love if there is a BUG remember small book with your long knife to cutCopy the code