Set the application version to the default 4 numbers

Asked

Viewed 138 times

1

A company has had a standardized version of projects for many years and would like to continue using this standard to keep things easy in its environment. This standard that was adopted uses the 4-digit semantics as for example 1.5.16.3.

I tried applying this pattern to an application I’m working for them and I got an error message on the Vscode console as soon as I changed the pubspec.yaml by entering the value version: 1.0.0.0+1:

[AppExemplo] flutter.bat pub get
Running "flutter pub get" in AppExemplo...
Error on line 3, column 10 of pubspec.yaml: Invalid version number: Could not parse "1.0.0.0+1".

  ╷

3 │ version: "1.0.0.0+1"

  │          ^^^^^^^^^^^

  ╵
pub get failed (65;   ╵)
exit code 65

I tried to look up the flutter issues if there was anything I could do but found nothing. I noticed that some applications installed on my phone have this pattern, which made me try to find a way to work.

Is there any way I can get 4 numbers in the name of the version and worth it without doing magic or Herculean efforts?

1 answer

2


According to the pubspec documentation:

A version number is three Numbers separated by Dots, like 0.2.43. It can also Optionally have a build ( +1, +2, +Hotfix.oopsie) or prerelease (-dev.4, -alpha.12, -beta.7, -rc.5) suffix.

That is: in this file you must use the notation of three numbers, with an optional fourth for the build number. This is required to host your package on the website pub.dev but not necessarily for the Google Play Store.

However, according to documentation about the deploy app in the store, this setting can be overridden using the parameters --build-name and --build-number spent at the time of build.

So when you build your application you can use the command:

flutter build apk --build-number=1.2.3.4

(Another suggestion that can be found on the internet is to modify the file local.properties before giving the build, but it all made you use the command flutter run your changes would be overwritten and you would have to access this file again. As this file is filled automatically by Flutter, it should not be touched.)

  • Good clarification, give me more confidence to continue the development. I really thought I would have to use the local.properties how it will change I’m always thinking of creating a .properties custom use it in graddle to control the code and version name. For Ios, which is the file equated to local.properties?

  • 1

    In iOS the equivalent is the file generated.xcconfig.

  • Doubts clarified and now I consider as the valid answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.