Giter Site home page Giter Site logo

aroutetest's Introduction

模块化开发 ARouter + ButterKnife 应用Test

modulebase作为base library。app、modulea、moduleb 均作为单独的模块

1、根目录下gradle.properties进行全局变量定义(包含引用版本、是否模块化debug开发)
2、ARouter初始化及应用(https://github.com/alibaba/ARouter)
    1、modulebase 设置;
        a、build.gradle
            android {
                defaultConfig {
                ...
                javaCompileOptions {
                    annotationProcessorOptions {
                    arguments = [ moduleName : project.getName() ]
                    }
                }
                }
            }
            dependencies {
              compile 'com.alibaba:arouter-api:x.x.x'
              annotationProcessor 'com.alibaba:arouter-compiler:x.x.x'
            }
        b、MyApplication
           进行初始化
    2、App modulea moduleb 设置:  
        javaCompileOptions {
                  annotationProcessorOptions {
                      arguments = [ moduleName : project.getName() ]
                  }
              }
        annotationProcessor "com.alibaba:arouter-compiler:${arouter_compiler_version}"    
            
3、ButterKnife 8.8.1应用
    1、根build.gradle设置
       buildscript {
           repositories {
               jcenter()
           }
           dependencies {
               //buterknife 版本要求
               classpath 'com.android.tools.build:gradle:2.3.3'
               classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'
           }
       }
    2、modulebase设置
       apply plugin: 'com.jakewharton.butterknife'
       compile "com.jakewharton:butterknife:${butterknife_version}"
    
    3、app moudlea moduleb设置
       apply plugin: 'com.jakewharton.butterknife'
       annotationProcessor "com.jakewharton:butterknife-compiler:${butterknife_compiler_version}"
    4、注意:在app modulea moduleb 中butterknife注入的,都使用R2 而非R
    
4、模块化modulea 设置:

   1、在modulea的AndroidMainfest.xml中添加如下设置
       android:name="com.bamboolmc.modulebase.MyApplication"
               android:icon="@mipmap/ic_launcher"
               android:theme="@style/AppTheme"
       
       //启动的activity下
       <intent-filter>
               action android:name="android.intent.action.MAIN"/>
               <category android:name="android.intent.category.LAUNCHER"/>
       </intent-filter>
   2、修改根gradle.properties 下的全局变量
       IsDebugModuleApp = true
        IsDebugModuleA = true
        IsDebugModuleB = true


5、注意: 将module合并时,需要在主app的build.gradle 下添加依赖关系
        if (!IsDebugModuleA.toBoolean()) {
             compile project(':modulea')
         }

aroutetest's People

Contributors

bambooblacklee avatar

Watchers

James Cloos avatar  avatar

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.