firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.25k stars 571 forks source link

Firebase App Distribution Task with Missing app id Error #4013

Closed felixchez closed 1 year ago

felixchez commented 2 years ago

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

related to this issue https://github.com/firebase/firebase-android-sdk/issues/3501

still seeing "Missing app id. Please check that it was passed in and try again" error

Task :app:appDistributionUploadDebug FAILED Using APK path in the outputs directory: /builds/android/androidapp/build/outputs/apk/debug/androidapp-debug.apk. Uploading APK to Firebase App Distribution... FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task 'androidapp:appDistributionUploadDebug'. Missing app id. Please check that it was passed in and try again

Steps to reproduce:

./gradlew appDistributionUploadDebug

Relevant Code:

        firebaseAppDistribution {
            artifactType = "APK"
            releaseNotesFile = "RELEASE_NOTES.txt"
            groups = "android-testers"
        }
google-oss-bot commented 2 years ago

I found a few problems with this issue:

argzdev commented 2 years ago

Thanks for reporting, @felixchez. I can't seem to reproduce this issue on the latest version 3.0.3. Any chance you could share a MCVE? It'll help me investigate this further. Thanks

felixchez commented 2 years ago

@argzdev I will try to come up with a MCVE.

just want to describe the process that we ended up with the Missing App id issue.

The project environment is setup with gitlab CI/CD.

In this scenarios, we will encounter the Missing App id issue

build stage: ./gradlew assembleDebug

firebase stage: ./gradlew appDistributionUploadDebug

In the following scenarios, we will NOT experience the Missing App id issue. Noticed that assembleDebug is called again in firebase stage.

build stage: ./gradlew assembleDebug

firebase stage: ./gradlew assembleDebug appDistributionUploadDebug

argzdev commented 2 years ago

Thanks for the extra details, @felixchez. This is quite odd, I was able to upload the APK in both scenarios.

Could you check what Gradle and AGP version are you using in your CI/CD? In my setup, im currently using Gradle version 7.3.3 and AGP version 7.2.0.

google-oss-bot commented 2 years ago

Hey @felixchez. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

felixchez commented 2 years ago

using Gradle version 7.5.1 and AGP version 7.2.1 still seeing the issue. Let me work on downgrading to Gradle version 7.3.3 and AGP version 7.2.0.

felixchez commented 2 years ago

downgrade to AGP version 7.3.3 and AGP version 7.2.0 still complaint error of missing AppId.

when using Gitlab CI/CD pipelines, this AppId issue gets away only when setting with the following methods exclusively.

Method #1:

        firebaseAppDistribution {
          appId = "...."
        }

Method #2:

export FIREBASE_APP_ID=""
./gradlew appDistributionUploadDebug

Method #3:

./gradlew assembleDebug appDistributionUploadDebug

Observing from method #3 which running assembleDebug on the same stage, firebaseAppDistribution don't complaint about the AppId error. However, when having build and deploy stages, Gitlab doesn't cache environment variables e.g. mobilesdk_app_id from build stage for deploy stage.

argzdev commented 2 years ago

That's insightful! Thanks for the extra details, @felixchez. I'll notify our engineers and see what we can do here.

tagboola commented 1 year ago

Hey @felixchez! I'm a developer on the App Distribution team. When the appId parameter isn't set in your build.gradle file, the gradle plugin gets the appId from the resource file that is output from the google-services plugin when the assembleDebug command is run. The file's location is app/build/generated/res/google-services/{build_type}/values/values.xml.

https://developers.google.com/android/guides/google-services-plugin#processing_the_json_file

Are you passing this file from the build stage to the firebase stage?

felixchez commented 1 year ago

@tagboola caching values.xml between build stage to the firebase stage does resolve the issue with missing appId. Thank you!

tagboola commented 1 year ago

Happy to help!

felixchez commented 1 year ago

@tagboola and @argzdev, Thank you for your help! Hopefully, this thread will help others as well when using Gitlab with build and Firebase deploy in stages.