build.gradle的常用配置

1,project的下的gradle配置

project和modules的區(qū)別,我們都清楚,gradle構(gòu)建配置如下:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        //mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' //注入框架必須增加這一句
        //classpath 'org.greenrobot:greendao-gradle-plugin:3.2.0'
    }
}
allprojects {//在配置中加入自定義的倉庫
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

2,module配置,app

配置簽名,各種版本信息,sdk,混淆打包,依賴文件,第三方庫等

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'//依賴注入
//apply plugin: 'org.greenrobot.greendao'
android {
    signingConfigs {
        oair_android_keystore {
            keyAlias 'oair_android'
            keyPassword KEY_PASSWORD
            storeFile file('../../keystore/android.keystore')
            storePassword KEYSTORE_PASSWORD//密碼保存在gradle.properties中
        }
    }

    compileSdkVersion 25
    buildToolsVersion "25.0.0"http://版本與你as的buildtool版本一致

    defaultConfig {
        applicationId "cn.net.duqian"
        minSdkVersion 11
        targetSdkVersion 24
        versionCode 1
        versionName "1.0.2"
        signingConfig signingConfigs.android_keystore
        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
    }

    buildTypes {
        release {
            minifyEnabled true//打開混淆
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            shrinkResources true// 移除無用的resource文件
            signingConfig signingConfigs.android_keystore
        }
        debug {
            signingConfig signingConfigs.android_keystore
        }
    }
   //多個版本的打包配置
    productFlavors {
        Version1{
            applicationId "package name1"
            manifestPlaceholders = [GAO_DE_KEY: "your gaode key1", UMENG_KEY: "your umeng key1"]
        }
        Version2 {
            applicationId "package name2"
            manifestPlaceholders = [GAO_DE_KEY: "your gaode key2", UMENG_KEY: "your umeng key2"]
        }
    }
   /* lintOptions {
        disable 'InvalidPackage'
    }
    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }*/

    /*greendao{
        schemaVersion 1000 //數(shù)據(jù)庫版本號
        daoPackage 'com.oair.ssy.model.db' //設(shè)置DaoMaster、DaoSession、Dao包名
        targetGenDir 'src/main/java'//設(shè)置DaoMaster、DaoSession、Dao目錄
    }*/

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':vitamio4.2.6')
    testCompile 'junit:junit:4.12'
    //testCompile 'org.mockito:mockito-core:2.0.99-beta'
    //testCompile 'org.robolectric:robolectric:3.1.2'
   
    compile 'com.android.support:support-v4:25.0.1'
    compile 'com.android.support:appcompat-v7:25.0.1'
    compile 'com.android.support:cardview-v7:25.0.1'
    compile 'com.android.support:recyclerview-v7:25.0.1'
    compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.1.3'
    compile 'com.jakewharton:butterknife:8.4.0'
    apt 'com.jakewharton:butterknife-compiler:8.4.0'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:retrofit-adapters:2.1.0'
    compile 'com.squareup.retrofit2:retrofit-converters:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    /*compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    compile 'io.reactivex:rxjava:1.1.10'
    compile 'io.reactivex:rxandroid:1.2.1'*/
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.okio:okio-parent:1.10.0'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.google.dagger:dagger:2.7'
    provided 'com.google.dagger:dagger-compiler:2.7'
    provided 'org.glassfish:javax.annotation:10.0-b28'
    compile 'com.squareup.leakcanary:leakcanary-android:1.4'
    compile 'com.umeng.analytics:analytics:5.6.4'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.github.chrisbanes:PhotoView:1.3.0'
    compile 'com.squareup.picasso:picasso:2.5.2'

    compile 'com.github.barteksc:android-pdf-viewer:2.3.0'
    //compile 'org.greenrobot:greendao:3.2.0'
}

未完待續(xù)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,316評論 25 708
  • 轉(zhuǎn)至:http://blog.csdn.net/heqiangflytosky/article/details/5...
    kkgo閱讀 3,033評論 0 1
  • 有時候會覺得 喝茶不但是一種味道 更多的應(yīng)該是一種心情 是茶 器 空間 聲音 泡茶的動態(tài)整體融合 我們不僅停留在茶...
    常樂丶閱讀 144評論 0 0
  • 陳春萍 求職目標(biāo):Amazon 運營; 外貿(mào)主管 年齡:26歲 籍貫:江蘇 常州 溧陽 地址:廣東 深圳 坂田 手...
    c3ae907411c0閱讀 468評論 0 0
  • 光芒萬丈長 風(fēng)吹夜凄涼 蒼穹孤星亮 我心獨彷徨
    劉波ONE閱讀 386評論 0 0

友情鏈接更多精彩內(nèi)容