apply plugin: 'com.android.application' apply plugin: 'org.jetbrains.kotlin.android.extensions' apply plugin: 'kotlin-android' // kotlin apply plugin: 'kotlin-kapt' // apkChannelPackage apply plugin: 'channel' apply from: 'tinker-support.gradle' android { androidExtensions { experimental = true } dataBinding { enabled = true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } dexOptions { jumboMode = true } defaultConfig { multiDexEnabled true javaCompileOptions { annotationProcessorOptions { arguments = [eventBusIndex: 'com.gh.EventBusIndex'] } } /** * 只支持两种架构,减少apk大小,有疑问请参考: * https://developer.android.com/ndk/guides/abis.html * http://allenfeng.com/2016/11/06/what-you-should-know-about-android-abi-and-so/ * (为了性能考虑,armeabi可以考虑替换成armeabi-v7a[需要先收集用户设备情况]) */ ndk { abiFilters "armeabi", "x86" } // 由于app只针对中文用户,所以仅保留zh资源,其他删掉 resConfigs "zh" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode rootProject.ext.versionCode versionName rootProject.ext.versionName applicationId rootProject.ext.applicationId proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-fresco.txt' /** * All third-party appid/appkey */ buildConfigField "String", "WECHAT_APPID", "\"${WECHAT_APPID}\"" buildConfigField "String", "WECHAT_SECRET", "\"${WECHAT_SECRET}\"" buildConfigField "String", "TENCENT_APPID", "\"${TENCENT_APPID}\"" buildConfigField "String", "WEIBO_APPKEY", "\"${WEIBO_APPKEY}\"" buildConfigField "String", "MTA_APPKEY", "\"${MTA_APPKEY}\"" buildConfigField "String", "TD_APPID", "\"${TD_APPID}\"" buildConfigField "String", "PATCH_VERSION_NAME", "\"${PATCH_VERSION_NAME}\"" } // gradle 2.2以上默认同时启用v1和v2(优先用于Android N) signingConfigs { debug { v1SigningEnabled true v2SigningEnabled true } release { v1SigningEnabled true v2SigningEnabled true } } buildTypes { debug { debuggable true minifyEnabled false zipAlignEnabled false versionNameSuffix "-debug" signingConfig signingConfigs.debug buildConfigField "String", "UMENG_APPKEY", "\"${DEBUG_UMENG_APPKEY}\"" buildConfigField "String", "UMENG_MESSAGE_SECRET", "\"${DEBUG_UMENG_MESSAGE_SECRET}\"" buildConfigField "String", "MIPUSH_APPID", "\"${DEBUG_MIPUSH_APPID}\"" buildConfigField "String", "MIPUSH_APPKEY", "\"${DEBUG_MIPUSH_APPKEY}\"" } release { debuggable false minifyEnabled true zipAlignEnabled true shrinkResources true signingConfig signingConfigs.release buildConfigField "String", "UMENG_APPKEY", "\"${UMENG_APPKEY}\"" buildConfigField "String", "UMENG_MESSAGE_SECRET", "\"${UMENG_MESSAGE_SECRET}\"" buildConfigField "String", "MIPUSH_APPID", "\"${MIPUSH_APPID}\"" buildConfigField "String", "MIPUSH_APPKEY", "\"${MIPUSH_APPKEY}\"" } } flavorDimensions "nonsense" /** * 多渠道打包,渠道请参考"channel.txt"文件,所有渠道值均通过java code设置 */ productFlavors { // publish release host publish { dimension "nonsense" buildConfigField "String", "API_HOST", "\"${API_HOST}\"" buildConfigField "String", "USER_HOST", "\"${USER_HOST}\"" buildConfigField "String", "COMMENT_HOST", "\"${COMMENT_HOST}\"" buildConfigField "String", "LIBAO_HOST", "\"${LIBAO_HOST}\"" buildConfigField "String", "MESSAGE_HOST", "\"${MESSAGE_HOST}\"" buildConfigField "String", "DATA_HOST", "\"${DATA_HOST}\"" buildConfigField "String", "BUGLY_APPID", "\"${BUGLY_APPID}\"" } // internal test dev host internal { dimension "nonsense" buildConfigField "String", "API_HOST", "\"${DEV_API_HOST}\"" buildConfigField "String", "USER_HOST", "\"${DEV_USER_HOST}\"" buildConfigField "String", "COMMENT_HOST", "\"${DEV_COMMENT_HOST}\"" buildConfigField "String", "LIBAO_HOST", "\"${DEV_LIBAO_HOST}\"" buildConfigField "String", "MESSAGE_HOST", "\"${DEV_MESSAGE_HOST}\"" buildConfigField "String", "DATA_HOST", "\"${DEV_DATA_HOST}\"" buildConfigField "String", "BUGLY_APPID", "\"${DEBUG_BUGLY_APPID}\"" } } // productFlavors.all { flavor -> // flavor.manifestPlaceholders = [CHANNEL_VALUE: name]//命令 gradlew assembleRelease // } } // apkChannelPackage channel { //多渠道包的输出目录,默认为new File(project.buildDir,"channel") baseOutputDir = new File(project.buildDir, "channel") //多渠道包的命名规则,默认为:${appName}-${versionName}-${versionCode}-${flavorName}-${buildType} apkNameFormat = '${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}' } rebuildChannel { // baseDebugApk = 已有Debug APK // baseReleaseApk = 已有Release APK // //默认为new File(project.buildDir, "rebuildChannel/debug") // debugOutputDir = Debug渠道包输出目录 // //默认为new File(project.buildDir, "rebuildChannel/release") // releaseOutputDir = Release渠道包输出目录 } dependencies { implementation fileTree(include: '*.jar', dir: 'libs') debugImplementation "com.squareup.leakcanary:leakcanary-android:${leakcanary}" debugImplementation "com.facebook.stetho:stetho:${stetho}" debugImplementation "com.facebook.stetho:stetho-okhttp3:${stetho}" debugImplementation "com.squareup.okhttp3:logging-interceptor:${okHttp}" implementation "com.android.support:multidex:${multidex}" implementation "com.android.support:design:${androidSupport}" implementation "com.android.support:support-v4:${androidSupport}" implementation "com.android.support:appcompat-v7:${androidSupport}" implementation "com.android.support:cardview-v7:${androidSupport}" implementation "com.android.support:support-annotations:${androidSupport}" implementation "com.android.support:percent:${androidSupport}" implementation "com.android.support.constraint:constraint-layout:${constraintLayout}" implementation "com.kyleduo.switchbutton:library:${switchButton}" implementation "com.readystatesoftware.systembartint:systembartint:${systemBarTint}" implementation "com.facebook.fresco:fresco:${fresco}" implementation "com.facebook.fresco:animated-gif:${fresco}" implementation "com.squareup.okhttp3:okhttp:${okHttp}" implementation "com.leon.channel:helper:${apkChannelPackage}" implementation "com.squareup.retrofit2:retrofit:${retrofit}" implementation "com.squareup.retrofit2:converter-gson:${retrofit}" // include gson 2.7 implementation "com.squareup.retrofit2:adapter-rxjava:${retrofit}" // implementation "com.google.code.gson:gson:${gson}" implementation "com.j256.ormlite:ormlite-android:${ormlite}" implementation "com.j256.ormlite:ormlite-core:${ormlite}" implementation "com.jakewharton:butterknife:${butterKnife}" annotationProcessor "com.jakewharton:butterknife-compiler:${butterKnife}" kapt "com.jakewharton:butterknife-compiler:${butterKnife}" implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}" implementation "org.greenrobot:eventbus:${eventbus}" annotationProcessor "org.greenrobot:eventbus-annotation-processor:${eventbusApt}" implementation "io.reactivex:rxjava:${rxJava}" implementation "io.reactivex:rxandroid:${rxAndroid}" implementation "com.jakewharton.rxbinding:rxbinding:${rxBinding}" //TODO update to rx 2.x // implementation "io.reactivex.rxjava2:rxjava:${rxJava2}" // implementation "io.reactivex.rxjava2:rxandroid:${rxAndroid2}" // implementation "com.jakewharton.rxbinding2:rxbinding:${rxBinding2}" implementation "com.google.zxing:core:${zxing}" implementation "com.google.zxing:android-core:${zxing}" implementation "com.daimajia.swipelayout:library:${swipeLayout}" implementation("cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:${autoScrollViewPager}") { exclude module: 'support-v4' } implementation "com.sina.weibo.sdk:core:${weiboSDK}" // bugly with tinker support implementation "com.tencent.bugly:crashreport_upgrade:${buglyTinkerSupport}" implementation "pub.devrel:easypermissions:${easypermissions}" // mvvm implementation "android.arch.lifecycle:runtime:${archLifecycleVersion}" kapt "android.arch.lifecycle:compiler:${archLifecycleVersion}" implementation "android.arch.lifecycle:extensions:${archLifecycleVersion}" implementation "android.arch.persistence.room:runtime:${archRoomVersion}" kapt "android.arch.persistence.room:compiler:${archRoomVersion}" implementation 'com.google.android:flexbox:0.2.2' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" kapt 'com.android.databinding:compiler:3.0.1' implementation 'com.contrarywind:Android-PickerView:4.1.3' implementation "com.scwang.smartrefresh:SmartRefreshLayout:${smartRefreshLayout}" implementation "net.cachapa.expandablelayout:expandablelayout:${expandableLayout}" implementation project(':libraries:LGLibrary') implementation project(':libraries:MTA') implementation project(':libraries:QQShare') implementation project(':libraries:TalkingData') implementation project(':libraries:UmengPush') implementation project(':libraries:WechatShare') implementation project(':libraries:iosched') implementation project(':libraries:LogHub') } File propFile = file('sign.properties') if (propFile.exists()) { Properties props = new Properties() props.load(new FileInputStream(propFile)) if (props.containsKey('keyAlias') && props.containsKey('keyPassword') && props.containsKey('storeFile') && props.containsKey('storePassword')) { android.signingConfigs { // debug 不要使用正式签名,这样tinker才不会打补丁。 debug { keyAlias props.get('keyAlias') keyPassword props.get('keyPassword') storeFile file(props.get('storeFile')) storePassword props.get('storePassword') } release { keyAlias props.get('keyAlias') keyPassword props.get('keyPassword') storeFile file(props.get('storeFile')) storePassword props.get('storePassword') } } } else { android.buildTypes.release.signingConfig = null } } else { android.buildTypes.release.signingConfig = null }