build.gradle文件
apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao' // 使用greenDAO def static releaseTime() {//获取当前时间
return new Date().format("MMdd", TimeZone.getTimeZone("UTC"))
}
android {
compileSdkVersion project.ext.compileSdkVersion//引用统一配置
buildToolsVersion '28.0.3' compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8//支持java8
targetCompatibility JavaVersion.VERSION_1_8
} defaultConfig {
applicationId "xx.xx.xx"
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
versionCode 24
versionName "1.0.9.4" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk { // 设置支持的SO库架构
abiFilters 'armeabi-v7a' //设置支持的arm架构
} vectorDrawables.useSupportLibrary = true//是否使用svg } signingConfigs {//使用签名文件
debug {
storeFile file('xx.jks')
storePassword "xxxx"
keyAlias "xxxx"
keyPassword "xxxx"
} release {
storeFile file('xxx.jks')
storePassword "xxx"
keyAlias "xxx"
keyPassword "xxxx"
}
} buildTypes {//打包命名
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "isNative", "false"
applicationVariants.all { variant ->
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
outputFileName = "${defaultConfig.versionName}.apk"
}
}
}
signingConfig signingConfigs.release
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "isNative", "true"
applicationVariants.all { variant ->
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
outputFileName = "${defaultConfig.versionName}_${versionNameSuffix}.apk"
}
}
}
versionNameSuffix "_debug_${releaseTime()}"
}
} flavorDimensions "api" productFlavors {//个性化配置
dev {
dimension "api"
buildConfigField "String", "BaseURL", '"http://192.168.10.175:3201"'
buildConfigField "String", "APIURL", '"http://192.168.10.175:3201"'
buildConfigField "String", "MQTT_SERVER", '"tcp://192.168.25.209:1883"' } normal {
dimension "api"
buildConfigField "String", "BaseURL", '"http://xxxx.com.cn"'
buildConfigField "String", "APIURL", '"http://xxxx.com.cn"'
buildConfigField "String", "MQTT_SERVER", '"ssl://xxxxx.com.cn:8883"'
}
} sourceSets {//jniLib目录支持app/libs
main.jniLibs.srcDirs = ['libs']
} lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
} } greendao {
schemaVersion 4
daoPackage 'ai.yunji.delivery.greendao.gen'
targetGenDir 'src/main/java'
} repositories {
flatDir {
dirs 'libs'
}
} dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
// implementation 'org.glassfish.tyrus.bundles:tyrus-standalone-client:1.5'
// implementation('edu.wpi.rail:jrosbridge:0.2.0') {
// exclude group: 'org.glassfish.grizzly'
// exclude group: 'org.glassfish.tyrus'
// }
//log相关
implementation 'com.tencent.bugly:crashreport:latest.release'
//其中latest.release指代最新Bugly SDK版本号,也可以指定明确的版本号,例如2.1.9
implementation 'com.tencent.bugly:nativecrashreport:latest.release'
//其中latest.release指代最新Bugly NDK版本号,也可以指定明确的版本号,例如3.0
implementation 'com.trello.rxlifecycle2:rxlifecycle:2.1.0'
implementation 'com.trello.rxlifecycle2:rxlifecycle-android:2.1.0'
implementation 'com.trello.rxlifecycle2:rxlifecycle-components:2.1.0'
implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.3@aar'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation "com.android.support:design:${supportLibVersion}"
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
// implementation 'com.github.bumptech.glide:glide:4.7.1'
// annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
implementation "com.android.support:recyclerview-v7:${supportLibVersion}"
// implementation 'com.jcodecraeer:xrecyclerview:1.5.9'
// implementation 'com.orhanobut:logger:2.2.0'
implementation 'com.elvishew:xlog:1.4.0'
implementation 'org.greenrobot:eventbus:3.0.0'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.3'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.zhy:okhttputils:2.6.2'
//greenDao
implementation 'org.greenrobot:greendao:3.1.0'
//logger
// implementation 'com.orhanobut:logger:2.2.0' implementation 'com.squareup.retrofit2:retrofit:2.4.0'
// Retrofit库
implementation('com.squareup.retrofit2:converter-gson:2.1.0') {
exclude group: 'com.google.code.gson', module: 'gson'
}
implementation 'com.alibaba:fastjson:1.2.58'
implementation 'com.belerweb:pinyin4j:2.5.1' implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.1.1' debugImplementation 'com.amitshekhar.android:debug-db:1.0.3'
implementation project(path: ':logger')
// implementation project(path: ':Water') configurations {
all*.exclude group: 'com.google.code.gson'
} }
项目的build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript {
repositories {
google()//如果网络不好,可以使用阿里服务器的镜像地址
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1' // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.novoda:bintray-release:0.8.0'
// classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1-rc1' //GreanDao
classpath 'org.greenrobot:greendao-gradle-plugin:3.1.0'
}
}/*
ext { compileSdkVersion = 27
buildToolsVersion = '27.0.3'
minSdkVersion = 14
targetSdkVersion = 27
supportLibraryVersion = '27.0.2'
versionCode = 113
versionName = "1.1.3"
}*/ ext {
minSdkVersion = 8
targetSdkVersion = 27
compileSdkVersion = 27
buildToolsVersion = '27.0.3'
} ext.deps = [
junit : 'junit:junit:4.12',
truth : 'com.google.truth:truth:0.28',
robolectric : 'org.robolectric:robolectric:3.3',
mockito : "org.mockito:mockito-core:2.8.9",
json : "org.json:json:20160810",
supportAnnotations: "com.android.support:support-annotations:27.1.0",
] subprojects {
apply from: "${rootProject.rootDir}/common_config.gradle"
}
allprojects {
repositories {
google()
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
jcenter()
mavenCentral()
}
} task clean(type: Delete) {
delete rootProject.buildDir
}
gradle.properties
android.injected.testOnly=false#一般情况下debug包给用户是安装不了的,因为打包的时候会自动在androidmenifest.xml中添加testOnly=true,这种情况下只能使用adb install -t xxx.apk安装,如果加这句话就不会影响安装了