3
0

build.gradle 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. apply plugin: 'com.android.application'
  2. apply plugin: 'android-aspectjx'
  3. apply from: '../common.gradle'
  4. // Android 代码规范文档:https://github.com/getActivity/AndroidCodeStandard
  5. android {
  6. // 资源目录存放指引:https://developer.android.google.cn/guide/topics/resources/providing-resources
  7. defaultConfig {
  8. // 无痛修改包名:https://www.jianshu.com/p/17327e191d2e
  9. applicationId 'com.clwl.app'
  10. // 仅保留中文语种的资源
  11. resConfigs 'zh'
  12. // 仅保留 xxhdpi 图片资源(目前主流分辨率 1920 * 1080)
  13. resConfigs 'xxhdpi'
  14. // 混淆配置
  15. proguardFiles 'proguard-sdk.pro', 'proguard-app.pro'
  16. // 日志打印开关
  17. buildConfigField('boolean', 'LOG_ENABLE', '' + LOG_ENABLE + '')
  18. // 测试包下的 BuglyId
  19. buildConfigField('String', 'BUGLY_ID', '"' + BUGLY_ID + '"')
  20. // 测试服务器的主机地址
  21. buildConfigField('String', 'HOST_URL', '"' + HOST_URL + '"')
  22. }
  23. // Apk 签名的那些事:https://www.jianshu.com/p/a1f8e5896aa2
  24. signingConfigs {
  25. config {
  26. storeFile file(StoreFile)
  27. storePassword StorePassword
  28. keyAlias KeyAlias
  29. keyPassword KeyPassword
  30. }
  31. }
  32. // 构建配置:https://developer.android.google.cn/studio/build/build-variants
  33. buildTypes {
  34. debug {
  35. // 给包名添加后缀
  36. applicationIdSuffix '.debug'
  37. // 调试模式开关
  38. debuggable true
  39. jniDebuggable true
  40. // 压缩对齐开关
  41. zipAlignEnabled false
  42. // 移除无用的资源
  43. shrinkResources false
  44. // 代码混淆开关
  45. minifyEnabled false
  46. // 签名信息配置
  47. signingConfig signingConfigs.config
  48. // 添加清单占位符
  49. addManifestPlaceholders([
  50. 'app_name': '常来微聊 Debug 版'
  51. ])
  52. // 调试模式下只保留一种架构的 so 库,提升打包速度
  53. ndk {
  54. abiFilters 'armeabi-v7a', 'x86'
  55. }
  56. }
  57. preview.initWith(debug)
  58. preview {
  59. applicationIdSuffix ''
  60. // 添加清单占位符
  61. addManifestPlaceholders([
  62. 'app_name': '常来微聊 Preview 版'
  63. ])
  64. }
  65. release {
  66. // 调试模式开关
  67. debuggable false
  68. jniDebuggable false
  69. // 压缩对齐开关
  70. zipAlignEnabled true
  71. // 移除无用的资源
  72. shrinkResources true
  73. // 代码混淆开关
  74. minifyEnabled true
  75. // 签名信息配置
  76. signingConfig signingConfigs.config
  77. // 添加清单占位符
  78. addManifestPlaceholders([
  79. 'app_name': '常来微聊'
  80. ])
  81. // 仅保留两种架构的 so 库,根据 Bugly 统计得出
  82. ndk {
  83. // armeabi:万金油架构平台(占用率:0%)
  84. // armeabi-v7a:曾经主流的架构平台(占用率:10%)
  85. // arm64-v8a:目前主流架构平台(占用率:95%)
  86. abiFilters 'armeabi-v7a', 'arm64-v8a'
  87. }
  88. }
  89. }
  90. packagingOptions {
  91. // 剔除这个包下的所有文件(不会移除签名信息)
  92. exclude 'META-INF/*******'
  93. }
  94. // AOP 配置(exclude 和 include 二选一)
  95. // 需要进行配置,否则就会引发冲突,具体表现为:
  96. // 第一种:编译不过去,报错:java.util.zip.ZipException:Cause: zip file is empty
  97. // 第二种:编译能过去,但运行时报错:ClassNotFoundException: Didn't find class on path: DexPathList
  98. aspectjx {
  99. // 排除一些第三方库的包名(Gson、 LeakCanary 和 AOP 有冲突)
  100. // exclude 'androidx', 'com.google', 'com.squareup', 'org.apache', 'com.alipay', 'com.taobao', 'versions.9'
  101. // 只对以下包名做 AOP 处理
  102. include android.defaultConfig.applicationId
  103. }
  104. applicationVariants.all { variant ->
  105. // apk 输出文件名配置
  106. variant.outputs.all { output ->
  107. outputFileName = rootProject.getName() + '_v' + variant.versionName + '_' + variant.buildType.name
  108. if (variant.buildType.name == buildTypes.release.getName()) {
  109. outputFileName += '_' + new Date().format('MMdd')
  110. }
  111. outputFileName += '.apk'
  112. }
  113. }
  114. sourceSets {
  115. main {
  116. jniLibs.srcDirs = ['libs']
  117. }
  118. }
  119. lintOptions {
  120. abortOnError false
  121. }
  122. //More than one file was found with OS independent path 'lib/x86/libc++_shared.so'. If you are using j
  123. packagingOptions {
  124. pickFirst 'lib/x86/libc++_shared.so'
  125. pickFirst 'lib/arm64-v8a/libc++_shared.so'
  126. pickFirst 'lib/armeabi-v7a/libc++_shared.so'
  127. pickFirst 'lib/x86_64/libc++_shared.so'
  128. }
  129. }
  130. // 添加构建依赖项:https://developer.android.google.cn/studio/build/dependencies
  131. // api 与 implementation 的区别:https://www.jianshu.com/p/8962d6ba936e
  132. dependencies {
  133. // 基类封装
  134. implementation project(':library:base')
  135. // 控件封装
  136. implementation project(':library:widget')
  137. // 友盟封装
  138. //implementation project(':library:umeng')
  139. // 录音
  140. implementation project(':library:mp3')
  141. // 权限请求框架:https://github.com/getActivity/XXPermissions
  142. implementation 'com.github.getActivity:XXPermissions:12.3'
  143. // 标题栏框架:https://github.com/getActivity/TitleBar
  144. implementation 'com.github.getActivity:TitleBar:9.2'
  145. // 吐司框架:https://github.com/getActivity/ToastUtils
  146. implementation 'com.github.getActivity:ToastUtils:9.5'
  147. // 网络请求框架:https://github.com/getActivity/EasyHttp
  148. implementation 'com.github.getActivity:EasyHttp:10.2'
  149. // OkHttp 框架:https://github.com/square/okhttp
  150. // noinspection GradleDependency
  151. implementation 'com.squareup.okhttp3:okhttp:3.12.13'
  152. // Json 解析框架:https://github.com/google/gson
  153. implementation 'com.google.code.gson:gson:2.8.8'
  154. // Gson 解析容错:https://github.com/getActivity/GsonFactory
  155. implementation 'com.github.getActivity:GsonFactory:5.2'
  156. // Shape 框架:https://github.com/getActivity/ShapeView
  157. implementation 'com.github.getActivity:ShapeView:6.0'
  158. // AOP 插件库:https://mvnrepository.com/artifact/org.aspectj/aspectjrt
  159. implementation 'org.aspectj:aspectjrt:1.9.6'
  160. // 图片加载框架:https://github.com/bumptech/glide
  161. // 官方使用文档:https://github.com/Muyangmin/glide-docs-cn
  162. implementation 'com.github.bumptech.glide:glide:4.12.0'
  163. annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
  164. // 沉浸式框架:https://github.com/gyf-dev/ImmersionBar
  165. implementation 'com.gyf.immersionbar:immersionbar:3.0.0'
  166. // 手势 ImageView:https://github.com/Baseflow/PhotoView
  167. implementation 'com.github.Baseflow:PhotoView:2.3.0'
  168. // Bugly 异常捕捉:https://bugly.qq.com/docs/user-guide/instruction-manual-android/?v=20190418140644
  169. implementation 'com.tencent.bugly:crashreport:3.4.4'
  170. implementation 'com.tencent.bugly:nativecrashreport:3.9.2'
  171. // 动画解析库:https://github.com/airbnb/lottie-android
  172. // 动画资源:https://lottiefiles.com、https://icons8.com/animated-icons
  173. implementation 'com.airbnb.android:lottie:4.1.0'
  174. // 上拉刷新下拉加载框架:https://github.com/scwang90/SmartRefreshLayout
  175. implementation 'com.scwang.smart:refresh-layout-kernel:2.0.3'
  176. implementation 'com.scwang.smart:refresh-header-material:2.0.3'
  177. implementation 'com.scwang.smart:refresh-footer-classics:2.0.3' //经典加载
  178. // 日志打印框架:https://github.com/JakeWharton/timber
  179. implementation 'com.jakewharton.timber:timber:4.7.1'
  180. // 指示器框架:https://github.com/ongakuer/CircleIndicator
  181. implementation 'me.relex:circleindicator:2.1.6'
  182. // 腾讯 MMKV:https://github.com/Tencent/MMKV
  183. implementation 'com.tencent:mmkv-static:1.2.10'
  184. // 内存泄漏监测框架:https://github.com/square/leakcanary
  185. debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
  186. previewImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
  187. //BaseRecyclerViewAdapterHelper: https://github.com/CymChad/BaseRecyclerViewAdapterHelper
  188. implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4'
  189. //implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50'
  190. // lombok: 插件
  191. implementation 'org.projectlombok:lombok:1.18.16'
  192. annotationProcessor 'org.projectlombok:lombok:1.18.16'
  193. //验证码输入框
  194. implementation 'com.github.Wynsbin:VerificationCodeInputView:1.0.2'
  195. //图片选择器
  196. implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0'
  197. // 轮播图:https://github.com/youth5201314/banner
  198. implementation 'io.github.youth5201314:banner:2.2.2'
  199. //live_bus https://github.com/JeremyLiao/LiveEventBus
  200. implementation 'io.github.jeremyliao:live-event-bus-x:1.8.0'
  201. //富文本编辑库 https://github.com/wasabeef/richeditor-android
  202. implementation 'jp.wasabeef:richeditor-android:2.0.0'
  203. // 多语种:https://github.com/getActivity/MultiLanguages
  204. // 悬浮窗:https://github.com/getActivity/XToast
  205. // 日志输出:https://github.com/getActivity/Logcat
  206. // 工具类:https://github.com/Blankj/AndroidUtilCode
  207. // 轮播图:https://github.com/bingoogolapple/BGABanner-Android
  208. // 二维码:https://github.com/bingoogolapple/BGAQRCode-Android
  209. // 跑马灯:https://github.com/sunfusheng/MarqueeView
  210. // 对象注解:https://www.jianshu.com/p/f1f888e4a35f
  211. // 对象存储:https://github.com/leavesC/DoKV
  212. // 多渠道打包:https://github.com/Meituan-Dianping/walle
  213. // 设备唯一标识:http://msa-alliance.cn/col.jsp?id=120
  214. // 嵌套滚动容器:https://github.com/donkingliang/ConsecutiveScroller
  215. // 隐私调用监控:https://github.com/huage2580/PermissionMonitor
  216. }