build.gradle 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. apply plugin: 'com.android.application'
  2. apply plugin: 'kotlin-android'
  3. apply plugin: 'kotlin-kapt'
  4. apply plugin: 'kotlin-android-extensions'
  5. android {
  6. compileSdkVersion rootProject.ext.android["compileSdkVersion"]
  7. buildToolsVersion rootProject.ext.android["buildToolsVersion"]
  8. useLibrary 'org.apache.http.legacy'
  9. compileOptions {
  10. targetCompatibility JavaVersion.VERSION_1_8
  11. sourceCompatibility JavaVersion.VERSION_1_8
  12. }
  13. defaultConfig {
  14. multiDexEnabled true
  15. applicationId "me.hegj.wandroid"
  16. minSdkVersion rootProject.ext.android["minSdkVersion"]
  17. targetSdkVersion rootProject.ext.android["targetSdkVersion"]
  18. versionCode rootProject.ext.android["versionCode"]
  19. versionName rootProject.ext.android["versionName"]
  20. testInstrumentationRunner rootProject.ext.dependencies["androidJUnitRunner"]
  21. ndk {
  22. // 设置支持的SO库架构 一般只设置这个就阔以设配所有的设备了,还可以极大的减少apk的大小
  23. abiFilters 'armeabi-v7a'
  24. }
  25. }
  26. signingConfigs {
  27. def alias = "wandroid"
  28. def password = "password"
  29. def filePath = "wandroid.jks"
  30. debug {
  31. keyAlias alias
  32. keyPassword password
  33. storeFile file(filePath)
  34. storePassword(password)
  35. }
  36. release {
  37. keyAlias alias
  38. keyPassword password
  39. storeFile file(filePath)
  40. storePassword(password)
  41. }
  42. }
  43. buildTypes {
  44. debug {
  45. buildConfigField "boolean", "LOG_DEBUG", "true"
  46. buildConfigField "boolean", "USE_CANARY", "false"
  47. buildConfigField "String", "BUGLY_KE", '"xxxxxx"'
  48. minifyEnabled false
  49. shrinkResources false
  50. zipAlignEnabled false
  51. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  52. }
  53. release {
  54. buildConfigField "boolean", "LOG_DEBUG", "false"
  55. buildConfigField "boolean", "USE_CANARY", "false"
  56. buildConfigField "String", "BUGLY_KE", '"5a5f6366fc"'
  57. minifyEnabled true//开启混淆
  58. shrinkResources true
  59. zipAlignEnabled true//去除无用资源
  60. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  61. }
  62. }
  63. lintOptions {
  64. disable 'InvalidPackage'
  65. disable "ResourceType"
  66. abortOnError false
  67. }
  68. dexOptions {
  69. javaMaxHeapSize "4g"
  70. jumboMode = true
  71. preDexLibraries = false
  72. additionalParameters = [
  73. '--multi-dex',//多分包
  74. '--set-max-idx-number=60000'//每个包内方法数上限
  75. ]
  76. }
  77. }
  78. dependencies {
  79. implementation fileTree(include: ['*.jar'], dir: 'libs')
  80. //androidX基础库
  81. implementation "androidx.appcompat:appcompat:1.1.0"
  82. implementation 'com.google.android.material:material:1.1.0-beta01'
  83. implementation "androidx.constraintlayout:constraintlayout:1.1.3"
  84. implementation "androidx.preference:preference:1.1.0"
  85. implementation "androidx.cardview:cardview:1.0.0"
  86. //dagger
  87. annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
  88. kapt rootProject.ext.dependencies["dagger2-compiler"]
  89. //黄油刀
  90. implementation "com.jakewharton:butterknife:10.1.0"
  91. kapt "com.jakewharton:butterknife-compiler:10.1.0"
  92. //test
  93. testImplementation rootProject.ext.dependencies["junit"]
  94. debugImplementation rootProject.ext.dependencies["canary-debug"]
  95. releaseImplementation rootProject.ext.dependencies["canary-release"]
  96. testImplementation rootProject.ext.dependencies["canary-release"]
  97. //kotlin
  98. implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  99. implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1"
  100. //项目用到的库大部分封装在里面 具体在 config.gradle
  101. implementation rootProject.ext.customLibs
  102. }
  103. repositories {
  104. mavenCentral()
  105. }