Blocking issue: Android credentials in multi-flavor config

I have an Android build configuration (bare workflow) with two productFlavors, one with the internal applicationId that I’m publishing to our internal Play account, and one with the production applicationId, that I’m publishing to the client’s Play account.

With a little workaround (changing the default applicationId manually), I have been able to upload credentials for both applicationIds to EAS, and I can see them in the web interface (this is a feature request in it’s own right, but at least it can be worked around).

However, eas will not select the credentials for the second applicationId, not even if I change the default applicationId in my build.gradle before kicking off the build.

As a workaround, I tried using the local credentials, but apparently, credentials.json doesn’t support storing more than one set of credentials at all.

All in all, short of overwriting credentials.json (‘CI style’) before kicking off the build, I have no way to run with EAS stored credentials, or locally configured ones, for the second productFlavor.

hi there! you could swap out the credentials provided in credentials.json depending on which flavor you’re building. the idea is not for credentials.json to have multiple credentials that are picked from at build time, but rather to specify exactly which credentials you wish to use for a particular build. we’ll discuss better affordances for product flavors, do let me know if you have any suggestions on how to handle it best.

Hi, that is what I suggested when I said ‘short of overwriting credentials’. But using credentials.json is a workaround to begin with, as I am able to store both sets of credentials for Android on EAS, but I’m unable to use them. I shouldn’t need a credentials.json, and it makes working in a team harder, because we can’t benefit from the credentials being uploaded to EAS.

the idea is not for credentials.json to have multiple credentials that are picked from at build time

Yet that is exactly how it works for iOS with multiple targets. Each one can be specified in credentials.json, and each one can have their own provisioningProfile etc.

do let me know if you have any suggestions on how to handle it best.

I would like Android productFlavors and iOS targets/schemes to be handled the same.

Every single project we do is set up exactly the same: on Android we have 2 productFlavors, each with their own keystores and applicationId, and their own api.json for uploading to either our own store, or the clients. on iOS, we have 2 schemes, each with their own applicationId and team, for uploading to our own Connect account, or the clients.

So far (because we only had bare workflow projects), we could sort of make this happen, but I’m now looking at the managed workflow too (because we don’t really have another reason left to go bare).

I’ll be happy to work with you to shape this functionality more.

[Kim Brandwijk]

1 Like

understood. thanks kim, we’ll discuss this further and get back to you

We’ve run into this exact same situation (2 flavors, 1 connected to the staging api, 1 connected to the production api).

Ideally we’d be able to:

  • Specify a set of Build Credentials when running eas build: eas build --platform android --profile staging --credentials staging
  • Specify Build Credentials in the eas.json file (build.staging.android.credentials)
  • Specify multiple sets of credentials in credentials.json

Hope this helps. If I understand notbrent correctly, the workaround for this is to store your credentials as secrets in your CI and then let it rewrite your credentials.json when building your application, correct?

(I’ve tried this by the way, but even though I have a local credentials.json file, when I run eas build, it will default to remote credentials. Of course this could be fixed by removing and reinitiating the project completely)

Hope this helps. If I understand notbrent correctly, the workaround for this is to store your credentials as secrets in your CI and then let it rewrite your credentials.json when building your application, correct?

yes

(I’ve tried this by the way, but even though I have a local credentials.json file, when I run eas build , it will default to remote credentials. Of course this could be fixed by removing and reinitiating the project completely)

you need to set credentialsSource: local in your build profile in eas.json

Ideally we’d be able to: …

We don’t want to support multiple sets of credentials in credentials.json, if you want us to manage credentials you should use remote credentials(not possible with flavors yet) and credentials.json is intended for people that want to manage them on their own.

I started working on flavors support, so workaround with credentials.json is only temporary

2 Likes

Gotcha! Thanks for your reply. Looking forward to multi flavor support. For now we’ll still with the credentials.json workaround. Thanks again!

@wkozyra hi :slight_smile:

it seems that your PR supporting flavors was already merged: [eas-cli] support multiflavor android projects by wkozyra95 · Pull Request #595 · expo/eas-cli · GitHub

I am building an app with multiple flavors on android but still I’m only able to push one FCM Server Key.

In “Credentials” in the EAS dashboard there’s only one application ID for android so it seems there’s no way of having different keystores / push notification credentials when we have flavors adding a suffix (for example, applicationIdSuffix “.staging”)?

Thank you,

multiflavor projects are supported but applicationIdSuffix is not if you want to assign different applicationId for different flavors you need to use sth like this

    flavorDimensions "env"
    productFlavors {
        production {
            dimension "env"
            applicationId 'example.app.id'
        }
        staging {
            dimension "env"
            applicationId 'example.app.id.staging'
        }
    }

Thank you @wkozyra :slight_smile: