fastlane: Cannot set `apk_path` dynamically for Crashlytics

New Issue Checklist

Issue Description

The solutions commented here are not longer valid and the documentation is missing https://github.com/fastlane/fastlane/issues/6916

Reviewing the source I see apk_path is mandatory but I wonder how would I set it up dynamically as the version bumps.

Complete output when running fastlane, including the stack trace and command used

You can use: --capture_output as the last commandline argument to get that collected for you

[INSERT OUTPUT HERE]

Environment

Please run fastlane env and copy the output below. This will help us help you 👍 If you used --capture_output option please remove this block - as it is already included there.

✅ fastlane environment ✅

Stack

Key Value
OS 10.12.4
Ruby 2.2.4
Bundler? false
Git git version 2.3.0
Installation Source ~/.fastlane/bin/bundle/bin/fastlane
Host Mac OS X 10.12.4 (16E195)
Ruby Lib Dir ~/.fastlane/bin/bundle/lib
OpenSSL Version OpenSSL 1.0.2g 1 Mar 2016
Is contained false
Is homebrew true
Is installed via Fabric.app false
Xcode Path /Applications/Xcode.app/Contents/Developer/
Xcode Version 8.3.2

System Locale

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

fastlane files:

`./fastlane/Fastfile`
# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs
# All available actions: https://docs.fastlane.tools/actions
# can also be listed using the `fastlane actions` command


# Jaime: see examples at https://github.com/fastlane/examples/blob/master/Fabric/Fastfile


# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`

# If you want to automatically update fastlane if a new version is available:
# update_fastlane

# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "2.28.3"

default_platform :android

platform :android do

  before_all do
    git_pull(only_tags: true)
    # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
  end

  after_all do
    push_git_tags
  end


  desc "Runs all the tests"
  lane :test do
    gradle(task: "test")
  end


  def load_keys
    begin
      import("keys")
    rescue => exception
      UI.error("fastlane/keys file not found. To use this Fastfile, copy fastlane/keys.template into fastlane/keys and fill in the values")
      raise exception
    end
  end


# see https://docs.fastlane.tools/actions/#changelog_from_git_commits
# see https://github.com/fastlane/fastlane/blob/master/fastlane/spec/actions_specs/changelog_from_git_commits_spec.rb
  def change_log_since_last_tag
      # http://git-scm.com/docs/pretty-formats
      # <short hash> <commit title>
      return  changelog_from_git_commits(merge_commit_filtering: 'exclude_merges', pretty: '%s')
      #return changelog_from_git_commits(pretty: '%h %s')
  end


  desc "Returns a default changelog."
  lane :default_changelog do

  end

  desc "Submit a new Beta Build to Crashlytics Beta"
  lane :beta do |options|
#    ensure_git_status_clean

    gradle(
      task: "assemble",
      build_type: 'beta'
    )

    load_keys

    # Generate the changelog based on commit messages since your last tag

    #changelog_from_git_commits
#      notifications = false unless options[:notify_testers],
#    changes =


    changelog = changelog_from_git_commits(
        between: [ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT'] || "HEAD^^^^^", "HEAD"],
        pretty: "- %s"
    )
    # HAX: strip emoji from changelog
#    changelog = changelog.sub(/[\u{1F300}-\u{1F6FF}]/, '')
#    Actions.lane_context[SharedValues::FL_CHANGELOG] = changelog
    puts changelog


    # The crashlytics action knows how to use the generated changelog automatically
    crashlytics(
      api_token: ENV["CRASHLYTICS_API_TOKEN"],
      build_secret: ENV["CRASHLYTICS_BUILD_SECRET"],
#      apk_path: lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH],
      apk_path: "./app/build/outputs/apk/app-beta-0.0.1-BETA-unaligned.apk",
      apk_path: "/Users/jaime/Github/MYPROJECT/android/MYPROJECT/app/build/outputs/apk/app-beta*.apk",
      notes: changelog
#      notes:  change_log_since_last_tag,
#      groups: ["first_beta_testers"]
    )
    # sh "your_script.sh"
    # You can also use other beta testing services here
  end

  desc "Deploy a new version to the Google Play"
  lane :deploy do
    gradle(task: "assembleRelease")
    supply
  end

  # You can define as many lanes as you want

  after_all do |lane|
    # This block is called, only if the executed lane was successful

    # slack(
    #   message: "Successfully deployed new App Update."
    # )
  end

  error do |lane, exception|
    # slack(
    #   message: exception.message,
    #   success: false
    # )
  end
end


# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
# All available actions: https://docs.fastlane.tools/actions

# fastlane reports which actions are used
# No personal data is sent or shared. Learn more at https://github.com/fastlane/enhancer
`./fastlane/Appfile`
json_key_file "" # Path to the json secret file - Follow https://github.com/fastlane/supply#setup to get one
package_name "site.paid2party.android" # e.g. com.krausefx.app

fastlane gems

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

Loaded fastlane plugins:

No plugins Loaded

Loaded gems
Gem Version
slack-notifier 1.5.1
CFPropertyList 2.3.5
claide 1.0.1
colored2 3.1.2
nanaimo 0.2.3
xcodeproj 1.4.4
rouge 1.11.1
xcpretty 0.2.6
terminal-notifier 1.7.1
unicode-display_width 1.1.3
terminal-table 1.7.3
plist 3.2.0
public_suffix 2.0.5
addressable 2.5.1
multipart-post 2.0.0
word_wrap 1.0.0
tty-screen 0.5.0
babosa 1.0.2
colored 1.2
highline 1.7.8
commander-fastlane 4.4.4
excon 0.55.0
faraday 0.12.1
unf_ext 0.0.7.4
unf 0.1.4
domain_name 0.5.20170404
http-cookie 1.0.3
faraday-cookie_jar 0.0.6
fastimage 2.1.0
gh_inspector 1.0.3
uber 0.0.15
representable 2.3.0
retriable 2.1.0
mime-types-data 3.2016.0521
mime-types 3.1
hurley 0.2
little-plugger 1.1.4
multi_json 1.12.1
logging 2.2.2
jwt 1.5.6
memoist 0.15.0
os 0.9.6
signet 0.7.3
googleauth 0.5.1
httpclient 2.8.3
google-api-client 0.9.28
json 1.8.1
mini_magick 4.5.1
multi_xml 0.6.0
rubyzip 1.2.1
security 0.1.3
xcpretty-travis-formatter 0.0.4
dotenv 2.2.0
bundler 1.14.6
faraday_middleware 0.11.0.1

generated on: 2017-05-20

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 19 (6 by maintainers)

Most upvoted comments

Encountering the same issue at my end as well.

Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH] and Actions.lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS] both return correct paths using the latest build tools on AS 2.0 which is currently 2.3.3.

With the introduction of AS 3.0 Canary using the build tools 3.0.0-alpha1 and above, the output path seems to have been changed allowing for variant-aware dependency management

/app/build/outputs/…

2.3.3 output structure |____outputs | |____apk | | |____app-debug.apk | | |____app-release.apk

3.0.0-alpha1 + |____outputs | |____apk | | |____debug | | | |____app-debug.apk | | | |____output.json | | |____release | | | |____app-release.apk | | | |____output.json