You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.gradle 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. apply plugin: 'com.android.application'
  2. android {
  3. compileSdkVersion rootProject.ext.compileSdkVersion
  4. buildToolsVersion rootProject.ext.buildToolsVersion
  5. // 使用 JDK 1.8
  6. // compileOptions {
  7. // targetCompatibility JavaVersion.VERSION_1_8
  8. // sourceCompatibility JavaVersion.VERSION_1_8
  9. // }
  10. defaultConfig {
  11. // 无痛修改包名:https://www.jianshu.com/p/17327e191d2e
  12. applicationId "com.hjq.demo"
  13. minSdkVersion 14
  14. targetSdkVersion rootProject.ext.targetSdkVersion
  15. versionCode 10
  16. versionName "1.0"
  17. testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  18. // 混淆配置
  19. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-app.pro'
  20. javaCompileOptions {
  21. annotationProcessorOptions {
  22. // EventBus Apt 索引类生成位置
  23. arguments = [ eventBusIndex : applicationId + '.MyEventBusIndex' ]
  24. }
  25. }
  26. }
  27. //APK 签名的那些事:https://www.jianshu.com/p/a1f8e5896aa2
  28. // signingConfigs {
  29. // release {
  30. // keyAlias '密钥别称'
  31. // keyPassword '密钥密码'
  32. // storeFile file('E:/MySign.jks')
  33. // storePassword '密钥库密码'
  34. // }
  35. //
  36. // debug {
  37. // keyAlias '密钥别称'
  38. // keyPassword '密钥密码'
  39. // storeFile file('E:/MySign.jks')
  40. // storePassword '密钥库密码'
  41. // }
  42. // }
  43. buildTypes {
  44. release {
  45. // 不显示Log
  46. buildConfigField "boolean", "LOG_DEBUG", "false"
  47. // 移除无用的resource文件,前提minifyEnabled必须打开
  48. shrinkResources true
  49. // ZipAlign优化
  50. zipAlignEnabled true
  51. // 设置混淆
  52. minifyEnabled true
  53. // 正式环境签名
  54. //signingConfig signingConfigs.release
  55. }
  56. debug {
  57. // ZipAlign优化
  58. zipAlignEnabled false
  59. // 设置混淆
  60. minifyEnabled false
  61. // 开发环境签名
  62. //signingConfig signingConfigs.debug
  63. }
  64. }
  65. flavorDimensions "default" // 这个名字貌似随便取,也可以有多个,总之一定要有
  66. // 友盟多渠道打包
  67. productFlavors {
  68. kuan {} // 酷安
  69. tencent {} // 应用宝
  70. baidu {} // 百度
  71. xiaomi {} // 小米
  72. huawei {} // 华为
  73. google {} // 谷歌
  74. productFlavors.all { flavor ->
  75. flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
  76. }
  77. }
  78. // JNI 目录
  79. sourceSets {
  80. main {
  81. jniLibs.srcDirs = ['libs']
  82. }
  83. }
  84. // 执行配置
  85. applicationVariants.all { variant ->
  86. // Apk 输出配置
  87. variant.outputs.all { output ->
  88. def appName = "AndroidProject"
  89. if (variant.buildType.name == 'debug') {
  90. outputFileName = appName + '_v' + versionName + '_' + variant.buildType.name + '.apk'
  91. } else {
  92. outputFileName = appName + '_v' + versionName + '_' + new Date().format("yyyyMMdd") + '_' + variant.productFlavors[0].name + '_' + variant.buildType.name + '.apk'
  93. }
  94. }
  95. // AndroidManifest 输出配置
  96. variant.outputs[0].processManifest.doLast {
  97. def manifestFile = "${manifestOutputDirectory}/AndroidManifest.xml"
  98. def updatedContent = new File(manifestFile).getText('UTF-8')
  99. .replaceAll("UMENG_APPKEY_VALUE", "5cb16d93570df399fd0014e2") // 友盟 AppKey
  100. .replaceAll("QQ_APPID_VALUE", "100424468") // QQ AppId
  101. .replaceAll("QQ_APPKEY_VALUE", "c7394704798a158208a74ab60104f0ba") // QQ Key
  102. .replaceAll("WX_APPID_VALUE", "wxdc1e388c3822c80b") // 微信 AppId
  103. .replaceAll("WX_APPKEY_VALUE", "3baf1193c85774b3fd9d18447d76cab0") // 微信 Key
  104. .replaceAll("SN_APPID_VALUE", "3921700954") // 新浪 AppId
  105. .replaceAll("SN_APPKEY_VALUE", "04b48b094faeb16683c32669824ebdad") // 新浪 Key
  106. new File(manifestFile).write(updatedContent, 'UTF-8')
  107. }
  108. }
  109. }
  110. // api 与 implementation 的区别:https://www.jianshu.com/p/8962d6ba936e
  111. dependencies {
  112. // 依赖 libs 目录下所有 jar 包
  113. implementation fileTree(include: ['*.jar'], dir: 'libs')
  114. // 依赖 libs 目录下所有 aar 包
  115. implementation fileTree(include: ['*.aar'], dir: 'libs')
  116. // 基础库(不包任何第三方框架)
  117. implementation project(':base')
  118. // 自定义 View
  119. implementation project(':widget')
  120. // Dialog 封装
  121. implementation project(':dialog')
  122. // Glide 隔离
  123. implementation project(':image')
  124. // 友盟隔离
  125. implementation project(':umeng')
  126. implementation "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
  127. implementation "com.android.support:design:$rootProject.ext.supportLibraryVersion"
  128. implementation "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion"
  129. implementation "com.android.support:cardview-v7:$rootProject.ext.supportLibraryVersion"
  130. implementation "com.android.support.constraint:constraint-layout:$rootProject.ext.constraintLayoutVersion"
  131. // Dex分包,解决 64k 问题
  132. implementation 'com.android.support:multidex:1.0.3'
  133. // ButterKnife 注解库:https://github.com/JakeWharton/butterknife
  134. implementation 'com.jakewharton:butterknife:9.0.0-rc1'
  135. annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc1'
  136. // EventBus 事件总线
  137. implementation "org.greenrobot:eventbus:3.1.1"
  138. annotationProcessor 'org.greenrobot:eventbus-annotation-processor:3.1.1'
  139. // 状态栏沉浸:https://github.com/gyf-dev/ImmersionBar
  140. implementation 'com.gyf.immersionbar:immersionbar:2.3.3'
  141. // 侧滑功能:https://github.com/bingoogolapple/BGASwipeBackLayout-Android
  142. implementation 'cn.bingoogolapple:bga-swipebacklayout:1.2.0'
  143. // 权限请求框架:https://github.com/getActivity/XXPermissions
  144. implementation 'com.hjq:xxpermissions:5.5'
  145. // 标题栏:https://github.com/getActivity/TitleBar
  146. implementation 'com.hjq:titlebar:5.0'
  147. // 吐司工具类:https://github.com/getActivity/ToastUtils
  148. implementation 'com.hjq:toast:6.0'
  149. // 圆形的ImageView:https://github.com/hdodenhof/CircleImageView
  150. implementation 'de.hdodenhof:circleimageview:2.2.0'
  151. // 支持放大缩放的ImageView:https://github.com/chrisbanes/PhotoView
  152. implementation 'com.github.chrisbanes:PhotoView:2.0.0'
  153. // 布局优化:https://github.com/getActivity/Layouts
  154. // 分割线:https://github.com/getActivity/RecyclerItemDecoration
  155. // 国际化:https://github.com/getActivity/MultiLanguages
  156. // 悬浮窗:https://github.com/getActivity/XToast
  157. // 网络请求:https://github.com/zhou-you/RxEasyHttp
  158. // RxJava: https://github.com/ReactiveX/RxAndroid
  159. // RecyclerView:https://github.com/CymChad/BaseRecyclerViewAdapterHelper
  160. // 上拉刷新下拉加载:https://github.com/scwang90/SmartRefreshLayout
  161. // 工具类:https://github.com/Blankj/AndroidUtilCode
  162. // 图片选择:https://github.com/zhihu/Matisse
  163. // 轮播图:https://github.com/bingoogolapple/BGABanner-Android
  164. // 二维码:https://github.com/bingoogolapple/BGAQRCode-Android
  165. // 第三方支付:https://github.com/getActivity/RxPay
  166. // Log 打印:https://github.com/JakeWharton/timber
  167. // 重要数据存储:https://github.com/Tencent/MMKV
  168. }