Skip to content

Instantly share code, notes, and snippets.

@xxnjdlys
Created December 16, 2016 12:01
Show Gist options
  • Save xxnjdlys/ec3c6a6630eb653c9621fbffecc04bec to your computer and use it in GitHub Desktop.
Save xxnjdlys/ec3c6a6630eb653c9621fbffecc04bec to your computer and use it in GitHub Desktop.
client
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
repositories {
mavenCentral()
maven {
url "http://112.124.19.81:8081/nexus/content/repositories/releases"
credentials {
username 'libuser'
password 'b813b813'
}
}
flatDir {
dirs 'libs'
}
}
ext {
/**
* - 要求
* - Android Studio 2.0以及以上
* - 开启设置中的instant run
*
* 下面的开关按照需开启,不用的时候接关闭 instant = false
* 这个开关是multi dex下instant run的flavor开关
* 开启后可以在ide左下Build Variant中选择instantDebug
* 选一个API21及以上的设备进行调试
*/
instant = true
/**
* 先将protocol gradle minifyEnabled 改为 true 就可以debug了
* 默认不显示protocolJar 的Build Variant
*/
protocolJar = false
}
/**
* below link is about improving Gradle build performance.
* https://plus.google.com/+AndroidDevelopers/posts/ECrb9VQW9XP
*/
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileOptions.encoding = "UTF-8"
/**
* dexOptions
* http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.DexOptions.html
* https://source.android.com/devices/tech/dalvik/dalvik-bytecode.html
*
* I may receive an Out Of Memory exception while building WKRemote (large app?).
* I resolve this by configuring the build system to use 2G of ram (or more) like so:
*
* http://stackoverflow.com/questions/24224186/what-is-dex-in-gradle
*/
dexOptions {
// jumboMode true
preDexLibraries false
javaMaxHeapSize "2048M"
}
/**
* see those links below for help.
* 1.http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Lint-support
* 2.http://developer.android.com/tools/help/lint.html
* you can also read lint-list.md,lint-show.md in project.
*/
lintOptions {
//这个属性是为了在release下也可以调试应用
// checkReleaseBuilds false
fatal(
'MissingTranslation',
'UnknownIdInLayout',
'UniquePermission',
// 虽然打包的时候可以自动删除无引用的资源,但是有时间还是可以来捋一下无用资源的问题
// 'UnusedResources',
// 'UnknownId',
'NewApi',
'InlinedApi'
)
lintConfig file("../lint.xml")
}
defaultConfig {
manifestPlaceholders = [umkey : "5307046c56240b67db004d26"];
applicationId "com.wukongtv.wkremote.client"
minSdkVersion 10
//noinspection OldTargetApi
targetSdkVersion 23
versionCode 260
versionName "2.6.0.1"
manifestPlaceholders = [umvalue: "wktv"]
buildConfigField "boolean", "NEED_STAT", "true"
// Enabling multidex support.
multiDexEnabled true
/**
* true means hide menu button and false means show mneu button
* default value is fasle (show menu buttons)。
*/
buildConfigField "boolean", "MENU_HIDE_STATUS_FAST_CLEAN", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_CLEAN_CACHE", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_SCREENSHOT", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_CHILDLOCK", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_HANDLE", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_SCAN_DEVICE", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_POWER_OFF", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_OPEN_SETTING", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_APP_UNINSTALL", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_BAIDUYUN", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_TV_SETTING", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_EYEMODE", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_IR_POWER", "false"
buildConfigField "boolean", "LOADING_SCREEN_SWITCH", "false"
buildConfigField "int", "LOADING_SCREEN_TIME_MILLLISECONDS", "1000"
// buildConfigField "boolean", "MENU_STATUS_MORE", "false"
// buildConfigField "boolean", "MENU_HIDE_STATUS_OPEN_SETTING", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_FILE_MANAGE", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_TOU_PING", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_TOOL_BOX", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_TOOL_TIJIAN", "false"
buildConfigField "boolean", "MENU_HIDE_STATUS_MENU_SPEED_BALL", "false"
//检测盒子是否为正版应用的时候会用到。打专版的时候可能要修改这个字段
buildConfigField "String", "CHECK_APP_LEGAL_STRING", "\"com.wukongtv.wkremote.client\""
buildConfigField "boolean", "TAB_HIDE_STATUS_VIDEO", "false"
buildConfigField "boolean", "TAB_HIDE_STATUS_LIVE", "false"
buildConfigField "boolean", "TAB_HIDE_STATUS_APPSTORE", "false"
buildConfigField "boolean", "BAR_HIDE_STATUS_GLOBAL_SEARCH", "false"
buildConfigField "boolean", "BAR_HIDE_STATUS_HISTORY", "false"
buildConfigField "boolean", "HIDE_SPEED_BALL", "false"
// 是否导入协议库,debug时为true,release 为false
buildConfigField "boolean", "JAR_DEBUG", "false";
buildConfigField "boolean", "IS_NO_AD_CHANNEL", "false"
// release打Timber.log专用
buildConfigField "boolean", "RELEASE_TIMBER_LOG", "false"
}
signingConfigs {
release {
storeFile file(System.getenv("KEYSTORE_WKTV"))
storePassword System.getenv("KEYSTORE_PWD_WKTV")
keyAlias System.getenv("KEY_ALIAS_WKTV")
keyPassword System.getenv("KEYSTORE_PWD_WKTV")
}
}
def File customerProguardFile = file('src/proguard.cfg')
buildTypes {
release {
/** 在测试分享等需要release包的时候将下面两个配置改为false可以大大缩短run起来的时间。 **/
minifyEnabled true
shrinkResources true
/** 在测试分享 等需要release包的时候将上面两个配置改为false可以大大缩短run起来的时间。 **/
proguardFiles customerProguardFile, 'proguard-rules.txt'
signingConfig signingConfigs.release
}
debug {
versionNameSuffix '-DEBUG-TEST'
minifyEnabled false
debuggable true
}
userdebug.initWith(buildTypes.release)
userdebug {
versionNameSuffix '-USER-DEBUG'
}
}
productFlavors {
/** =============do not delete these pids below forever =====================**/
update2 {
manifestPlaceholders = [umkey : "5307046c56240b67db004d26"];
proguardFile 'proguard-rules.txt';
// buildConfigField "boolean", "RELEASE_TIMBER_LOG", "true"
}
noad {
manifestPlaceholders = [umkey : "5307046c56240b67db004d26"];
proguardFile 'proguard-rules.txt';
buildConfigField "boolean", "IS_NO_AD_CHANNEL", "true"
}
if (isProtocolJarEnable()) {
protocolJar{
manifestPlaceholders = [umkey : "5307046c56240b67db004d26"];
buildConfigField "boolean", "JAR_DEBUG", "true";
}
}
if (isInstantRunEnable()) {
instant {
manifestPlaceholders = [umkey : "5307046c56240b67db004d26"];
proguardFile 'proguard-rules.txt';
buildConfigField "boolean", "IS_NO_AD_CHANNEL", "true"
android.dexOptions{
/**
* There's a new flag to force "jumbo mode"
* for dex which allows a larger number of strings in the dex files;
* set dex.force.jumbo=true in project.properties
*
* Turn on Jumbo mode automatically in instant-run mode.
*/
jumboMode true
}
/**
* https://developer.android.com/studio/run/index.html
* Instant Run is supported only when you deploy the debug build variant,
* use Android plugin for Gradle version 2.0.0 or higher,
* and set minSdkVersion to 15 or higher in your app's module-level build.gradle file.
* For the best performance, set minSdkVersion to 21 or higher.
*/
minSdkVersion 21
}
}
}
}
dependencies {
/**
* 下面这句是说libs文件夹里的所有的jar文件都会被引用的声明
* 所以再导入新的jar包的时候不用再重新加入类似:
* compile files('libs/*.jar')的语句
*
* 否则可能导致部分手机无法run成功?(好像不是这个问题呢?)。
* 应该是引入了google广告库导致的无法在一些手机上run起来
*/
compile fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleDependency
compile 'com.android.support:recyclerview-v7:24.2.0'
//noinspection GradleDependency
compile 'com.android.support:support-v4:24.2.0'
//noinspection GradleDependency
compile 'com.android.support:appcompat-v7:24.2.0'
//noinspection GradleDependency
compile 'com.android.support:palette-v7:24.0.0-beta1'
compile 'io.reactivex:rxandroid:1.2.1'
compile project(':common')
//将AsyncHttp库移到wkutil中
compile project(':wkutil')
//目前的gson最新版是2.4,但遥控器只需要2.3就够了,目前项目中再淡化gson的使用。大部json分手动解析
//noinspection GradleDependency
compile 'com.google.code.gson:gson:2.3'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.makeramen:roundedimageview:1.3.0'
compile 'com.squareup:otto:1.3.5'
compile 'com.github.satyan:sugar:1.3'
compile 'com.jakewharton.timber:timber:2.5.0'
//noinspection GradleDependency
compile 'com.android.support:percent:23.1.1'
compile 'com.github.mzule.activityrouter:annotation:1.1.0'
compile 'com.wukongtv.lib:activityrouter:1.1.1@aar'
apt 'com.github.mzule.activityrouter:compiler:1.1.1'
userdebugCompile 'com.wukongtv.lib:remote-logger:0.9@aar'
releaseCompile 'com.wukongtv.lib:remote-logger-no-op:0.9@aar'
debugCompile 'com.wukongtv.lib:remote-logger-debug:0.9@aar'
compile 'com.connectsdk:connect-sdk-android-lite:1.6.0'
debugCompile project(':protocollibrary')
update2Compile project(':wkad')
//ali bai chuan feedback lib
compile(name: 'feedbackSdk', ext: 'aar')
//
compile files('libs/MiPush_SDK_Client_3_0_3.jar')
compile 'com.android.support:multidex:1.0.1'
compile files('libs/Sunflower.jar')
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
task loadfile << {
customerProguardFile = file('src/proguard.cfg')
println "Proguard File path: " + customerProguardFile.path
println "Proguard File name: " + customerProguardFile.name
}
/**
* https://docs.gradle.org/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html
*/
def isInstantRunEnable() {
return hasProperty("INSTANT_RUN_ENABLE") ? INSTANT_RUN_ENABLE : project.ext.instant
}
def isProtocolJarEnable() {
return hasProperty("PROTOCOL_JAR_ENABLE") ? PROTOCOL_JAR_ENABLE : project.ext.protocolJar
}
/**
* 在命令行中执行gradle instant命令来检验instant开关
*/
task extCheck << {
println "instant compile : " + project.ext.instant
println "protocol jar : " + project.ext.protocolJar
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment