场景:记录一些Android开发过程中常用的配置项。(持续更新)
①:APP build.gradle:
android {
...
//签名配置,用于gradle脚本打包
signingConfigs {
release {
keyAlias 'key名称'
keyPassword 'key密码'
storeFile file('签名文件路径')
storePassword '签名文件密码'
}
debug {
keyAlias ''
keyPassword ''
storeFile file('')
storePassword ''
}
}
//开启dataBing
dataBinding {
enabled true
}
//使用JDK1.8编译
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
②:项目 build.gradle:
buildscript {
repositories {
//使用阿里的仓库,解决库下不下来的问题
maven { url'http://maven.aliyun.com/nexus/content/groups/public' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://dl.google.com/dl/android/maven2/' }
maven { url 'https://dl.bintray.com/umsdk/release' }
maven { url 'https://jitpack.io' }
}
dependencies {
...
}
}
allprojects {
repositories {
//使用阿里的仓库,解决库下不下来的问题
maven { url'http://maven.aliyun.com/nexus/content/groups/public' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://dl.google.com/dl/android/maven2/' }
maven { url 'https://dl.bintray.com/umsdk/release' }
maven { url 'https://jitpack.io' }
maven { url 'http://central.maven.org/maven2/' }
}
}
③:秘钥生成,打开终端,输入以下命令:
keytool -genkey -alias alias的名称 -keyalg RSA -validity 有效时间(天) -keystore keystore文件名
示例:
keytool -genkey -alias Flash -keyalg RSA -validity 5000 -keystore flash.keystore
?生成的key文件路径(macOS):/Users/flash/flash.keystore
④:项目的.gitignore忽略文件一些配置,根据实际情况增删:
/local.properties
.DS_Store
/captures
**/build
**.iml
.gradle/*
.idea/*
.settings
./.gitignore
⑤:...
⑥:...
|