GithubHelp home page GithubHelp logo

smallbuer / jimu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mqzhangw/jimu

8.0 1.0 1.0 1.19 MB

优化版的JIMU组件化方案,支持组件的代码资源隔离、单独调试、集成调试、组件交互、UI跳转、生命周期等完整功能。

License: Apache License 2.0

Groovy 14.28% Java 84.64% Kotlin 1.08% Batchfile 0.01%

jimu's Introduction

本分支只是为了解决windows机器使用JIMU框架上遇到的无法删除问题;组件化原理请参考原著:地址: https://github.com/mqzhangw/JIMU

1.windows出现Could not delete path ... app\build\intermediates\transforms\desugar\debug\0.jar错误,根据原因分析得出是Javassist修改类方法时导致Java程序无法释放问题导致的;

2.结合AutoRegister方案,使用效率更高的ASM框架来进行字节码分析和修改,非常感谢作者,原著地址:https://github.com/luckybilly/AutoRegister;

3.具体实现步骤: 1.替换原有项目中com.github.jimu:build-gradle:1.*.*为com.smallbuer:build-gradle:1.0.5,已上传到jcenter仓库;

2.在app主module中新建类AppCompCore.class,主要用于AMS修改时找到需要插入注册组件的代码;代码内容如下:

package com.luojilab.componentdemo.application;

import android.util.Log;

import com.luojilab.component.componentlib.applicationlike.IApplicationLike;

public class AppCompCore {

    public static void rigisterComp(IApplicationLike iApplicationLike){
        Log.d("asm---",""+iApplicationLike.getClass().getSimpleName());
        iApplicationLike.onCreate();
    }

    public static void initComp(){

    }

}

然后在主module中的build.gradle中添加自动注册的代码;

autoregister {

    registerInfo = [

            [
                    'scanInterface'             : 'com.luojilab.component.componentlib.applicationlike.IApplicationLike'
                    , 'codeInsertToClassName'   : 'com.luojilab.componentdemo.application.AppCompCore'
                    , 'codeInsertToMethodName'  : 'initComp' 
                    , 'registerMethodName'      : 'rigisterComp' 
            ]
    ]
}

3.然后删除所有module中的combuild字段;

//combuild {
//    applicationName = 'com.luojilab.componentdemo.application.AppApplication'
//    isRegisterCompoAuto = true
//}

4.然后编译,在编译过程中会扫描出所有集成IApplicationLike的类,然后在AppCompCore类中initComp方法中动态插入该类的实例并实现rigisterComp方法,所以在编译期就自动执行了组件中的onCreate()方法;

5.以上操作只是修改了每一个组件自动注入执行onCreate方法的方式,并不修改其他地方;所以不需要有其他的改动;只是为windows机器无法删除的bug的一种解决方案;

6.继续支持组件的单独打包编译;

jimu's People

Contributors

leobert-lan avatar mqzhangw avatar smallbuer avatar monkeydone avatar

Stargazers

 avatar FishYY1989 avatar  avatar Yuuta Liang avatar  avatar Byte Involution avatar JD-CP avatar Shengzhong Zhang avatar

Watchers

James Cloos avatar

Forkers

ouyangpeng

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.