androidflutter

Changed code does not appear to be updated after upgrading the application to a newer version


I built a Flutter application and generated the release version by setting the version to 1.0.0+1 in pubspec.yaml and running flutter build apk --release to create the APK file.

After installing the APK on multiple phones, everything worked fine.

Later, I found some bugs, fixed the code, and updated the version in pubspec.yaml to 1.0.1+1. I then ran flutter build apk --release again to generate the new version of the APK.

If I uninstall the old version and install the new one, everything works as expected. However, if I upgrade the app without uninstalling the previous version, some of the updated functionalities do not reflect the changes and continue to behave as they did in the old version.

I am displaying the app version in a Text widget using package_info_plus, so I can confirm that the new version is installed.


Solution

  • When you work on a Flutter application, the version roughly corresponds to this:

    MAJOR.MINOR.PATCH+BUILD_NUMBER
    

    The BUILD_NUMBER must absolutely be increased each time you send an update of your application to overwrite the previous one.

    For example, you can have more version 1.0.0 but with each time an incremented build.

    In your case, if you are still in the first version then, your version must be 1.0.0+2

    Tip: If you generated your project with Android Studio, there is an explanation of this in the comments of the pubspec.yaml file.