build.gradle 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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", "true"
  47. buildConfigField "String", "BUGLY_KEY", '"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_KEY", '"5a5f6366fc"'//bugly key
  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. //dagger
  81. annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
  82. kapt rootProject.ext.dependencies["dagger2-compiler"]
  83. //黄油刀
  84. implementation "com.jakewharton:butterknife:10.1.0"
  85. kapt "com.jakewharton:butterknife-compiler:10.1.0"
  86. //test
  87. testImplementation rootProject.ext.dependencies["junit"]
  88. debugImplementation rootProject.ext.dependencies["canary-debug"]
  89. releaseImplementation rootProject.ext.dependencies["canary-release"]
  90. testImplementation rootProject.ext.dependencies["canary-release"]
  91. //kotlin
  92. implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  93. implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1"
  94. //项目用到的库大部分封装在里面 具体在 config.gradle
  95. implementation rootProject.ext.customLibs
  96. }
  97. repositories {
  98. mavenCentral()
  99. }