build.gradle 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. def localProperties = new Properties()
  2. def localPropertiesFile = rootProject.file('local.properties')
  3. if (localPropertiesFile.exists()) {
  4. localPropertiesFile.withReader('UTF-8') { reader ->
  5. localProperties.load(reader)
  6. }
  7. }
  8. def flutterRoot = localProperties.getProperty('flutter.sdk')
  9. if (flutterRoot == null) {
  10. throw new Exception("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
  11. }
  12. def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
  13. if (flutterVersionCode == null) {
  14. flutterVersionCode = '1'
  15. }
  16. def flutterVersionName = localProperties.getProperty('flutter.versionName')
  17. if (flutterVersionName == null) {
  18. flutterVersionName = '1.0'
  19. }
  20. apply plugin: 'com.android.application'
  21. apply plugin: 'kotlin-android'
  22. apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
  23. import groovy.xml.*
  24. android {
  25. compileSdkVersion 32
  26. sourceSets {
  27. main.java.srcDirs += 'src/main/kotlin'
  28. }
  29. lintOptions {
  30. disable 'InvalidPackage'
  31. }
  32. defaultConfig {
  33. applicationId "xie.hiyd.com"
  34. minSdkVersion 21
  35. targetSdkVersion 31
  36. versionCode flutterVersionCode.toInteger()
  37. versionName flutterVersionName
  38. manifestPlaceholders = [
  39. TENCENT_APP_ID: "1110701531" ,
  40. AMAP_KEY: "f606b2f01de83ce2f9984680fa0f1897",
  41. GETUI_APPID : "Rvnote7osU9Ntxk4tpEP46",
  42. GETUI_APP_ID : "Rvnote7osU9Ntxk4tpEP46",
  43. GETUI_APP_KEY : "9bHdNmOfPu5KXKAVKKXUv4",
  44. GETUI_APP_SECRET: "aMP4ifBDUJAzvL7KUe2M33",
  45. XIAOMI_APP_ID : "2882303761520111715",
  46. XIAOMI_APP_KEY : "5722011155715",
  47. MEIZU_APP_ID : "",
  48. MEIZU_APP_KEY : "",
  49. HUAWEI_APP_ID : "",
  50. OPPO_APP_KEY : "",
  51. OPPO_APP_SECRET : "",
  52. VIVO_APP_ID : "",
  53. VIVO_APP_KEY : ""
  54. ]
  55. ndk {
  56. abiFilters 'armeabi-v7a', 'arm64-v8a'
  57. }
  58. }
  59. signingConfigs {
  60. debug {
  61. storeFile file("ojia.keystore")
  62. storePassword "111111"
  63. keyAlias "ojia"
  64. keyPassword "111111"
  65. }
  66. release {
  67. storeFile file("ojia.keystore")
  68. storePassword "111111"
  69. keyAlias "ojia"
  70. keyPassword "111111"
  71. }
  72. }
  73. buildTypes {
  74. release {
  75. minifyEnabled false
  76. zipAlignEnabled true
  77. shrinkResources false
  78. // Signing with the debug keys for now, so `flutter run --release` works.
  79. signingConfig signingConfigs.release
  80. }
  81. }
  82. android.applicationVariants.all { variant ->
  83. String variantName = variant.name.capitalize()
  84. println "=====variantName=====$variantName"
  85. def processManifestTask = project.tasks.getByName("process${variantName}Manifest")
  86. println "=====task=====$processManifestTask"
  87. processManifestTask.doFirst { pm ->
  88. String manifestPath = pm.mainMergedManifest.get().asFile
  89. println "=====manifestPath=====$manifestPath"
  90. def xml = pm.mainMergedManifest.get().asFile
  91. def manifestContent = xml.getText()
  92. def manifest = new XmlParser().parseText(manifestContent)
  93. // manifest.declareNamespace('android': 'http://schemas.android.com/apk/res/android')
  94. def android = new Namespace('http://schemas.android.com/apk/res/android', 'android')
  95. manifest.application[0].each { component ->
  96. def hasIntentFilter = false
  97. component.children().each { child ->
  98. if(child.name() == "intent-filter"){
  99. hasIntentFilter = true
  100. println " =====find $component"
  101. return true
  102. }
  103. }
  104. if(hasIntentFilter){
  105. component.attributes().put(android.exported, "true")
  106. }
  107. }
  108. xml.withWriter {out->
  109. groovy.xml.XmlUtil.serialize(manifest, out)
  110. }
  111. }
  112. variant.outputs.all {
  113. outputFileName = "qudong_${variant.versionName}_${variant.versionCode}.apk"
  114. }
  115. }
  116. }
  117. flutter {
  118. source '../..'
  119. }
  120. dependencies {
  121. implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  122. implementation "androidx.appcompat:appcompat:1.3.1"
  123. implementation 'com.github.HBiSoft:HBRecorder:2.0.4'
  124. implementation "com.amap.api:location:6.0.1"
  125. }
  126. tasks.withType(JavaCompile) {
  127. options.encoding = "UTF-8"
  128. }