APK version code conflict despite Google Play Store showing otherwise - fastlane

I am using fastlane to automatically increment my version code and deploy my app. I am getting the error apkNotificationMessageKeyUpgradeVersionConflict: APK specifies a version code that has already been used. - APK specifies a version code that has already been used despite the highest versionCode of my releases is 3.
Lanebump_version_code executing
[03:47:41]: ------------------------------
[03:47:41]: Driving the lane 'android alpha' 🚀
[03:47:42]: ------------------------------------------------------
[03:47:42]: --- Step: Switch to android bump_version_code lane ---
[03:47:42]: ------------------------------------------------------
[03:47:42]: Cruising over to lane 'android bump_version_code' 🚖
[03:47:42]: ---------------------------------------------
[03:47:42]: --- Step: google_play_track_version_codes ---
[03:47:42]: ---------------------------------------------
[03:47:43]: Found '1' version codes in track 'production'
[03:47:43]: ---------------------------------------------
[03:47:43]: --- Step: google_play_track_version_codes ---
[03:47:43]: ---------------------------------------------
[03:47:45]: Found '1' version codes in track 'beta'
[03:47:45]: ---------------------------------------------
[03:47:45]: --- Step: google_play_track_version_codes ---
[03:47:45]: ---------------------------------------------
[03:47:46]: Found '3' version codes in track 'alpha'
[03:47:46]: ------------------------------------
[03:47:46]: --- Step: increment_version_code ---
[03:47:46]: ------------------------------------
[03:47:46]: The get_version_code plugin is looking inside your project folder (./app)!
[03:47:46]: ☝️ Version code has been changed to 4
[03:47:46]: Cruising back to lane 'android alpha' 🚘
Lane context and error
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| DEFAULT_PLATFORM | android |
| PLATFORM_NAME | android |
| LANE_NAME | android alpha |
| VERSION_CODE | 4 |
| GRADLE_BUILD_TYPE | Release |
| GRADLE_ALL_APK_OUTPUT_PATHS | ["/Users/runner/runners/2.165.2/work/myapp/myapp/client/android/app/build/outputs/apk/release/app-release.apk"] |
| GRADLE_ALL_AAB_OUTPUT_PATHS | [] |
| GRADLE_ALL_OUTPUT_JSON_OUTPUT_PATHS | ["/Users/runner/runners/2.165.2/work/myapp/myapp/client/android/app/build/outputs/apk/release/output.json"] |
| GRADLE_ALL_MAPPING_TXT_OUTPUT_PATHS | [] |
| GRADLE_APK_OUTPUT_PATH | /Users/runner/runners/2.165.2/work/myapp/myapp/client/android/app/build/outputs/apk/release/app-release.apk |
| GRADLE_OUTPUT_JSON_OUTPUT_PATH | /Users/runner/runners/2.165.2/work/myapp/myapp/client/android/app/build/outputs/apk/release/output.json |
+-------------------------------------+-------------------------------------------------------------------------------------------------------------------+
[03:49:53]: Google Api Error: apkNotificationMessageKeyUpgradeVersionConflict: APK specifies a version code that has already been used. - APK specifies a version code that has already been used.
+------+------------------------------------------+-------------+
| fastlane summary |
+------+------------------------------------------+-------------+
| Step | Action | Time (in s) |
[!] Google Api Error: apkNotificationMessageKeyUpgradeVersionConflict: APK specifies a version code that has already been used. - APK specifies a version code that has already been used.
+------+------------------------------------------+-------------+
| 1 | default_platform | 0 |
| 2 | Switch to android bump_version_code lane | 0 |
| 3 | google_play_track_version_codes | 1 |
| 4 | google_play_track_version_codes | 1 |
| 5 | google_play_track_version_codes | 1 |
| 6 | increment_version_code | 0 |
| 7 | clean | 47 |
| 8 | assembleRelease | 73 |
| 💥 | upload_to_play_store | 5 |
+------+------------------------------------------+-------------+
Fastfile
lane :bump_version_code do
g = google_play_track_version_codes
gb = google_play_track_version_codes(track: 'beta')
ga = google_play_track_version_codes(track: 'alpha')
max_value = [g[0].to_i, gb[0].to_i, ga[0].to_i].max
version_updated = max_value + 1
increment_version_code(
app_folder_name: "./app",
version_code: version_updated.to_i
)
end
desc "Submit a new Alpha Build to Google Play"
lane :alpha do
bump_version_code
gradle(task: 'clean')
gradle(
task: 'assemble',
build_type: 'Release',
properties: {
"android.injected.signing.store.file" => ENV["ANDROID_KEYSTORE"],
"android.injected.signing.store.password" => ENV["ANDROID_KEYSTORE_PASSWORD"],
"android.injected.signing.key.alias" => ENV["ANDROID_KEY_ALIAS"],
"android.injected.signing.key.password" => ENV["ANDROID_KEY_PASSWORD"],
}
)
upload_to_play_store(track: 'alpha')
end
Archive library

