fastlane icon indicating copy to clipboard operation
fastlane copied to clipboard

Version overrides do not work on Gradle 7.3+

Open turbohappy opened this issue 3 years ago • 17 comments

New Issue Checklist

Issue Description

Version name and version number are not being updated when building using Gradle versions 7.3+. Everything works as expected on 7.2 and earlier.

Command executed

bundle exec fastlane mvde_build_dev

Complete output when running fastlane, including the stack trace and command used
Nothing interesting here, it completes successfully but the version of the APK is just the defaults set in build.gradle, not the overrides set in the Fastfile

Environment

✅ fastlane environment ✅

Stack

Key Value
OS debian_based bullseye/sid
Ruby 2.7.0
Bundler? false
Git git version 2.25.1
Installation Source /usr/local/bin/fastlane
Host Ubuntu 20.04.3 LTS debian_based bullseye/sid (5.10.104-linuxkit)
Ruby Lib Dir /usr/lib
OpenSSL Version OpenSSL 1.1.1f 31 Mar 2020
Is contained false
Is homebrew false
Is installed via Fabric.app false

System Locale

Variable Value
LANG en_US.UTF-8 ✅
LC_ALL en_US.UTF-8 ✅
LANGUAGE en_US.UTF-8 ✅

fastlane files:

`./fastlane/Fastfile`
# frozen_string_literal: true

# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools

import("Egnytefile")

default_platform(:android)

platform :android do
  version_number = "222.0.0" # keep updated
  build_number = ENV['CI_PIPELINE_ID']

  build_properties_dev = {
    "android.injected.version.name" => version_number,
    "android.injected.version.code" => build_number,
    'android.injected.signing.store.file' => 'mvde/config/upload_keystore',
    'android.injected.signing.store.password' => ENV['ANDROID_KEYSTORE_PASS'],
    'android.injected.signing.key.alias' => 'keyalias',
    'android.injected.signing.key.password' => ENV['ANDROID_KEY_PASS']
  }

  # MVDE build
  lane :mvde_build_dev do
    build_android_app(
      task: 'clean :mvde:assemble',
      flavor: 'devStandard',
      build_type: 'Release',
      properties: build_properties_dev,
      flags: "--quiet"
    )
  end
end

No Appfile found

fastlane gems

Gem Version Update-Status
fastlane 2.207.0 ✅ Up-To-Date

Loaded fastlane plugins:

Plugin Version Update-Status
fastlane-plugin-firebase_app_distribution 0.3.4 ✅ Up-To-Date
Loaded gems
Gem Version
did_you_mean 1.4.0
atomos 0.1.3
CFPropertyList 3.0.5
claide 1.0.3
colored2 3.1.2
nanaimo 0.3.0
rexml 3.2.5
xcodeproj 1.21.0
rouge 2.0.7
xcpretty 0.3.0
terminal-notifier 2.0.0
unicode-display_width 1.8.0
terminal-table 1.8.0
plist 3.6.0
public_suffix 4.0.6
addressable 2.8.0
multipart-post 2.0.0
word_wrap 1.0.0
optparse 0.1.1
tty-screen 0.8.1
tty-cursor 0.7.1
tty-spinner 0.9.3
artifactory 3.0.15
babosa 1.0.4
colored 1.2
highline 2.0.3
commander 4.6.0
excon 0.89.0
faraday-em_http 1.0.0
faraday-em_synchrony 1.0.0
faraday-excon 1.1.0
faraday-httpclient 1.0.1
faraday-net_http 1.0.1
faraday-net_http_persistent 1.2.0
faraday-patron 1.0.0
faraday-rack 1.0.0
ruby2_keywords 0.0.5
faraday 1.8.0
unf_ext 0.0.8
unf 0.1.4
domain_name 0.5.20190701
http-cookie 1.0.4
faraday-cookie_jar 0.0.7
faraday_middleware 1.2.0
fastimage 2.2.5
gh_inspector 1.1.3
mini_magick 4.11.0
naturally 2.2.1
rubyzip 2.3.2
security 0.1.3
xcpretty-travis-formatter 1.0.1
dotenv 2.7.6
simctl 1.6.8
jwt 2.3.0
uber 0.1.0
declarative 0.0.20
trailblazer-option 0.1.2
representable 3.1.1
retriable 3.1.2
mini_mime 1.1.2
memoist 0.16.2
multi_json 1.15.0
os 1.1.4
signet 0.16.0
googleauth 1.1.0
httpclient 2.8.3
google-apis-core 0.4.1
google-apis-playcustomapp_v1 0.6.0
google-apis-androidpublisher_v3 0.14.0
google-cloud-env 1.5.0
google-cloud-errors 1.2.0
google-cloud-core 1.6.0
google-apis-iamcredentials_v1 0.8.0
google-apis-storage_v1 0.10.0
digest-crc 0.6.4
google-cloud-storage 1.35.0
emoji_regex 3.2.3
jmespath 1.4.0
aws-partitions 1.540.0
aws-eventstream 1.2.0
aws-sigv4 1.4.0
aws-sdk-core 3.124.0
aws-sdk-kms 1.52.0
aws-sdk-s3 1.109.0
uri 0.10.0
json 2.6.1
bundler 2.2.33
webrick 1.7.0
rake 13.0.6
forwardable 1.3.1
logger 1.4.2
cgi 0.1.0
date 3.0.0
timeout 0.1.0
stringio 0.1.0
ipaddr 1.2.2
openssl 2.1.2
zlib 1.1.0
mutex_m 0.1.0
ostruct 0.2.0
strscan 1.0.3
io-console 0.5.3
delegate 0.1.0
fileutils 1.4.1
etc 1.1.0
singleton 0.1.0
open3 0.1.0
yaml 0.1.0
psych 3.1.0
fastlane-plugin-firebase_app_distribution 0.3.4

