beplus / fastlane-plugin-versioning_android

Android Versioning Plugin for Fastlane
MIT License
140 stars 25 forks source link

android_set_version_name does not work with Flutter #10

Open dsgriffin opened 3 years ago

dsgriffin commented 3 years ago

Using android_set_version_name without options sets versionName to an empty string. If you run it twice it then completely removes the property from gradle.

If you instead try setting a specific version (e.g. android_set_version_name(version_name: '1.0.0')) it sets an invalid raw numeric instead of a string

def flutterVersionName = 1.0.0 // Error's when building - invalid format
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}
pablopantaleon commented 3 years ago

You need to use something like this:

lane :staging do 
android_set_version_name(
    version_name: '"1.6.3"'
)
android_set_version_code(
    version_code: 18
)
...
..
.
TheFabbiusCorp commented 2 years ago

Thanks, @pablopantaleon, this works! I think we need to update the documentation.

TheFabbiusCorp commented 2 years ago

@dsgriffin @pablopantaleon Please have a look at this PR if you think it's useful or needs additions/updates: https://github.com/beplus/fastlane-plugin-versioning_android/pull/17

igorlamos commented 1 year ago

@TheFabbiusCorp PR #17 merged – is that the whole solution to this issue so that it can be closed? Thank you!

TheFabbiusCorp commented 1 year ago

@TheFabbiusCorp PR #17 merged – is that the whole solution to this issue so that it can be closed? Thank you!

Well, that PR provides a description to a possible solution. It actually solves the issue, although supporting the use case in the code itself would be the best.

yoursweetginger commented 1 year ago

@TheFabbiusCorp PR #17 merged – is that the whole solution to this issue so that it can be closed? Thank you!

But it doesn't work, if you're trying to use variable instead of just string.

android_set_version_name(version_name: '"#{version_name}"')

In build.gradle it looks like it

versionName "#{version_name}"
yoursweetginger commented 1 year ago

@TheFabbiusCorp PR #17 merged – is that the whole solution to this issue so that it can be closed? Thank you!

But it doesn't work, if you're trying to use variable instead of just string.

android_set_version_name(version_name: '"#{version_name}"')

In build.gradle it looks like it

versionName "#{version_name}"

Solution

android_set_version_name(version_name: %Q["#{version_name}"])
FaisalMohammadi commented 1 year ago

@TheFabbiusCorp PR #17 merged – is that the whole solution to this issue so that it can be closed? Thank you!

But it doesn't work, if you're trying to use variable instead of just string.

android_set_version_name(version_name: '"#{version_name}"')

In build.gradle it looks like it

versionName "#{version_name}"

Solution

android_set_version_name(version_name: %Q["#{version_name}"])

this works for one time. When i run it again it throughs then the same error and the version looks like this in build.gradle ""2.0.0""

Solution for me was that i just put single quotes for version number like this %Q['#{version_name}']