Go to Google Play Console
"App bundle explorer" in the sidebar
top right corner, click on the "App version: *** ▾"
you should see all the uploaded bundle. Delete the one that have the version code you want to use.
Explanation: this happened to me while playing with Fastlane. I uploaded a bunch of .aab files and the versionCode was updated all the time (I was toying with increment_version_code plugin so this make sense). I ended up pushing a build by hand because I got an error (that has nothing to do with versionCode).
After a few days, I tried to continue working on that and wanted to upload my build "3" (versionCode: 3, as I only pushed 2 bundles in testing, the others where unused)... But during my previous days, I upload three builds 3, 4 and 5, that were causing the issue. Deleting them allowed me to push a new build with versionCode 3.

The error you got is due to after updating version code through increment_version_code, it again looks for "app/build.gradle" and picks version code from there which conflicts and then gives error.
You can solve this by 2 methods.
Add another lane below 'bump_version_code'.
lane :gitpush do
git add
git commit(path: '*', message: 'Version')
push_to_git_remote
Note:- If you build your app using CI workflows, add Git authentication step in your CI.yml
name: Deploy
on:
push:
branch: [ master ]
jobs:
distribute:
run-on: Ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v1
- name: Build App
run: npm run build
- name: Git Config
run: |
git config user.name "xyz"
git config user.email "xyz#gmail.com"
git config user.password "xyz123"
- name: Deploy
run: fastlane alpha
Another method is to properly config google_play_track_version_code which is better way to do it.
lane :increment_version_code do
version_code = google_play_track_version_codes(
package_name: "your package name", #e.g. com.xyz.app
track: "track-name", #e.g. alpha
json_key: "json key file path",
)
version_code_play_store = version_code[0].to_i
update_version_code = version_code_play_store + 1
increment_version_code(
gradle_file_path: "your gradle file path",
version_code: update_version_code.to_i
)
end
Hope this will help :)

This is because you have some artifact uploaded on the artifact library that has been uploaded manually. If you delete it it will work.
You can find the Artifact Library on the left menu, inside release management.
Probably there will be some draft binaries uploaded with a code version bigger than the ones on the active ones.

Related

Fastlane issue with fastlane match: Couldn't decrypt the repo, please make sure you enter the right password

