在Android中引入XDroid

XDroid是一个轻量级的Android快速开发框架
由UI、Cache、Event、ImageLoader、Kit、Log、Router、Net等几个部分组成。其设计思想是使用接口对各模块解耦规范化,不强依赖某些明确的三方类库,使得三方类库可自由搭配组装,方便替换。可快速、自由的进行App开发。
XDroid链接

引入

以下打星号部分需要注意

  • clone 'XDroid'库到本地
git clone https://github.com/limedroid/XDroid.git
    1. 新建conf.gradle
ext {

    android = [
            compileSdkVersion: 25,
            buildToolsVersion: "25.0.3",

            minSdkVersion    : 19,
            targetSdkVersion : 25,

            versionCode      : 1,
            versionName      : '1.0.0',

            VSupportSdk      : '25.1.0'
    ]

    dependencies = [
            "appcompat-v7"   : "com.android.support:appcompat-v7:${android["VSupportSdk"]}",
            "support-v4"     : "com.android.support:support-v4:${android["VSupportSdk"]}",
            "design"         : "com.android.support:design:${android["VSupportSdk"]}",
            "annotations"    : "com.android.support:support-annotations:${android["VSupportSdk"]}",
            "recyclerview-v7": "com.android.support:recyclerview-v7:${android["VSupportSdk"]}",
            "butterknife"    : "com.jakewharton:butterknife:8.4.0",
            "butterknife-apt": "com.jakewharton:butterknife-compiler:8.4.0",
            "glide"          : "com.github.bumptech.glide:glide:3.7.0",
            "picasso"        : "com.squareup.picasso:picasso:2.5.2",
            "okhttp3"        : "com.squareup.okhttp3:okhttp:3.3.0",
            "gson"           : "com.google.code.gson:gson:2.6.2",
            "eventbus"       : "org.greenrobot:eventbus:3.0.0",
            "xrecyclerview"  : "com.github.limedroid:ARecyclerView:v1.1.5",
            "okhttputils"    : "com.zhy:okhttputils:2.6.2",
            "canary-debug"   : "com.squareup.leakcanary:leakcanary-android:1.4-beta2",
            "canary-release" : "com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2",
            "avi-loading"    : "com.wang.avi:library:1.0.2",
            "XDroid-Base"    : "com.github.fodroid:XDroid-Base:v1.4"
    ]
}
    1. 导入模块,导入XDroid中的library
在Android中引入XDroid_第1张图片
导入模块
    1. 根目录下的build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: "conf.gradle"  //***
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" } //****
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
    1. app下的build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt' //***

android {
    compileSdkVersion rootProject.ext.android.compileSdkVersion
    buildToolsVersion rootProject.ext.android.buildToolsVersion
    defaultConfig {
        applicationId "com.XXX.XXX"
        minSdkVersion rootProject.ext.android.minSdkVersion
        targetSdkVersion rootProject.ext.android.targetSdkVersion
        versionCode rootProject.ext.android.versionCode
        versionName rootProject.ext.android.versionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' //***
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    apt rootProject.ext.dependencies["butterknife-apt"] //***
    compile rootProject.ext.dependencies["avi-loading"] //***
    compile project(':library') //***
}
以上就可以了

之前自己没有在app中添加

apply plugin: 'com.neenbedankt.android-apt' //***


apt rootProject.ext.dependencies["butterknife-apt"] //***
compile rootProject.ext.dependencies["avi-loading"] //***

然后@BindView()会出现问题。

当然,还没有仔细研究,死搬硬套了-。-勿喷

你可能感兴趣的:(在Android中引入XDroid)