Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android build failing when using default build number #58

Open
jasperamorgan opened this issue Jun 12, 2020 · 3 comments
Open

Android build failing when using default build number #58

jasperamorgan opened this issue Jun 12, 2020 · 3 comments

Comments

@jasperamorgan
Copy link

Issue

Our Flutter build tasks were running without problem and then suddenly started to fail.

The command that was causing the error was:

/Users/runner/hostedtoolcache/Flutter/1.18.0-11.1.pre-beta/macos/flutter/bin/flutter build apk --target-platform=android-arm --build-number=20200611.1

The error was:

buildNumber: 20200611.1 was not a valid integer value.

OK, makes sense - 20200611.1 is certainly not an integer.

This is not an error with the vsts-flutter-tasks - it is an error from the Android gradle build task. I'm adding it here in case others encounter the same problem.

Solution

The solution is the change how Azure names each pipeline run by adding a 'name' to your pipline yaml.

I chose to use the BuildID pipeline variable which is "an internal immutable ID that is also referred to as the Run ID. It is unique across the organization"

name: $(BuildID)
stages:
  - stage: Build
....

Explanation

The Flutter Build task uses the buildNumber pipeline variable and then passes this as the --build-number to the Android build.

The default value for the buildNumber assigned by the Azure Pipeline is $(Date:yyyyMMdd).$(Rev:r) - See the docs..

This is not an integer.

To change the value of the buildNumber, we set a 'name' in the pipeline yaml.

(Yeah, it's a nice bit of MS inconsistency that seems to be everywhere in Azure...)

Configuring the build number also changes the 'name' of the pipeline run that is displayed in the Azure UI. (Not the name of the pipeline itself, just the identifier of an individual run of the pipeline.) See the docs.

I still don't know why the pipeline build was working and then suddenly stopped working. It's a little hard to know the exact details of machines running the pipelines and the Android SDK versions being used - maybe that changed....

@denisbabineau
Copy link

For us this started happening when we went from Flutter 1.17.5 to 1.20.0

@shadow1007
Copy link

Since $(Date:yyyyMMdd)$(Rev:.r) is used as $buildNumber, it is not available after version 1.17.5 (maybe flutter team fix it later). There are two option for this case.

Set version to 1.17.5

- task: FlutterInstall@0
  inputs:
    channel: 'stable'
    version: 'custom'
    customVersion: '1.17.5'

In addition to using version 1.17.5, if you want to use the latest version of Flutter, which I recommended, there is another way to solve it.

ADD
name: $(Date:yyyyMMdd)$(Rev:r)
to the TOP of azure-pipelines.yml

like

name: $(Date:yyyyMMdd)$(Rev:r)
variables:
  projectDirectory: .
    
  jobs:
    - job: Android

We can just simply change $(Rev:.r) to $(Rev:r). The build number be like 20200907.1 to 202009071

If you want to show prefix zeros in the number, you can add additional 'r' characters. For example, specify $(Rev:rr) if you want the Rev number to begin with 01, 02, and so on.

For more information about Configure run or build numbers, you can look this up.

@LukasP94
Copy link

It take me few hour to figure this out but I found workaround how to use build number which you specify in pubspec.yaml (i.g. version: 1.0.1+11) for FlutterBuild.

Documentation for this task says it is optional, but some weird number is used, but if you specify build number like: buildNumber: '' (empty quotation marks). Then magic happen and your aplication will be build with build number specified in pubspec.yaml.

- task: FlutterBuild@0
  displayName: 'Flutter Build'
  inputs:
    target: 'aab'
    projectDirectory: '$(Build.SourcesDirectory)'
    buildNumber: ''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants