build.gradle 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 GradleException("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. def keystoreProperties = new Properties()
  21. def keystorePropertiesFile = rootProject.file('key.properties')
  22. if (keystorePropertiesFile.exists()) {
  23. keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
  24. }
  25. apply plugin: 'com.android.application'
  26. apply plugin: 'kotlin-android'
  27. apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
  28. android {
  29. namespace "com.beswell.trackoffical_app"
  30. compileSdkVersion 33
  31. // compileSdkVersion flutter.compileSdkVersion
  32. // ndkVersion flutter.ndkVersion
  33. ndkVersion "25.1.8937393"
  34. compileOptions {
  35. sourceCompatibility JavaVersion.VERSION_1_8
  36. targetCompatibility JavaVersion.VERSION_1_8
  37. }
  38. kotlinOptions {
  39. jvmTarget = '1.8'
  40. }
  41. sourceSets {
  42. main.java.srcDirs += 'src/main/kotlin'
  43. }
  44. defaultConfig {
  45. // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
  46. applicationId "com.beswell.trackoffical_app"
  47. // You can update the following values to match your application needs.
  48. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
  49. // minSdkVersion flutter.minSdkVersion
  50. // targetSdkVersion flutter.targetSdkVersion
  51. minSdkVersion 23
  52. targetSdkVersion 33
  53. versionCode flutterVersionCode.toInteger()
  54. versionName flutterVersionName
  55. }
  56. signingConfigs {
  57. release {
  58. keyAlias keystoreProperties['keyAlias']
  59. keyPassword keystoreProperties['keyPassword']
  60. storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
  61. storePassword keystoreProperties['storePassword']
  62. }
  63. }
  64. buildTypes {
  65. release {
  66. // TODO: Add your own signing config for the release build.
  67. // Signing with the debug keys for now, so `flutter run --release` works.
  68. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  69. signingConfig signingConfigs.debug
  70. }
  71. }
  72. flavorDimensions "default"
  73. productFlavors {
  74. dev {
  75. dimension "default"
  76. resValue "string", "app_name", "dev flavor example"
  77. applicationIdSuffix ".dev"
  78. }
  79. prod {
  80. dimension "default"
  81. resValue "string", "app_name", "dev flavor example"
  82. }
  83. }
  84. }
  85. flutter {
  86. source '../..'
  87. }
  88. dependencies {
  89. implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  90. implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
  91. implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
  92. implementation "com.squareup.okhttp3:okhttp:4.10.0"
  93. }
  94. [
  95. DevDebug: null,
  96. DevRelease: '--release',
  97. Profile: '--release',
  98. ProdRelease: '--release',
  99. ].each {
  100. def taskPostfix = it.key
  101. def profileMode = it.value
  102. tasks.whenTaskAdded { task ->
  103. if (task.name == "javaPreCompile$taskPostfix") {
  104. task.dependsOn "cargoBuild$taskPostfix"
  105. }
  106. }
  107. tasks.register("cargoBuild$taskPostfix", Exec) {
  108. workingDir "../../third_party/appcore"
  109. // environment ANDROID_NDK_HOME: "$ANDROID_NDK"
  110. commandLine 'cargo', 'ndk',
  111. // the 2 ABIs below are used by real Android devices
  112. '-t', 'armeabi-v7a',
  113. '-t', 'arm64-v8a',
  114. // the below 2 ABIs are usually used for Android simulators,
  115. // add or remove these ABIs as needed.
  116. '-t', 'x86_64',
  117. '-o', '../../android/app/src/main/jniLibs', 'build'
  118. if (profileMode != null) {
  119. args profileMode
  120. }
  121. }
  122. }