I'm trying to learn fastlane and I'm currently blocked at fastlane match: https://docs.fastlane.tools/actions/match/#fastlane
Following the docs, I installed fastlane.
I created a private repository for the profiles and certificates.
I created an SSH key using a passphrase, example sfsfsdf
I added the SSH key to the ssh-agent and uploaded it to GitHub.
I ran then bundle exec fastlane match init and adjusted the Matchfile
Matchfile
git_url("git#github.com:my-repository/certificates.git")
git_branch("main")
type "development" # The default type, can be: appstore, adhoc, enterprise or development
app_identifier("com.mydomain.ios.project.v1")
username("my-appstore-account#domain.co")
Then I ran bundle exec fastlane match development to generate and install the Development certificates and profiles, which generates the following output:
fastlane could not check for updates error: 776: unexpected token at '<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>NoSuchBucket</Code><Message>The specified bucket does not exist</Message><BucketName>kits-crashlytics-com</BucketName><RequestId>VX3SA</RequestId><HostId>hnZRvv3hulf/q50pxV5S1co0jPLJq0KgI6/1EB0jQEI+dWlLedQA=</HostId></Error>'
[15:53:38]: Successfully loaded '/Users/my-user/my-project/fastlane/Matchfile' 📄
+----------------+--------------------------------------+
| Detected Values from './fastlane/Matchfile' |
+----------------+--------------------------------------+
| git_url | git#github.com:my-repository/
certificates.git |
| git_branch | main |
| type | development |
| app_identifier | com.mydomain.ios.project.v1. |
| username | my-appstore-account#domain.com |
+----------------+--------------------------------------+
+-----------------------+--------------------------------------+
| Summary for match 2.28.3 |
+-----------------------+--------------------------------------+
| git_url | git#github.com:my-repository/
certificates.git |
| git_branch | main |
| type | development |
| app_identifier | com.mydomain.ios.project.v1. |
| username | my-appstore-account#domain.com |
| keychain_name | login.keychain |
| readonly | false |
| team_id | TEAM_ID_NUMBER |
| verbose | false |
| force | false |
| skip_confirmation | false |
| shallow_clone | false |
| force_for_new_devices | false |
| skip_docs | false |
| platform | ios |
+-----------------------+--------------------------------------+
[15:53:38]: Cloning remote git repo...
[15:53:40]: Checking out branch main...
[15:53:40]: Enter the passphrase that should be used to encrypt/decrypt your certificates
[15:53:40]: This passphrase is specific per repository and will be stored in your local keychain
[15:53:40]: Make sure to remember the password, as you'll need it when you run match on a different machine
[15:53:40]: Passphrase for Git Repo:
I entered the passphrase I used for my SSH key (sfsfsdf) and I saw the following error:
[15:59:09]: Couldn't decrypt the repo, please make sure you enter the right password!
keychain: "/Users/my-user/Library/Keychains/login.keychain-db"
version: 512
class: "inet"
attributes:
0x00000007 <blob>="match_git#github.com:my-repository/certificates.git"
0x00000008 <blob>=<NULL>
"acct"<blob>=<NULL>
"atyp"<blob>="dflt"
"cdat"<timedate>=0x32303232303531303232353930395A00 "20220510225909Z\000"
"crtr"<uint32>=<NULL>
"cusi"<sint32>=<NULL>
"desc"<blob>=<NULL>
"icmt"<blob>=<NULL>
"invi"<sint32>=<NULL>
"mdat"<timedate>=0x32303232303531303232353930395A00 "20220510225909Z\000"
"nega"<sint32>=<NULL>
"path"<blob>=<NULL>
"port"<uint32>=0x00000000
"prot"<blob>=<NULL>
"ptcl"<uint32>=0x00000000
"scrp"<sint32>=<NULL>
"sdmn"<blob>=<NULL>
"srvr"<blob>="match_git#github.com:my-repository/certificates.git"
"type"<uint32>=<NULL>
password has been deleted.
[15:59:09]: Enter the passphrase that should be used to encrypt/decrypt your certificates
[15:59:09]: This passphrase is specific per repository and will be stored in your local keychain
[15:59:09]: Make sure to remember the password, as you'll need it when you run match on a different machine
[15:59:09]: Passphrase for Git Repo:
What am I doing wrong or not doing?
Thanks!
I'm facing a similar issue. So far the only solution I've seen is to add the password for the repo to the Matchfile as ENV["MATCH_PASSWORD"] = "[PASSWORD]".
This did not work for me, but it's the best I've found and it at least makes the error more obvious on the command line. My next attempt is going to be running fastlane match nuke and starting the process fresh.
This issue has more specifics about their reproducible steps and solution: https://github.com/fastlane/fastlane/issues/14879.

Azure pipeline how detect when pipeline stoped when script waiting for user input

