build.gradle 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. plugins {
  2. id "com.android.application"
  3. id "kotlin-android"
  4. id "dev.flutter.flutter-gradle-plugin"
  5. }
  6. def localProperties = new Properties()
  7. def localPropertiesFile = rootProject.file('local.properties')
  8. if (localPropertiesFile.exists()) {
  9. localPropertiesFile.withReader('UTF-8') { reader ->
  10. localProperties.load(reader)
  11. }
  12. }
  13. def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
  14. if (flutterVersionCode == null) {
  15. flutterVersionCode = '1'
  16. }
  17. def flutterVersionName = localProperties.getProperty('flutter.versionName')
  18. if (flutterVersionName == null) {
  19. flutterVersionName = '1.0'
  20. }
  21. android {
  22. namespace "com.szls.lszlgl"
  23. compileSdkVersion flutter.compileSdkVersion
  24. ndkVersion flutter.ndkVersion
  25. compileOptions {
  26. sourceCompatibility JavaVersion.VERSION_1_8
  27. targetCompatibility JavaVersion.VERSION_1_8
  28. }
  29. defaultConfig {
  30. applicationId "com.szls.lszlgl"
  31. // You can update the following values to match your application needs.
  32. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
  33. minSdkVersion 21
  34. targetSdkVersion flutter.targetSdkVersion
  35. versionCode flutterVersionCode.toInteger()
  36. versionName flutterVersionName
  37. }
  38. // 签名配置
  39. signingConfigs {
  40. release {
  41. v1SigningEnabled true
  42. v2SigningEnabled true
  43. storeFile file(KEY_PATH)
  44. storePassword KEY_PWD
  45. keyAlias = ALIAS_NAME
  46. keyPassword ALIAS_PWD
  47. }
  48. }
  49. buildTypes {
  50. release {
  51. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  52. signingConfig signingConfigs.release
  53. manifestPlaceholders = [APP_NAME: "国粮质检"]
  54. }
  55. profile {
  56. signingConfig signingConfigs.release
  57. manifestPlaceholders = [APP_NAME: "国粮质检-测试"]
  58. applicationIdSuffix ".debug"
  59. }
  60. debug {
  61. signingConfig signingConfigs.release
  62. manifestPlaceholders = [APP_NAME: "国粮质检-测试"]
  63. applicationIdSuffix ".debug"
  64. }
  65. }
  66. android.applicationVariants.all {
  67. def buildType = it.buildType.name
  68. def outputFile
  69. it.outputs.each {
  70. outputFile = it.outputFile
  71. // 名称_环境_版本名称_版本号.apk
  72. // lszlgl_release_0.0.2_2.apk
  73. it.outputFileName = "lszlgl_${buildType}_${defaultConfig.versionName}_${defaultConfig.versionCode}.apk"
  74. }
  75. }
  76. dependencies {
  77. implementation fileTree(include: ['*.jar'], dir: 'libs')
  78. implementation 'com.amap.api:location:5.6.0'
  79. }
  80. }
  81. flutter {
  82. source '../..'
  83. }