build.gradle 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. apply plugin: 'com.android.application'
  2. // NOTE!!! 重要!!! aar需要kotlin支持,不引入会导致小程序打不开.
  3. apply plugin: 'kotlin-android'
  4. apply plugin: 'kotlin-android-extensions'
  5. if (rootProject.ext.miniAppConfig.usePluginSdk && rootProject.ext.miniAppConfig.usePluginSdk.tpush && rootProject.ext.miniAppConfig.usePluginSdk.tpush != '') {
  6. apply plugin: 'com.tencent.android.tpns'
  7. }
  8. android {
  9. useLibrary 'org.apache.http.legacy'
  10. compileSdkVersion rootProject.ext.compileSdkVersion
  11. buildToolsVersion rootProject.ext.buildToolsVersion
  12. def miniAppConfig = rootProject.ext.miniAppConfig
  13. defaultConfig {
  14. buildConfigField "String", "SDK_KEY", "\"$miniAppConfig.sdkKey\""
  15. buildConfigField "String", "SDK_KEY_SECRET", "\"$miniAppConfig.sdkKeySecret\""
  16. buildConfigField "Boolean", "SPLASHSCREEN", "$miniAppConfig.splashscreen"
  17. buildConfigField "String", "ENABLE_VCONSOLE", "\"$miniAppConfig.enableVConsole\""
  18. buildConfigField "Boolean", "PRIVACY_POPUP", "$miniAppConfig.privacyPopup"
  19. buildConfigField "Boolean", "APP_MENU_ENABLE", "$miniAppConfig.appMenuEnable"
  20. buildConfigField "String", "SCHEME", "\"$miniAppConfig.scheme\""
  21. manifestPlaceholders = [
  22. MINIAPP_SCHEME: miniAppConfig.scheme,
  23. ]
  24. }
  25. signingConfigs {
  26. debug {
  27. keyAlias "edufound_key"
  28. keyPassword "edufound321"
  29. storeFile file("C:/Users/candy/Desktop/efunbox/edufound.keystore")
  30. storePassword "edufound123"
  31. v1SigningEnabled true
  32. v2SigningEnabled true
  33. }
  34. release {
  35. keyAlias "edufound_key"
  36. keyPassword "edufound321"
  37. storeFile file("C:/Users/candy/Desktop/efunbox/edufound.keystore")
  38. storePassword "edufound123"
  39. v1SigningEnabled true
  40. v2SigningEnabled true
  41. }
  42. }
  43. defaultConfig {
  44. multiDexEnabled true
  45. versionName miniAppConfig.version
  46. versionCode miniAppConfig.versionCode
  47. minSdkVersion rootProject.ext.minSdkVersion
  48. targetSdkVersion rootProject.ext.targetSdkVersion
  49. if (rootProject.ext.miniAppConfig.map && rootProject.ext.miniAppConfig.map.qmapAPIKey) {
  50. manifestPlaceholders["qmapAPIKey"] = rootProject.ext.miniAppConfig.map.qmapAPIKey
  51. }
  52. }
  53. buildTypes {
  54. debug {
  55. debuggable true
  56. signingConfig signingConfigs.debug
  57. minifyEnabled false
  58. shrinkResources false
  59. }
  60. release {
  61. debuggable false
  62. signingConfig signingConfigs.release
  63. minifyEnabled true
  64. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  65. }
  66. }
  67. packagingOptions {
  68. exclude 'META-INF/DEPENDENCIES'
  69. exclude 'META-INF/NOTICE'
  70. exclude 'META-INF/LICENSE'
  71. exclude 'META-INF/LICENSE.txt'
  72. exclude 'META-INF/NOTICE.txt'
  73. }
  74. flavorDimensions 'abi'
  75. productFlavors {
  76. arm {
  77. dimension 'abi'
  78. ndk {
  79. abiFilters "arm64-v8a", "armeabi-v7a"
  80. }
  81. }
  82. arm32 {
  83. dimension 'abi'
  84. ndk {
  85. abiFilter "armeabi-v7a"
  86. }
  87. }
  88. arm64 {
  89. dimension 'abi'
  90. ndk {
  91. abiFilter "arm64-v8a"
  92. }
  93. }
  94. }
  95. lintOptions {
  96. checkReleaseBuilds false
  97. abortOnError false
  98. }
  99. compileOptions {
  100. sourceCompatibility = 1.8
  101. targetCompatibility = 1.8
  102. }
  103. repositories {
  104. flatDir {
  105. dirs 'libs'
  106. }
  107. }
  108. sourceSets {
  109. main {
  110. jniLibs.srcDirs = ["libs"]
  111. }
  112. }
  113. }
  114. // def wxa_sdk_version = rootProject.ext.miniAppConfig.sdkVersion
  115. def wxa_sdk_version = rootProject.ext.saaaSDKVersionDepend
  116. def libsDir = file("./libs")
  117. if (!file("$libsDir/com/tencent/luggage/wxa-standalone-open-runtime-SaaA-plugin-sdk/${wxa_sdk_version}").exists()) {
  118. libsDir.mkdir()
  119. apply plugin: 'de.undercouch.download'
  120. def zipFileName = "wxa-standalone-open-runtime-SaaA-sdk-all-${wxa_sdk_version}.zip"
  121. download.run {
  122. src "https://dldir1.qq.com/WechatWebDev/donut/android/pluginsdk/${zipFileName}"
  123. dest libsDir
  124. }
  125. def zipFilePath = "$libsDir/$zipFileName"
  126. copy {
  127. def subDir = 'localAar'
  128. from {
  129. zipTree(zipFilePath).matching { include "$subDir/**" }
  130. }
  131. into libsDir
  132. eachFile { fcp ->
  133. fcp.path = fcp.path.replaceFirst("^$subDir", '')
  134. }
  135. includeEmptyDirs false
  136. }
  137. file(zipFilePath).delete()
  138. }
  139. task updateResource {
  140. doFirst {
  141. println "[I] start connect with devtools"
  142. def url = miniAppPluginConfig.devtoolsResourceUrl
  143. def shouldInterrupt = false
  144. try {
  145. println "[I] url: $url"
  146. def response = new URL(url).getText()
  147. println("[I] response: $response")
  148. if (response.contains("success")) {
  149. // 请求成功
  150. println("[I] update Android resource done")
  151. } else {
  152. shouldInterrupt = true
  153. }
  154. } catch (Exception e) {
  155. println("[W] connecting with devtools fail.." + e.getMessage())
  156. }
  157. if (shouldInterrupt) {
  158. throw new GradleException("update Android resource fail")
  159. }
  160. }
  161. }
  162. preBuild.dependsOn updateResource
  163. dependencies {
  164. implementation project(path: ':plugin')
  165. def miniAppConfig = rootProject.ext.miniAppConfig
  166. implementation("com.tencent.luggage:wxa-standalone-open-runtime-SaaA-plugin-sdk:${wxa_sdk_version}")
  167. //以下是测试通过微信打包出来的aar能否正常使用
  168. // implementation(name: 'wxf1a06dafa3350688-1.0.47', ext: 'aar')
  169. // implementation('io.github.jeremyliao:live-event-bus-x:1.8.0')
  170. // implementation('io.github.FailedToRead:intermodal-release:1.0.1')
  171. // implementation('io.github.FailedToRead:oaid_sdk_1.0.25:1.0.1')
  172. }