build.gradle 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. apply plugin: 'com.android.library'
  2. apply plugin: 'kotlin-android'
  3. apply plugin: 'kotlin-android-extensions'
  4. android {
  5. compileSdkVersion 31
  6. buildToolsVersion "30.0.3"
  7. defaultConfig {
  8. minSdkVersion 21
  9. targetSdkVersion 31
  10. versionCode 1
  11. versionName "1.0"
  12. }
  13. buildTypes {
  14. release {
  15. minifyEnabled false
  16. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  17. }
  18. }
  19. }
  20. dependencies {
  21. implementation fileTree(dir: 'libs', include: ['*.jar'])
  22. implementation 'androidx.lifecycle:lifecycle-viewmodel:2.2.0'
  23. implementation 'androidx.appcompat:appcompat:1.2.0'
  24. //kotlin
  25. implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  26. //http框架
  27. implementation 'com.squareup.retrofit2:retrofit:2.4.0'
  28. implementation 'com.squareup.retrofit2:converter-gson:2.2.0'
  29. implementation 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
  30. implementation 'com.squareup.okhttp3:okhttp:3.11.0'
  31. implementation 'io.reactivex:rxjava:1.1.6'
  32. implementation 'io.reactivex:rxandroid:1.2.1'
  33. implementation('com.github.bumptech.glide:glide:3.7.0')
  34. }
  35. //添加以下方法
  36. //在 build/libs 目录下生成 makeKotlinJar.jar 文件
  37. // 这种方式生成的jar文件如果被kotlin app项目引用,则会出现kotlin库重复的错误,所以生成的jar
  38. //task makeJar(type: Jar) {
  39. // delete('build/libs/o2_auth_sdk.jar')
  40. // archiveName 'o2_auth_sdk.jar'
  41. // //添加项目中java生成的class文件目录
  42. // from('build/intermediates/classes/release/')
  43. // //添加项目中kotlin生成的class文件目录
  44. // from('build/tmp/kotlin-classes/release')
  45. //// 添加Kotlin库(方法1)
  46. // from {
  47. // String[] include = [
  48. // "kotlin-stdlib-${kotlin_version}.jar"
  49. // ]
  50. // configurations.compile
  51. // .findAll { include.contains(it.name) }
  52. // .collect { it.isDirectory() ? it : zipTree(it) }
  53. // }
  54. //
  55. // destinationDir = file('build/libs')
  56. //
  57. // exclude('android/**')
  58. //
  59. // include('**/**')
  60. //
  61. //}
  62. //
  63. //makeJar.dependsOn(build)
  64. // 将打包好的aar包拷贝到app下
  65. task copy2App(type: Copy) {
  66. from 'build/outputs/aar/o2_auth_sdk-release.aar'
  67. into '../app/libs'
  68. }
  69. copy2App.dependsOn(assemble)