SOLVED: Android not building due to fastlane error (apk file not found)

Never been able to get the android build and deploy within Appflow build system.

using:

  • IONIC V5
  • CAPACITOR V2

  • IOS + Web are building + deploying correctly.
  • Android is built and signed perfectly locally and successfully deployed to the playstore.

The building process itself seems to go fine and finishes with: “BUILD SUCCESSFULL”

After that the script seems to use fastlane to upload this file:

android/app/build/outputs/apk/release/app-release.apk

which doesn’t seem to exist, nor is this path configured within my project configuration.

Any suggestions to get this to work? Is it required to install fastlane within my project?


(... build process) 
[08:44:03]: ▸ BUILD SUCCESSFUL in 2m 45s
[08:44:03]: ▸ 198 actionable tasks: 198 executed
+----------------------------+-------------------------------------------------------+
|                                    Lane Context                                    |
+----------------------------+-------------------------------------------------------+
| DEFAULT_PLATFORM           | ios                                                   |
| PLATFORM_NAME              | android                                               |
| LANE_NAME                  | android package_build                                 |
| PROJECT_WEB_DIR            | dist/fitmama                                          |
| DOWNLOAD_CREDENTIAL_EXISTS | true                                                  |
| DOWNLOAD_CREDENTIAL_PATH   | /builds/fitmama-nl/Fitmama.App.Ionic/android.keystore |
| DOWNLOAD_CREDENTIAL_ALIAS  | upload-key                                            |
+----------------------------+-------------------------------------------------------+
[08:44:03]: apk file android/app/build/outputs/apk/release/app-release.apk not found

+------+-------------------------+-------------+
|               fastlane summary               |
+------+-------------------------+-------------+
| Step | Action                  | Time (in s) |
+------+-------------------------+-------------+
| 1    | default_platform        | 0           |
| 2    | build_summary           | 0           |
| 3    | add_git_credentials     | 0           |
| 4    | get_appflow_config      | 0           |
| 5    | detect_native_type      | 0           |
| 6    | dependency_install      | 85          |
| 7    | create_capacitor_config | 0           |
| 8    | get_web_dir             | 0           |
| 9    | modify_cap_web_config   | 0           |
| 10   | download_credential     | 1           |
| 11   | build_pro_app           | 189         |
| 12   | cap_sync                | 1           |
| 13   | cap_custom_deploy       | 0           |
| 💥   | build_android_capacitor | 165         |
+------+-------------------------+-------------+

[08:44:03]: fastlane finished with errors
/usr/local/bundle/bin/fastlane: [!] apk file android/app/build/outputs/apk/release/app-release.apk not found (RuntimeError)
/builds/fitmama-nl/Fitmama.App.Ionic/fastlane/actions/build_android_capacitor.rb:73:in `find_artifacts': apk file android/app/build/outputs/apk/release/app-release.apk not found (RuntimeError)
	from /builds/fitmama-nl/Fitmama.App.Ionic/fastlane/actions/build_android_capacitor.rb:66:in `run'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/runner.rb:263:in `block (2 levels) in execute_action'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/actions/actions_helper.rb:69:in `execute_action'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/runner.rb:255:in `block in execute_action'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/runner.rb:229:in `chdir'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/runner.rb:229:in `execute_action'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/runner.rb:157:in `trigger_action_by_name'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/fast_file.rb:159:in `method_missing'
	from Fastfile:174:in `block (2 levels) in parsing_binding'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/lane.rb:33:in `call'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/runner.rb:49:in `block in execute'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/runner.rb:45:in `chdir'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/runner.rb:45:in `execute'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/lane_manager.rb:47:in `cruise_lane'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/command_line_handler.rb:36:in `handle'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/commands_generator.rb:108:in `block (2 levels) in run'
	from /usr/local/bundle/gems/commander-fastlane-4.4.6/lib/commander/command.rb:178:in `call'
	from /usr/local/bundle/gems/commander-fastlane-4.4.6/lib/commander/command.rb:153:in `run'
	from /usr/local/bundle/gems/commander-fastlane-4.4.6/lib/commander/runner.rb:476:in `run_active_command'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:76:in `run!'
	from /usr/local/bundle/gems/commander-fastlane-4.4.6/lib/commander/delegates.rb:15:in `run!'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/commands_generator.rb:352:in `run'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/commands_generator.rb:41:in `start'
	from /usr/local/bundle/gems/fastlane-2.169.0/fastlane/lib/fastlane/cli_tools_distributor.rb:119:in `take_off'
	from /usr/local/bundle/gems/fastlane-2.169.0/bin/fastlane:23:in `<top (required)>'
	from /usr/local/bundle/bin/fastlane:23:in `load'
	from /usr/local/bundle/bin/fastlane:23:in `<main>'
Running after script...
$ run "clean-up"
ERROR: Job failed: command terminated with exit code 1

Hi MrBasque,

Thanks for posting this.

I suspect the new AAB support for Android builds in Appflow might have caused this issue for you. It would be helpful to take a closer look at your build logs and the project.

I would encourage you to contact the Appflow support and we should be able to assist you.

Cheers,

1 Like

Hi @Likhith_Aalla Thanks for responding. It has been like this since the beginning, so i’m not convinced it’s in the newer AAB support. But i will contact support and see if they can help me me with this. Thanks again!

SOLUTION: (Thanks to the Appflow support team)

For reference, this issue was resolved in the following way:

I removed the following line from the build.gradle file:

archivesBaseName = "$applicationId-v$versionCode($versionName)"

That entry changes the builds output .apk name, in order to make the buildsystem produce a separate apk for each version. (Which is pretty convenient btw, when building locally)

I manually added that entry a long time ago, and never thought about it again. :cowboy_hat_face:

1 Like