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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. apply plugin: 'com.android.application'
  2. apply plugin: 'android-aspectjx'
  3. apply from: '../config.gradle'
  4. apply from: 'proguard.gradle'
  5. android {
  6. defaultConfig {
  7. // 无痛修改包名(推荐使用第二种方案):https://www.jianshu.com/p/17327e191d2e
  8. applicationId 'com.hjq.demo'
  9. // 仅保留中文语种的资源
  10. resConfigs 'zh'
  11. // 仅保留 xxhdpi 图片资源(目前主流分辨率 1920 * 1080)
  12. resConfig 'xxhdpi'
  13. // 仅保留两种架构的 so 库,根据 Bugly 统计得出
  14. ndk {
  15. // armeabi:万金油架构平台(占用率:0%)
  16. // armeabi-v7a:曾经主流的架构平台(占用率:10%)
  17. // arm64-v8a:目前主流架构平台(占用率:90%)
  18. abiFilters 'armeabi-v7a', 'arm64-v8a'
  19. }
  20. // 混淆配置
  21. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-app.pro'
  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. buildTypes {
  33. debug {
  34. debuggable true
  35. jniDebuggable true
  36. // 移除无用的资源文件
  37. shrinkResources false
  38. // ZipAlign 优化
  39. zipAlignEnabled false
  40. // 设置混淆
  41. minifyEnabled false
  42. // 开发环境下的 BuglyId
  43. buildConfigField 'String', 'BUGLY_ID', '\"请自行替换 Bugly 上面的 AppID\"'
  44. signingConfig signingConfigs.config
  45. }
  46. release {
  47. debuggable false
  48. jniDebuggable false
  49. // 移除无用的资源文件
  50. shrinkResources true
  51. // ZipAlign 优化
  52. zipAlignEnabled true
  53. // 设置混淆
  54. minifyEnabled true
  55. // 正式环境下的 BuglyId
  56. buildConfigField 'String', 'BUGLY_ID', '\"请自行替换 Bugly 上面的 AppID\"'
  57. signingConfig signingConfigs.config
  58. }
  59. }
  60. // AOP 配置
  61. aspectjx {
  62. // 排除一些第三方库的包名(Gson、 LeakCanary 和 AOP 有冲突)
  63. // 否则就会起冲突:ClassNotFoundException: Didn't find class on path: DexPathList
  64. exclude 'androidx', 'com.google', 'com.squareup', 'com.alipay', 'com.taobao', 'org.apache'
  65. }
  66. applicationVariants.all { variant ->
  67. // Apk 输出文件名配置
  68. variant.outputs.all { output ->
  69. outputFileName = rootProject.getName() + '_v' + variant.versionName + '_' + variant.buildType.name
  70. if (variant.buildType.name == buildTypes.release.getName()) {
  71. outputFileName += '_' + new Date().format('MMdd')
  72. }
  73. outputFileName += '.apk'
  74. }
  75. }
  76. }
  77. // api 与 implementation 的区别:https://www.jianshu.com/p/8962d6ba936e
  78. dependencies {
  79. // 基类库
  80. implementation project(':base')
  81. // 自定义 View
  82. implementation project(':widget')
  83. // 友盟封装
  84. implementation project(':umeng')
  85. // 网络请求框架:https://github.com/getActivity/EasyHttp
  86. implementation 'com.hjq:http:6.9'
  87. // 权限请求框架:https://github.com/getActivity/XXPermissions
  88. implementation 'com.hjq:xxpermissions:6.5'
  89. // 标题栏框架:https://github.com/getActivity/TitleBar
  90. implementation 'com.hjq:titlebar:6.5'
  91. // 吐司框架:https://github.com/getActivity/ToastUtils
  92. implementation 'com.hjq:toast:8.6'
  93. // OkHttp 框架:https://github.com/square/okhttp
  94. implementation 'com.squareup.okhttp3:okhttp:4.2.2'
  95. // JSON 解析框架:https://github.com/google/gson
  96. implementation 'com.google.code.gson:gson:2.8.6'
  97. // AOP 插件库:https://mvnrepository.com/artifact/org.aspectj/aspectjrt
  98. implementation 'org.aspectj:aspectjrt:1.9.5'
  99. // 图片加载框架:https://github.com/bumptech/glide
  100. implementation 'com.github.bumptech.glide:glide:4.11.0'
  101. annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
  102. // 状态栏沉浸:https://github.com/gyf-dev/ImmersionBar
  103. implementation 'com.gyf.immersionbar:immersionbar:3.0.0'
  104. // 手势 ImageView:https://github.com/chrisbanes/PhotoView
  105. implementation 'com.github.chrisbanes:PhotoView:2.3.0'
  106. // ViewPager 指示器:https://github.com/romandanylyk/PageIndicatorView
  107. implementation 'com.romandanylyk:pageindicatorview:1.0.3'
  108. // Bugly 异常捕捉:https://bugly.qq.com/docs/user-guide/instruction-manual-android/?v=20190418140644
  109. implementation 'com.tencent.bugly:crashreport:3.1.9'
  110. implementation 'com.tencent.bugly:nativecrashreport:3.7.1'
  111. // 动画解析库:https://github.com/airbnb/lottie-android
  112. // 动画资源:https://lottiefiles.com、https://icons8.com/animated-icons
  113. implementation 'com.airbnb.android:lottie:3.4.1'
  114. // 上拉刷新下拉加载:https://github.com/scwang90/SmartRefreshLayout
  115. implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.2'
  116. // SmartRefreshLayout 刷新样式集合库
  117. implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.2'
  118. // 侧滑框架:https://github.com/luckybilly/SmartSwipe
  119. implementation 'com.billy.android:smart-swipe:1.1.2'
  120. implementation 'com.billy.android:smart-swipe-x:1.1.0'
  121. // 日志调试:https://github.com/getActivity/Logcat
  122. debugImplementation 'com.hjq:logcat:8.2'
  123. // 内存泄漏:https://github.com/square/leakcanary
  124. debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
  125. // 国际化:https://github.com/getActivity/MultiLanguages
  126. // 悬浮窗:https://github.com/getActivity/XToast
  127. // 工具类:https://github.com/Blankj/AndroidUtilCode
  128. // 平板适配:https://github.com/JessYanCoding/AndroidAutoSize
  129. // 轮播图:https://github.com/bingoogolapple/BGABanner-Android
  130. // 二维码:https://github.com/bingoogolapple/BGAQRCode-Android
  131. // 跑马灯:https://github.com/sunfusheng/MarqueeView
  132. // 第三方支付:https://github.com/Cuieney/RxPay
  133. // Log 打印:https://github.com/JakeWharton/timber
  134. // 图片裁剪:https://github.com/Yalantis/uCrop
  135. // 图片压缩:https://github.com/Curzibn/Luban
  136. // 对象存储:https://github.com/leavesC/DoKV
  137. // 对象注解:https://www.jianshu.com/p/f1f888e4a35f
  138. }