当前位置:   article > 正文

Flutter 2.10.5 自定义打包名称

Flutter 2.10.5 自定义打包名称
修改 android/app/build.gradle 文件,如下所示
  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. apply plugin: 'com.android.application'
  21. apply plugin: 'kotlin-android'
  22. apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
  23. android {
  24. compileSdkVersion flutter.compileSdkVersion
  25. compileOptions {
  26. sourceCompatibility JavaVersion.VERSION_1_8
  27. targetCompatibility JavaVersion.VERSION_1_8
  28. }
  29. defaultConfig {
  30. // print(${flutterVersionName});
  31. // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
  32. applicationId "YourPackageName"
  33. minSdkVersion flutter.minSdkVersion
  34. targetSdkVersion flutter.targetSdkVersion
  35. versionCode flutterVersionCode.toInteger()
  36. versionName flutterVersionName
  37. }
  38. applicationVariants.all { variant ->
  39. variant.outputs.all {
  40. def appName = 'YourCustomAppName' // 替换为实际自定义应用名
  41. def buildType = variant.buildType.name
  42. def versionName = variant.versionName
  43. // 输入结果如:YourCustomAppName-1.0.0-release.apk
  44. outputFileName = "${appName}-${versionName}-${buildType}.apk"
  45. println(" L Terminal Run : cd "+ rootProject.buildDir + "/app/outputs/apk/${buildType}/" + " file: ${outputFileName}")
  46. }
  47. }
  48. }
  49. flutter {
  50. source '../..'
  51. }

将applicationId 修改成你的包名,将appName 修改成你的应用名。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/778234
推荐阅读
相关标签
  

闽ICP备14008679号