generated on: 2022-07-12

turbohappy avatar Jul 12 '22 18:07 turbohappy

I am seeing the same behavior. My project works fine and updates the versionCode using this in my Fastfile gradle command:

 "android.injected.version.code" => code

when I'm using (Gradle 7.2)

 classpath 'com.android.tools.build:gradle:7.1.3'

however, it does not work when I'm using (Gradle 7.3)

 classpath 'com.android.tools.build:gradle:7.2.1'

iujames avatar Jul 21 '22 13:07 iujames

same behavior

alxon avatar Jul 23 '22 15:07 alxon

same here

truyentd-2427 avatar Aug 12 '22 11:08 truyentd-2427

Facing same issue here. It seems this is not related to Fastlane but rather to latest gradle version.

You can find the issue in Gradle's issue tracker:

https://issuetracker.google.com/issues/242730594

jpgarcia avatar Aug 19 '22 12:08 jpgarcia

It seems it is by design :(

More info https://developer.android.com/studio/releases/gradle-plugin#version_properties_removed_from_buildconfig_class_in_library_projects

jpgarcia avatar Aug 19 '22 13:08 jpgarcia

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest fastlane version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

Friendly reminder: contributions are always welcome! Check out CONTRIBUTING.md for more information on how to help with fastlane and feel free to tackle this issue yourself :muscle:

This issue will be auto-closed if there is no reply within 1 month.

fastlane-bot avatar Sep 18 '22 17:09 fastlane-bot

This is still an issue today

gugahoi avatar Oct 05 '22 02:10 gugahoi

Do you have an alternative?

zhiqingchen avatar Nov 09 '22 03:11 zhiqingchen

I am seeing the same behavior. My project works fine and updates the versionCode using this in my Fastfile gradle command:

 "android.injected.version.code" => code

when I'm using (Gradle 7.2)

 classpath 'com.android.tools.build:gradle:7.1.3'

however, it does not work when I'm using (Gradle 7.3)

 classpath 'com.android.tools.build:gradle:7.2.1'

This fixed it for me, using the previous version. Give it a try guys.

spijkermenno avatar Dec 16 '22 14:12 spijkermenno

Downgrading Gradle is a temporary solution, sooner or later you'll be forced out of it.

Here's how I solved it:

Fastfile:

desc "Deploy a new internal version to Google Play"           
lane :internal do                         
  # <...>                    

  gradle(                                                     
    task: "bundleRelease",                                    
    project_dir: "..",                                        
    properties: {                                             
      "versionCode" => build_number,                          
      "versionName" => build_name,                            
    },                                                        
  )                                                           
                                                              
  # <...>
end

and in my build.gradle.kts:

defaultConfig {                                                                
    applicationId = "pl.baftek.spitfire"                                      
    minSdk = 21                                                               
    targetSdk = 33                                                            
    versionCode = (findProperty("versionCode") as? String)?.toIntOrNull() ?: 1
    versionName = findProperty("versionName") as? String ?: "1.0.0"           
}                                                                             

bartekpacia avatar Jan 01 '23 22:01 bartekpacia

For me what worked is: in app/build.gradle versionCode project.hasProperty('versionCode') ? Integer.parseInt(project.versionCode) : 58

and in fastfile

gradle(.... properties: { "versionCode" => next_build_number, ...

xpt300 avatar Jan 25 '23 08:01 xpt300

@xpt300 thanks, it worked for me

hiendc170196 avatar Feb 01 '23 03:02 hiendc170196

There will be more and more people affected by this because the most recently released version of React Native bumped it's dependency on gradle to 7.3.1.

varemenos avatar Feb 09 '23 16:02 varemenos

Plugins based solution works well.

bundle exec fastlane add_plugin increment_version_code
bundle exec fastlane add_plugin increment_version_name
    increment_version_code(
      gradle_file_path: "./android/app/build.gradle",
      version_code: ENV["CI_BUILD_ID"]
    )

    increment_version_name(
      gradle_file_path: "./android/app/build.gradle",
      version_name: package['version']
    )

404-html avatar Feb 11 '23 19:02 404-html

Same issue reported here: https://issuetracker.google.com/issues/242730594?pli=1

gimi-anders avatar Apr 21 '23 09:04 gimi-anders

Plugins based solution works well.

bundle exec fastlane add_plugin increment_version_code
bundle exec fastlane add_plugin increment_version_name
    increment_version_code(
      gradle_file_path: "./android/app/build.gradle",
      version_code: ENV["CI_BUILD_ID"]
    )

    increment_version_name(
      gradle_file_path: "./android/app/build.gradle",
      version_name: package['version']
    )

saved my time thanks

ShaimaaFakhraldin avatar Sep 14 '23 09:09 ShaimaaFakhraldin