firebase/fastlane-plugin-firebase_app_distribution

the server responded with status 400

mibrahimdev opened this issue ยท 5 comments

Issue Description

  • fastlane (2.198.1)
  • fastlane-plugin-firebase_app_distribution (0.3.1)

I'm getting this issue and didn't succeed in the step where CircleCi and Fastlane upload APK to Firebase distribution, I've read every issue and StackOverflow threads but I didn't get anywhere. the token is working locally on my machine and the Fastlane log on CircleCi shows that's authenticated successfully, but didn't proceed to upload the apk.
I've attached the error on CircleCi and distribution lane as follow:

[21:53:06]: ---------------------------------------
[21:53:06]: --- Step: firebase_app_distribution ---
[21:53:06]: ---------------------------------------
[21:53:06]: Authenticating with FIREBASE_TOKEN environment variable
[21:53:06]: ๐Ÿ” Authenticated successfully.
[21:53:06]: โŒ› Uploading the APK.
+-------------------------------------+-----------------------------------------------------------------------------------+
|                                                      Lane Context                                                       |
+-------------------------------------+-----------------------------------------------------------------------------------+
| DEFAULT_PLATFORM                    | android                                                                           |
| PLATFORM_NAME                       | android                                                                           |
| LANE_NAME                           | android CI_Distribute                                                             |
| GRADLE_ALL_APK_OUTPUT_PATHS         | ["/home/circleci/project/app/build/outputs/apk/release/app-release-unsigned.apk"] |
| GRADLE_ALL_AAB_OUTPUT_PATHS         | []                                                                                |
| GRADLE_ALL_OUTPUT_JSON_OUTPUT_PATHS | ["/home/circleci/project/app/build/outputs/apk/release/output-metadata.json"]     |
| GRADLE_ALL_MAPPING_TXT_OUTPUT_PATHS | []                                                                                |
| GRADLE_APK_OUTPUT_PATH              | /home/circleci/project/app/build/outputs/apk/release/app-release-unsigned.apk     |
| GRADLE_OUTPUT_JSON_OUTPUT_PATH      | /home/circleci/project/app/build/outputs/apk/release/output-metadata.json         |
+-------------------------------------+-----------------------------------------------------------------------------------+
[21:53:06]: the server responded with status 400

+------+-----------------------------------+-------------+
|                    fastlane summary                    |
+------+-----------------------------------+-------------+
| Step | Action                            | Time (in s) |
+------+-----------------------------------+-------------+
| 1    | default_platform                  | 0           |
| 2    | setup_circle_ci                   | 0           |
| 3    | Switch to android distribute lane | 0           |
| 4    | clean assembleRelease             | 73          |
| ๐Ÿ’ฅ   | firebase_app_distribution         | 0           |
+------+-----------------------------------+-------------+

[21:53:06]: fastlane finished with errors

Looking for related GitHub issues on fastlane/fastlane

Fastfile:

default_platform(:android)


platform :android do


  before_all do
    setup_circle_ci
  end

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

  desc "Submit a new Beta Build to Crashlytics Beta"
  lane :beta do
    gradle(task: "clean assembleRelease")
    crashlytics
  end

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


#Main Distribute lane
 lane :distribute do |options|
     gradle(task: "clean assembleRelease")
     firebase_app_distribution(
        app: "#{options[:firebaseAppId]}",
        firebase_cli_token: "#{options[:firebaseCliToken]}",
        groups_file: "FirebaseAppDistributionConfig/groups.txt",
        release_notes_file: "FirebaseAppDistributionConfig/release_notes.txt",
     )
 end

#Ci lane
 lane :CI_Distribute do |options|
     distribute(
        firebaseAppId: "#{options[:FIREBASE_APP_ID]}",
        firebaseCliToken: "#{options[:FIREBASE_TOKEN]}",
     )
 end

#Fastlane lane
 lane :Fast_distribute do
     distribute(
        firebaseAppId: ENV["FIREBASE_APP_ID"],
        firebaseCliToken: ENV["FIREBASE_TOKEN"],
     )
 end

end

I'm having the same problem. If I upload the apk manually it works fine. I checked if groups where correct and they are, I don't have release notes and kind of out of ideas what to try.

@taltrui Well, let me explain what I've found;
firstly there's a debug flag you could enable it with Firebase App distribution, and then when it fails, it will log error cause, so What I've got plus the 400 status, is an error message telling me that there's an invalid argument.
The fix was to use Fast_distribute directly instead of CI_Distribute with arguments. But you've to make sure that you've saved token and app id in CircleCi with the same names as Fastlane .env variables.

@MohamedISoliman how did you set the debug flag on Firebase App Distribution? I am getting the same error

@aaronksaunders this is a sample code of mine

 firebase_app_distribution(
        app: "#{options[:firebaseAppId]}",
        firebase_cli_token: "#{options[:firebaseCliToken]}",
        release_notes: "Text of release notes",
        groups_file: "FirebaseAppDistributionConfig/groups.txt",
        release_notes_file: "FirebaseAppDistributionConfig/release_notes.txt",
        debug: true
     )