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 8.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. apply plugin : 'com.android.application'
  2. apply plugin : 'android-aspectjx'
  3. apply from : '../config.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.hjq.demo'
  10. // 仅保留中文语种的资源
  11. resConfigs 'zh'
  12. // 仅保留 xxhdpi 图片资源(目前主流分辨率 1920 * 1080)
  13. resConfig 'xxhdpi'
  14. // 混淆配置
  15. proguardFiles 'proguard-sdk.pro', 'proguard-app.pro'
  16. }
  17. // Apk 签名的那些事:https://www.jianshu.com/p/a1f8e5896aa2
  18. signingConfigs {
  19. config {
  20. storeFile file(StoreFile)
  21. storePassword StorePassword
  22. keyAlias KeyAlias
  23. keyPassword KeyPassword
  24. }
  25. }
  26. buildTypes {
  27. debug {
  28. // 给包名添加后缀
  29. applicationIdSuffix '.debug'
  30. // 调试模式开关
  31. debuggable true
  32. jniDebuggable true
  33. // 压缩对齐开关
  34. zipAlignEnabled false
  35. // 移除无用的资源
  36. shrinkResources false
  37. // 代码混淆开关
  38. minifyEnabled false
  39. // 签名信息配置
  40. signingConfig signingConfigs.config
  41. // 日志打印开关
  42. buildConfigField('boolean', 'LOG_ENABLE', 'true')
  43. // 测试包下的 BuglyId
  44. buildConfigField('String', 'BUGLY_ID', '"请自行替换 Bugly 上面的 AppID"')
  45. // 测试服务器的主机地址
  46. buildConfigField('String', 'HOST_URL', '"https://www.test.baidu.com/"')
  47. // 设置清单占位符
  48. manifestPlaceholders = ['app_name' : '安卓技术中台 Debug 版']
  49. // 调试模式下只保留一种架构的 so 库,提升打包速度
  50. ndk {
  51. abiFilters 'armeabi-v7a'
  52. }
  53. }
  54. preview.initWith(debug)
  55. preview {
  56. applicationIdSuffix ''
  57. // 设置清单占位符
  58. manifestPlaceholders = ['app_name' : '安卓技术中台 Preview 版']
  59. }
  60. release {
  61. // 调试模式开关
  62. debuggable false
  63. jniDebuggable false
  64. // 压缩对齐开关
  65. zipAlignEnabled true
  66. // 移除无用的资源
  67. shrinkResources true
  68. // 代码混淆开关
  69. minifyEnabled true
  70. // 签名信息配置
  71. signingConfig signingConfigs.config
  72. // 日志打印开关
  73. buildConfigField('boolean', 'LOG_ENABLE', 'false')
  74. // 正式包下的 BuglyId
  75. buildConfigField('String', 'BUGLY_ID', '"请自行替换 Bugly 上面的 AppID"')
  76. // 正式服务器的主机地址
  77. buildConfigField('String', 'HOST_URL', '"https://www.baidu.com/"')
  78. // 设置清单占位符
  79. manifestPlaceholders = ['app_name' : '@string/app_name']
  80. // 仅保留两种架构的 so 库,根据 Bugly 统计得出
  81. ndk {
  82. // armeabi:万金油架构平台(占用率:0%)
  83. // armeabi-v7a:曾经主流的架构平台(占用率:10%)
  84. // arm64-v8a:目前主流架构平台(占用率:95%)
  85. abiFilters 'armeabi-v7a', 'arm64-v8a'
  86. }
  87. }
  88. }
  89. packagingOptions {
  90. // 剔除这个包下的所有文件(不会移除签名信息)
  91. exclude 'META-INF/*******'
  92. }
  93. // AOP 配置(exclude 和 include 二选一)
  94. aspectjx {
  95. // 排除一些第三方库的包名(Gson、 LeakCanary 和 AOP 有冲突)
  96. // exclude 'androidx', 'com.google', 'com.squareup', 'org.apache', 'com.alipay', 'com.taobao', 'versions.9'
  97. // 只对以下包名做 AOP 处理
  98. include 'com.hjq.demo'
  99. // 否则就会引发冲突,具体表现为:
  100. // 编译不过去,报错:java.util.zip.ZipException:Cause: zip file is empty
  101. // 编译能过去,但运行时报错:ClassNotFoundException: Didn't find class on path: DexPathList
  102. }
  103. applicationVariants.all { variant ->
  104. // Apk 输出文件名配置
  105. variant.outputs.all { output ->
  106. outputFileName = rootProject.getName() + '_v' + variant.versionName + '_' + variant.buildType.name
  107. if (variant.buildType.name == buildTypes.release.getName()) {
  108. outputFileName += '_' + new Date().format('MMdd')
  109. }
  110. outputFileName += '.apk'
  111. }
  112. }
  113. }
  114. // api 与 implementation 的区别:https://www.jianshu.com/p/8962d6ba936e
  115. dependencies {
  116. // 基类封装
  117. implementation project(':base')
  118. // 控件封装
  119. implementation project(':widget')
  120. // 友盟封装
  121. implementation project(':umeng')
  122. // 权限请求框架:https://github.com/getActivity/XXPermissions
  123. implementation 'com.hjq:xxpermissions:9.8'
  124. // 标题栏框架:https://github.com/getActivity/TitleBar
  125. implementation 'com.hjq:titlebar:8.2'
  126. // 吐司框架:https://github.com/getActivity/ToastUtils
  127. implementation 'com.hjq:toast:8.8'
  128. // 网络请求框架:https://github.com/getActivity/EasyHttp
  129. implementation 'com.hjq:http:9.0'
  130. // OkHttp 框架:https://github.com/square/okhttp
  131. // noinspection GradleDependency
  132. implementation 'com.squareup.okhttp3:okhttp:3.12.12'
  133. // Json 解析框架:https://github.com/google/gson
  134. implementation 'com.google.code.gson:gson:2.8.6'
  135. // Gson 解析容错:https://github.com/getActivity/GsonFactory
  136. implementation 'com.hjq.gson:factory:3.0'
  137. // AOP 插件库:https://mvnrepository.com/artifact/org.aspectj/aspectjrt
  138. implementation 'org.aspectj:aspectjrt:1.9.6'
  139. // 图片加载框架:https://github.com/bumptech/glide
  140. // 官方使用文档:https://muyangmin.github.io/glide-docs-cn/
  141. implementation 'com.github.bumptech.glide:glide:4.12.0'
  142. annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
  143. // 沉浸式框架:https://github.com/gyf-dev/ImmersionBar
  144. implementation 'com.gyf.immersionbar:immersionbar:3.0.0'
  145. // 手势 ImageView:https://github.com/chrisbanes/PhotoView
  146. implementation 'com.github.chrisbanes:PhotoView:2.3.0'
  147. // Bugly 异常捕捉:https://bugly.qq.com/docs/user-guide/instruction-manual-android/?v=20190418140644
  148. implementation 'com.tencent.bugly:crashreport:3.3.3'
  149. implementation 'com.tencent.bugly:nativecrashreport:3.7.700'
  150. // 动画解析库:https://github.com/airbnb/lottie-android
  151. // 动画资源:https://lottiefiles.com、https://icons8.com/animated-icons
  152. implementation 'com.airbnb.android:lottie:3.6.1'
  153. // 刷新框架:https://github.com/scwang90/SmartRefreshLayout
  154. implementation 'com.scwang.smart:refresh-layout-kernel:2.0.3'
  155. implementation 'com.scwang.smart:refresh-header-material:2.0.3'
  156. // 日志打印框架:https://github.com/JakeWharton/timber
  157. implementation 'com.jakewharton.timber:timber:4.7.1'
  158. // 指示器框架:https://github.com/ongakuer/CircleIndicator
  159. implementation 'me.relex:circleindicator:2.1.4'
  160. // 内存泄漏监测框架:https://github.com/square/leakcanary
  161. // noinspection GradleDependency
  162. debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.5'
  163. // noinspection GradleDependency
  164. previewImplementation 'com.squareup.leakcanary:leakcanary-android:2.5'
  165. // 国际化:https://github.com/getActivity/MultiLanguages
  166. // 悬浮窗:https://github.com/getActivity/XToast
  167. // 日志输出:https://github.com/getActivity/Logcat
  168. // 工具类:https://github.com/Blankj/AndroidUtilCode
  169. // 轮播图:https://github.com/bingoogolapple/BGABanner-Android
  170. // 二维码:https://github.com/bingoogolapple/BGAQRCode-Android
  171. // 跑马灯:https://github.com/sunfusheng/MarqueeView
  172. // 对象注解:https://www.jianshu.com/p/f1f888e4a35f
  173. // 平板适配:https://github.com/JessYanCoding/AndroidAutoSize
  174. // 图片压缩:https://github.com/Curzibn/Luban
  175. // 对象存储:https://github.com/leavesC/DoKV
  176. // 第三方支付:https://github.com/Cuieney/RxPay
  177. // 多渠道打包:https://github.com/Meituan-Dianping/walle
  178. // 设备唯一标识:http://msa-alliance.cn/col.jsp?id=120
  179. }