Skip to content

Instantly share code, notes, and snippets.

@shuanghua
Last active January 28, 2023 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shuanghua/ea6fb9033d28f67503f38ccfc21596ca to your computer and use it in GitHub Desktop.
Save shuanghua/ea6fb9033d28f67503f38ccfc21596ca to your computer and use it in GitHub Desktop.
一份包含签名、DataBinding 等配置的 Android 项目 build.gradle.kts
// Project/keystore//keystore/xxxxxx.jks
// Project/keystore//keystore.properties
// < keystore.properties 内容> :
// storePassword=xxxxxxx
// keyPassword=xxxxxxx
// keyAlias=xxxxxxx
// storeFile=/keystore/xxxxxx.jks
import org.jetbrains.kotlin.konan.properties.Properties
import org.jetbrains.kotlin.konan.properties.loadProperties
val keystorePropertiesPath: String = rootProject.file("keystore.properties").path
val keystoreProperties: Properties = loadProperties(keystorePropertiesPath)
plugins {
id("com.android.application")
kotlin("android")
kotlin("android.extensions")
kotlin("kapt")
id("androidx.navigation.safeargs.kotlin")
}
android {
compileSdkVersion(29)
buildToolsVersion = "29.0.0"
defaultConfig {
applicationId = "com.demo.weather"
minSdkVersion(21)
targetSdkVersion(29)
versionCode = (1)
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
sourceSets {
getByName("main").java.srcDirs("src/main/kotlin")
}
lintOptions {
isAbortOnError = false
}
dataBinding {
isEnabled = true
}
signingConfigs {
create("release") {
storeFile = rootProject.file(keystoreProperties["storeFile"].toString())
keyAlias = keystoreProperties["keyAlias"].toString()
keyPassword = keystoreProperties["keyPassword"].toString()
storePassword = keystoreProperties["storePassword"].toString()
}
}
buildTypes {
getByName("release") {
signingConfig = signingConfigs.getByName("release")//此处的名字需要和前面的一致
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
getByName("debug") {
signingConfig = signingConfigs.getByName("release")
isMinifyEnabled = false
resValue("string", "PORT_NUMBER", "9999")
}
}
}
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
implementation("androidx.legacy:legacy-support-v4:1.0.0")
testImplementation("junit:junit:4.12")
androidTestImplementation("androidx.test:runner:1.3.0-alpha02")
androidTestImplementation("androidx.test.espresso:espresso-core:3.3.0-alpha02")
//-------------------------Kotlin-------------------------------------------------
val coroutinesVersion = "1.3.0-M2"
val kotlinVersion = "1.3.50-eap-5"
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion")
implementation("org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.0.5")
//----------------------Androidx------------------------------------------
val coreVersion = "1.2.0-alpha02"
val appcompatVersion = "1.1.0-rc01"
val lifecycleVersion = "2.2.0-alpha02"
val roomVersion = "2.1.0"
val navVersion = "2.1.0-beta02"
val activityVersion = "1.1.0-alpha01"
val fragmentVersion = "1.2.0-alpha01"
val preferenceVersion = "1.1.0-rc01"
val recyclerViewVersion = "1.1.0-beta01"
implementation("androidx.constraintlayout:constraintlayout:2.0.0-beta2")
implementation("androidx.recyclerview:recyclerview:$recyclerViewVersion")
implementation("androidx.appcompat:appcompat:$appcompatVersion")
//implementation "androidx.appcompat:appcompat-resources:$appcompatVersion"
implementation("androidx.core:core:$coreVersion")
implementation("androidx.core:core-ktx:$coreVersion")
implementation("androidx.activity:activity:$activityVersion")
implementation("androidx.activity:activity-ktx:$activityVersion")
implementation("androidx.fragment:fragment:$fragmentVersion")
implementation("androidx.fragment:fragment-ktx:$fragmentVersion")
implementation("androidx.preference:preference:$preferenceVersion")
implementation("androidx.lifecycle:lifecycle-extensions:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion")
implementation("androidx.room:room-runtime:$roomVersion")
implementation("androidx.room:room-ktx:$roomVersion")
kapt("androidx.room:room-compiler:$roomVersion")
implementation("androidx.navigation:navigation-fragment:$navVersion")
implementation("androidx.navigation:navigation-ui:$navVersion")
//------------------------Google----------------------------------------------
val daggerVersion = "2.24"
val materialVersion = "1.1.0-alpha08"
implementation("com.google.android.material:material:$materialVersion")
implementation("com.google.dagger:dagger:$daggerVersion")
implementation("com.google.dagger:dagger-android:$daggerVersion")
implementation("com.google.dagger:dagger-android-support:$daggerVersion")
kapt("com.google.dagger:dagger-compiler:$daggerVersion")
kapt("com.google.dagger:dagger-android-processor:$daggerVersion")
//-------------------------Squareup----------------------------------------------
val retrofit2Version = "2.6.0"
val moshiVersion = "1.8.0"
implementation("com.squareup.retrofit2:retrofit:$retrofit2Version")
implementation("com.squareup.retrofit2:converter-moshi:$retrofit2Version")
implementation("com.squareup.moshi:moshi:$moshiVersion")
kapt("com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion")
implementation("com.squareup.okhttp3:logging-interceptor:4.0.1")
//---------------------- 内存泄漏检测 ---------------------------------------------
val leakCanaryVersion = "1.6.3"
debugImplementation("com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion")
releaseImplementation("com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion")
debugImplementation("com.squareup.leakcanary:leakcanary-support-fragment:$leakCanaryVersion")
//------------------------------------- Glide ----------------------------------
val glideVersion = "4.9.0"
implementation("com.github.bumptech.glide:glide:$glideVersion")
annotationProcessor("com.github.bumptech.glide:compiler:$glideVersion")
kapt("com.github.bumptech.glide:compiler:$glideVersion")
//----------------------权限、布局数据适配、日志--------------------------------------
//implementation "pub.devrel:easypermissions:1.2.0"
implementation("com.yanzhenjie.permission:x:2.0.1")
implementation("me.drakeet.multitype:multitype:4.0.0-alpha2")
implementation("com.jakewharton.timber:timber:4.7.1")
//--------- SQLScout插件连接数据库, AndroidStudio 没有该插件请删掉 --------------------
debugImplementation("com.idescout.sql:sqlscout-server:4.1")
releaseImplementation("com.idescout.sql:sqlscout-server-noop:4.1")
//------------------------ 浏览器查看 SQLite 数据库 ---------------------------------
debugImplementation("com.amitshekhar.android:debug-db:1.0.6")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment