首页 > 代码库 > Gradle 模板配置

Gradle 模板配置

对于新手配置Gradle是一件很痛苦的事,记住二句话绝对搞定

1.在Gradle-->gradle-wrapper.properties中配置distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip  ;//这个是modle的版本

2.在build.gradle中更改classpath ‘com.android.tools.build:gradle:2.2.2‘  //这个是工具用到的版本

 

Example:

apply plugin: ‘com.android.application‘
apply plugin: ‘android-apt‘

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId ""
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    //极光推送配置
    sourceSets {
        main {
            jniLibs.srcDirs = [‘libs‘]
            assets.srcDirs = [‘src/main/assets‘, ‘src/main/assets/‘]
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            signingConfig signingConfigs.debug
            proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘
        }
        debug {
            minifyEnabled false
            signingConfig signingConfigs.debug
            proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘
        }
    }
    signingConfigs {
        debug {
            storeFile file(‘hanyi.jks‘)
            storePassword "0213abcd"
            keyAlias "hanyi"
            keyPassword "0213abcd"
        }
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

}

dependencies {
    compile fileTree(include: [‘*.jar‘], dir: ‘libs‘)
    compile ‘com.android.support:appcompat-v7:23.4.0‘
    compile ‘com.android.support:support-v4:23.4.0‘
    compile ‘com.android.support:design:24.2.0‘
    
    //json解析Gson,fastjson
    compile ‘com.google.code.gson:gson:2.7‘
    compile ‘com.alibaba:fastjson:1.2.21‘
    
    //图片加载库Glide
    compile ‘com.github.bumptech.glide:glide:3.7.0‘
    compile ‘com.facebook.fresco:fresco:0.12.0‘//我后加的

    compile ‘com.zxy.android:recovery:0.0.8‘//crash后处理,在banner项目里有用到,沉浸式是用的这个
    
    //轮播图库
    compile ‘com.youth.banner:banner:1.3.3‘
    testCompile ‘junit:junit:4.12‘
    //compile ‘com.recker.flybanner:flybanner:1.3‘ //enjoy用的
    
    //okhttputils库
    compile ‘com.zhy:okhttputils:2.6.2‘
    compile ‘com.squareup.okhttp3:okhttp:3.4.1‘
    
    // butterknife 关联类库
    compile ‘com.jakewharton:butterknife:8.4.0‘
    apt ‘com.jakewharton:butterknife-compiler:8.4.0‘
    
    //EventBus
    compile ‘org.greenrobot:eventbus:3.0.0‘
    // BaseRecyclerView适配器
    compile ‘com.github.CymChad:BaseRecyclerViewAdapterHelper:2.5.0‘
    
    //友盟登录分享
    compile files(‘libs/umeng_social_api.jar‘)
    compile files(‘libs/umeng_social_net.jar‘)
    compile files(‘libs/SocialSDK_QQ_Simplify.jar‘)
    compile files(‘libs/SocialSDK_Sina_Simplify.jar‘)
    compile files(‘libs/SocialSDK_WeChat_Simplify.jar‘)
    compile files(‘libs/umeng_social_tool.jar‘)
    compile files(‘libs/umeng_social_shareview.jar‘)
    
    //融云即时通讯
    compile project(‘:Rong_Cloud_Android_IMKit_SDK_v2_7_3_stable‘)
    
    //极光推送
    compile files(‘libs/jpush-android-2.2.0.jar‘)
    
    //Zxing
    compile ‘cn.yipianfengye.android:zxing-library:2.1‘
    
    //6.0添加权限
    compile ‘com.yanzhenjie:permission:1.0.3‘
    compile ‘pub.devrel:easypermissions:0.3.0‘//个人推荐用这个

}

Gradle 模板配置