Android 依赖库

目前开发的项目基础依赖库分享:
一、根目录新建config.gradle,添加依赖信息:

ext {
    android = [
            compileSdkVersion: 29,
            buildToolsVersion: "29.0.3",
            minSdkVersion    : 23,
            targetSdkVersion : 29,
            versionCode      : 1,
            versionName      : "1.0.0",
            applicationId    : "",
    ]

    manifestPlaceholders = [
            serverHost: "",
    ]


    dependencies = [
            "material"                     : 'com.google.android.material:material:1.1.0',
            //androidx
            "appcompat"                    : 'androidx.appcompat:appcompat:1.1.0',
            "core-ktx"                     : 'androidx.core:core-ktx:1.2.0',
            "constraintlayout"             : 'androidx.constraintlayout:constraintlayout:1.1.3',
            "recyclerview"                 : 'androidx.recyclerview:recyclerview:1.1.0',
            "swiperefreshlayout"           : 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha03',
            "lifecycle-extensions"         : 'androidx.lifecycle:lifecycle-extensions:2.2.0',
            "lifecycle-viewmodel-ktx"      : 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0',
            "navigation-fragment"          : 'androidx.navigation:navigation-fragment:2.2.2',
            "navigation-fragment-ktx"      : 'androidx.navigation:navigation-fragment-ktx:2.2.2',
            "navigation-ui"                : 'androidx.navigation:navigation-ui:2.2.2',
            "navigation-ui-ktx"            : 'androidx.navigation:navigation-ui-ktx:2.2.2',
            //multidex
            "multidex"                     : 'androidx.multidex:multidex:2.0.1',
            //coroutines
            "coroutines"                   : 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.1',
            //retrofit
            "retrofit"                     : 'com.squareup.retrofit2:retrofit:2.7.1',
            "retrofit-convert"             : 'com.squareup.retrofit2:converter-gson:2.7.1',
            "retrofit-adapter"             : 'com.squareup.retrofit2:adapter-rxjava2:2.7.1',
            "logging-interceptor"          : 'com.squareup.okhttp3:logging-interceptor:3.12.0',
            //rxjava
            "rxandroid"                    : 'io.reactivex.rxjava2:rxandroid:2.1.1',
            "rxlifecycle"                  : 'com.trello.rxlifecycle3:rxlifecycle-components:3.1.0',
            //glide
            "glide"                        : 'com.github.bumptech.glide:glide:4.11.0',
            "glide-compiler"               : 'com.github.bumptech.glide:compiler:4.10.0',
            "glide-transformation"         : 'jp.wasabeef:glide-transformations:4.0.0',
            //baseadapter
            "BaseRecyclerViewAdapterHelper": 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50',
            //eventbus
            "eventbus"                     : 'org.greenrobot:eventbus:3.1.1',
            //bugly
            "bugly"                        : 'com.tencent.bugly:crashreport_upgrade:1.4.5',
            //webview
            "agentweb"                     : 'com.just.agentweb:agentweb:4.1.2',
            //cookie
            "PersistentCookie"             : 'com.github.franmontiel:PersistentCookieJar:v1.0.1',//轮播图
            //banner
            "banner"                       : 'com.youth.banner:banner:1.4.10',
            //缩放图片
            "scale-image"                  : 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0',
            //flowlayout
            "flowlayout"                   : 'com.hyman:flowlayout-lib:1.1.2',
            //mpandroidchart
            "MPAndroidChart"               : 'com.github.PhilJay:MPAndroidChart:v3.1.0',


    ]

}

二、工程build.gradle引入配置

image.png

三、module的build.gradle中引用

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {

    compileSdkVersion rootProject.ext.android["compileSdkVersion"]
    defaultConfig {
        applicationId rootProject.ext.android["applicationId"]
        minSdkVersion rootProject.ext.android["minSdkVersion"]
        targetSdkVersion rootProject.ext.android["targetSdkVersion"]
        versionCode rootProject.ext.android["versionCode"]
        versionName rootProject.ext.android["versionName"]
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [
                        "room.schemaLocation"  : "$projectDir/build/schemas".toString(),
                        "room.incremental"     : "true",
                        "room.expandProjection": "true"]
            }
        }
    }

    signingConfigs {
        config {
            storeFile file('../jingyingtang.jks')
            storePassword "jyt12345"
            keyAlias "Key0"
            keyPassword "jyt12345"
            v1SigningEnabled true
            v2SigningEnabled true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            signingConfig signingConfigs.config
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            applicationVariants.all { variant ->
                variant.outputs.all { output ->
                    outputFileName = "wandroid_v${defaultConfig.versionName}.apk"
                }
            }
        }
    }
    androidExtensions {
        experimental = true
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    //androidx
    implementation rootProject.ext.dependencies["material"]
    implementation rootProject.ext.dependencies["recyclerview"]
    implementation rootProject.ext.dependencies["swiperefreshlayout"]
    implementation rootProject.ext.dependencies["lifecycle-extensions"]
    implementation rootProject.ext.dependencies["lifecycle-viewmodel-ktx"]

    implementation rootProject.ext.dependencies["navigation-fragment"]
    implementation rootProject.ext.dependencies["navigation-fragment-ktx"]
    implementation rootProject.ext.dependencies["navigation-ui"]
    implementation rootProject.ext.dependencies["navigation-ui-ktx"]
    //multidex
    implementation rootProject.ext.dependencies["multidex"]
    //coroutines
    implementation rootProject.ext.dependencies["coroutines"]
    //retrofit
    implementation rootProject.ext.dependencies["retrofit"]
    implementation rootProject.ext.dependencies["retrofit-convert"]
    implementation rootProject.ext.dependencies["retrofit-adapter"]
    implementation rootProject.ext.dependencies["logging-interceptor"]

    //rxjava
    implementation rootProject.ext.dependencies["rxandroid"]
    implementation rootProject.ext.dependencies["rxlifecycle"]
    //glide
    implementation rootProject.ext.dependencies["glide"]
    kapt rootProject.ext.dependencies["glide-compiler"]
    implementation rootProject.ext.dependencies["glide-transformation"]
    //baseadapter
    implementation rootProject.ext.dependencies["BaseRecyclerViewAdapterHelper"]
    //eventbus
    implementation rootProject.ext.dependencies["eventbus"]
    //bugly
    implementation rootProject.ext.dependencies["bugly"]
    //增强webview
    implementation rootProject.ext.dependencies["agentweb"]
    //cookie
    implementation rootProject.ext.dependencies["PersistentCookie"]
    //banner
    implementation rootProject.ext.dependencies["banner"]
    //scaleimage
    implementation rootProject.ext.dependencies["scale-image"]
    //flowlayout
    implementation rootProject.ext.dependencies["flowlayout"]
    //chart
    implementation rootProject.ext.dependencies["MPAndroidChart"]
}

统一管理依赖版本,这是基础功能依赖库,需要的直接复制即可。

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容