Fastlane File
default_platform(:android)
platform :android do
desc "Deploy a new version to the Google Play internal track"
lane :internal do
# Fetching the current version code from Google Play
google_play_info = google_play_track_version_codes(
track: "internal"
)
# Debug output to inspect google_play_info
UI.message("Google Play Info: #{google_play_info}")
#if google_play_info[:version_codes].nil? || google_play_info[:version_codes].empty?
# UI.user_error!("Could not fetch version codes from Google Play")
#end
current_version_code = google_play_info[:version_codes].max.to_i
new_version_code = current_version_code + 1
# Define a helper method to increment version code in build.gradle
def increment_version_code_in_gradle(new_version_code)
gradle_file_path = "./app/build.gradle"
gradle_content = File.read(gradle_file_path)
updated_content = gradle_content.gsub(/versionCode\s+\d+/) do |match|
"versionCode #{new_version_code}"
end
File.write(gradle_file_path, updated_content)
end
# Increment the version code in build.gradle
increment_version_code_in_gradle(new_version_code)
# Build the AAB (Android App Bundle)
gradle(
task: "bundle",
build_type: "Release"
)
# Upload the AAB to the internal track on Google Play
upload_to_play_store(
track: "internal",
aab: "./app/build/outputs/bundle/release/app-release.aab",
)
end
end
Error is
Error in your Fastfile at line 20
18: #end
19:
=> 20: current_version_code = google_play_info[:version_codes].max.to_i
21:
22: new_version_code = current_version_code + 1
no implicit conversion of Symbol into Integer
auto increment in version number google play store using Faslane
The error "no implicit conversion of Symbol into Integer fastlane", means that ruby tries to convert a Symbol to an Integer, meaning that you passed a Symbol to somewhere that expects an integer.
Let's see the offending line.
current_version_code = google_play_info[:version_codes].max.to_i
There is only one symbol here. From this my initial suspicion was that google_play_info
is not a hash (that would be indexed by symbols), but is an array instead (that would need to be indexed by integers).
google_play_info = google_play_track_version_codes(
track: "internal"
)
https://docs.fastlane.tools/actions/google_play_track_version_codes/
Returns: Array of integers representing the version codes for the given Google Play track
The docs indeed say that this is an Array.
I don't know exactly what you intended to do, but a possible fix is to just remove the hash access since you're already dealing with version codes. Also, since it returns an array of integers, then the .to_i
is redundant as well.
current_version_code = google_play_info.max