I have a pipeline that is executing scripts and some of them are 3third party scripts.
in this case is Fastlane script.
Now in some rare cases, the Fastlane script is expecting the user to input value to stdin my question is how can I detect when a script is stoped and waiting to input. in this case, I like to throw an error and fail the task.
this is the pipeline task :
- script: |
fastlane release --verbose projectName:${{parameters.projectName}}
echo 'Done invoking Fastfile'
#failOnStderr: false
workingDirectory: '$(System.ArtifactsDirectory)/ios_artifacts'
displayName: 'run fastlane'
And it stack in this idle state :
2020-10-12T06:46:27.5309820Z INFO [2020-10-12 06:46:27.52]: [32m------------------[0m
2020-10-12T06:46:27.5310570Z INFO [2020-10-12 06:46:27.53]: [32m--- Step: sigh ---[0m
2020-10-12T06:46:27.5311280Z INFO [2020-10-12 06:46:27.53]: [32m------------------[0m
2020-10-12T06:46:27.5362760Z
2020-10-12T06:46:27.5386680Z +-------------------------------------+------------------------------+
2020-10-12T06:46:27.5387580Z | [32mSummary for sigh 2.162.0[0m |
2020-10-12T06:46:27.5388330Z +-------------------------------------+------------------------------+
2020-10-12T06:46:27.5389160Z | username | xxxx#xxxx.com |
2020-10-12T06:46:27.5389530Z | app_identifier | com.xxxx.xxxx |
2020-10-12T06:46:27.5389950Z | team_id | xxxx |
2020-10-12T06:46:27.5390320Z | adhoc | false |
2020-10-12T06:46:27.5390730Z | developer_id | false |
2020-10-12T06:46:27.5391490Z | development | false |
2020-10-12T06:46:27.5391860Z | skip_install | false |
2020-10-12T06:46:27.5392280Z | force | false |
2020-10-12T06:46:27.5392650Z | ignore_profiles_with_different_name | false |
2020-10-12T06:46:27.5393070Z | skip_fetch_profiles | false |
2020-10-12T06:46:27.5393450Z | skip_certificate_verification | false |
2020-10-12T06:46:27.5393860Z | platform | ios |
2020-10-12T06:46:27.5394230Z | readonly | false |
2020-10-12T06:46:27.5394630Z | fail_on_name_taken | false |
2020-10-12T06:46:27.5395400Z +-------------------------------------+------------------------------+
2020-10-12T06:46:27.5395640Z
2020-10-12T06:46:27.5396350Z INFO [2020-10-12 06:46:27.53]: Starting login with user 'xxxx#xxxx.com'
2020-10-12T06:46:27.5559840Z Reading keychain entry, because either user or password were empty
2020-10-12T06:46:27.5560420Z Loading session from environment variable
2020-10-12T06:46:27.7305500Z Session loaded from environment variable is not valid. Continuing with normal login.
2020-10-12T06:46:28.7278420Z Two-factor Authentication (6 digits code) is enabled for account 'xxxx#xxxx.com'
2020-10-12T06:46:28.7279570Z More information about Two-factor Authentication: https://support.apple.com/en-us/HT204915
2020-10-12T06:46:28.7279880Z
2020-10-12T06:46:28.7280520Z If you're running this in a non-interactive session (e.g. server or CI)
2020-10-12T06:46:28.7281300Z check out https://github.com/fastlane/fastlane/tree/master/spaceship#2-step-verification
How can i monitor this state ? and fail the pipeline ?
How can i monitor this state ? and fail the pipeline ?
As far as I know, this could not be possible. Currently, the azure devops pipeline does not provide such a built-in feature that can detect the script waiting for input and fail the pipeline. It should be an easy way to set the timeout you want for the task timeoutInMinutes: number # how long to wait before timing out the task to make it fail based on timeout, but it seems you don't want this.
You could add your request for this feature on our UserVoice site, which is our main forum for product suggestions. After suggest raised, you can vote and add your comments for this feedback. The product team would provide the updates if they view it.

IntelliJ Scala: import works in test folder but not in main folder

I have an IntelliJ project in scala with the following directory structure (I've renamed files/directories for simplicity):
project
|
+--src
| |
| +--main
| | |
| | +--scala
| | |
| | +--'X'
| | |
| | +--'Y.scala'
| +--test
| |
| +--scala
| |
| +--'X'
| |
| +--'YSuite.scala'
|
+--build.sbt
The issue I'm having is that I'm able to import things in the YSuite.scala file that I'm not able to in YSuite.scala - specifically, the scala.collections.parallel packages. I just have no idea how or why I can import in the test file, but not in the parallel application file. I need them in the main file for implementation. Can someone point me in the right direction?
Screenshots are of the Y.scala file, YSuite.scala file, as well as the build.sbt file, if they help at all.
As can be seen, the red text indicates that I wasn't able to import it in Y.scala - when I hover over it with my mouse, it simply says cannot resolve symbol parallel. However, I've run the test file with some implementation of the parallel package, which runs with no problems.
Y.scala
YSuite.scala
build.sbt
a solution that seems to have worked for me:
step 1: File -> Invalidate Caches / Restart
step 2: build again/spin up sbt

Can I pass the results from match to sh in fastlane?

I have lane like:
lane :beta do
match(type: "appstore")
sh "ember cdv:build
--platform ios
--code-sign-identity='iPhone Distribution: Cannla Pte Ltd (856AP7L2GS)'
--provisioning-profile='5feb0088-c4dd-4ca2-84e6-4bbf7f319248'
--release"
pilot
end
Can I get the code signing identity and provisioning profile from match instead of manually setting them like this?
match will automatically fill your environment variables. Check out the fastlane code signing docs on what kind of variables are exposed and how you can use them in your Xcode project.
By default, these are the environment variables that are exposed for you
+---------------------+------------------------------------------------+--------------------------------------+
| Installed Provisioning Profile |
+---------------------+------------------------------------------------+--------------------------------------+
| Parameter | Environment Variable | Value |
+---------------------+------------------------------------------------+--------------------------------------+
| App Identifier | | me.themoji.release |
| Type | | appstore |
| Profile UUID | sigh_me.themoji.beta_appstore | 22a19b3a-7cf6-4997-95f2-9cbb4d33fe7e |
| Profile Name | sigh_me.themoji.beta_appstore_profile-name | match AppStore me.themoji.release |
| Development Team ID | sigh_me.themoji.beta_appstore_team-id | N8XAAASEU2 |
+---------------------+------------------------------------------------+--------------------------------------+

Best Practices for Project Feature Sub-Modules with Mercurial and Eclipse?

I have a couple of ANT projects for several different clients; the directory structure I have for my projects looks like this:
L___standard_workspace
L___.hg
L___validation_commons-sub-proj <- JS Library/Module
| L___java
| | L___jar
| L___old_stuff
| L___src
| | L___css
| | L___js
| | L___validation_commons
| L___src-test
| L___js
L___v_file_attachment-sub-proj <- JS Library/Module
| L___java
| | L___jar
| L___src
| | L___css
| | L___js
| L___src-test
| L___js
L___z_business_logic-sub-proj <- JS Library/Module
| L___java
| | L___jar
| L___src
| L___css
| L___js
L____master-proj <- Master web-deployment module where js libraries are compiled to.
L___docs
L___java
| L___jar
| L___src
| L___AntTasks
| L___build
| | L___classes
| | L___com
| | L___company
| L___dist
| L___nbproject
| | L___private
| L___src
| L___com
| L___company
L___remoteConfig
L___src
| L___css
| | L___blueprint
| | | L___plugins
| | | | L___buttons
| | | | | L___icons
| | | | L___fancy-type
| | | | L___link-icons
| | | | | L___icons
| | | | L___rtl
| | | L___src
| | L___jsmvc
| L___img
| | L___background-shadows
| | L___banners
| | L___menu
| L___js
| | L___approve
| | L___cart
| | L___confirm
| | L___history
| | L___jsmvc
| | L___mixed
| | L___office
| L___stylesheets
| L___swf
L___src-standard
Within the working copy the modules compile the sub-project into a single Javascript file that is placed in the Javascript directory of the master project.
For example, the directories:
validation_commons-sub-proj
v_file_attachment-sub-proj
z_business_logic-sub-proj
...all are combined and minified (sort of like compiled) into a different Javascript filename in the _master-proj/js directory; and in the final step the _master-proj is compiled to be deployed to the server.
Now in regards to the way I'd like to set this up with hg, what I'd like to be able to do is clone the master project and its sub-projects from their own base-line repositories into a client's working-copy, so that modules can be added (using hg) to a particular customer's working copy.
Additionally however, when I do make some changes to/fix bugs in one customer's working copy, I would like to be able to optionally push the changes/bug fixes back to the master project/sub-project's base-line repository, for purposes of eventually pulling the changes/fixes into other customer's working copies that might contain the same bugs that need to be fixed.
In this way I will be able to utilize the same bug fixes across different clients.
However...I am uncertain of the best way to do this using hg and Eclipse.
I read here that you can use hg's Convert Extension to split a sub-directory into a separate project using the --filemap option.
However, I'm still a little bit confused as to if it would be better to use the Convert Extension or if it would be better to just house each of the modules in their own repository and check them out into a single workspace for each client.
Yep, it looks like subrepos are what you are looking for, but I think maybe that is the right answer for the wrong question and I strongly suspect that you'll run into similar issues that occur when using svn:externals
Instead I would recommend that you "publish" your combined and minified JS files to an artefact repository and use a dependency manager such as Ivy to pull specific versions of your artefacts into your master project. This approach give you far greater control over the sub-project versions your master project uses.
If you need to make bug fixes to a sub-project for a particular client, you can just make the fixes on the mainline for that sub-project, publish a new version (ideally via an automated build pipeline) and update their master project to use the new version. Oh, you wanted to test the new version with the their master project before publishing? In that case, before you push your fix, combine and minify your sub-project locally, publish it to a local repository and have the client's master project pick up that version for your testing.