EAS Submit failing for android productFlavor

Hi

I have setup different android product flavours and can run successful builds, but eas submit is failing due to not picking up the right package name.

#!/bin/bash -eo pipefail
eas submit --platform android --latest --key=android/***.json
- Linking to project @payright/payright
✔ Linked to project @payright/payright


Project ID:          59c8a51b-789d-4ede-922c-63806d03b6e0
Android package:     com.payright.customer
Release track:       internal
Release status:      completed
Archive type:        AAB
Build ID:            [latest]
Google Service Key:  android/****.json

- Scheduling submission
✔ Scheduling submission
- Submitting your app to Google Play Store
✖ Something went wrong when submitting your app to Google Play Store.
We couldn't figure out what went wrong. Please see logs to learn more.

[logs] Starting uploading Android app
[logs] Downloading archive
[logs] Preparing artifact
[logs] Uploading Android app to Play Store...
[logs] Uploading the app with fastlane
[logs] +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
[logs] |                                                                    Summary for supply 2.170.0                                                                     |
[logs] +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
[logs] | aab                             | /tmp/submissions/4d1248bf-1006-4ba0-b497-c708558a8f03/3f94a51d_6389_426f_85e8_3704e6441445_568f9a0e43da44e58aceb02b99ad846b.aab |
[logs] | track                           | internal                                                                                                                        |
[logs] | json_key                        | /tmp/submissions/4d1248bf-1006-4ba0-b497-c708558a8f03/service-account.json                                                      |
[logs] | package_name                    | com.payright.customer                                                                                                           |
[logs] | release_status                  | completed                                                                                                                       |
[logs] | skip_upload_apk                 | false                                                                                                                           |
[logs] | skip_upload_aab                 | false                                                                                                                           |
[logs] | skip_upload_metadata            | false                                                                                                                           |
[logs] | skip_upload_changelogs          | false                                                                                                                           |
[logs] | skip_upload_images              | false                                                                                                                           |
[logs] | skip_upload_screenshots         | false                                                                                                                           |
[logs] | validate_only                   | false                                                                                                                           |
[logs] | check_superseded_tracks         | false                                                                                                                           |
[logs] | timeout                         | 300                                                                                                                             |
[logs] | deactivate_on_promote           | true                                                                                                                            |
[logs] | ack_bundle_installation_warning | false                                                                                                                           |
[logs] +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
[logs] 
[logs] Preparing aab at path '/tmp/submissions/4d1248bf-1006-4ba0-b497-c708558a8f03/3f94a51d_6389_426f_85e8_3704e6441445_568f9a0e43da44e58aceb02b99ad846b.aab' for upload...
[logs] [!] Google Api Error: forbidden: APK has the wrong package name. - APK has the wrong package name.
[logs] fastlane supply failed
[logs] Failed to submit the app

Exited with code exit status 1
CircleCI received exit code 1

My app.json has this…

    "android": {
      "package": "com.payright.customer",
      "versionCode": 4
    },

But build.gradle is setup like this:

    defaultConfig {
        applicationId 'com.payright.customer'
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode findProperty("android.versionCode") as Integer
        versionName findProperty("android.versionName")
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    productFlavors {
        dev {
            applicationId 'com.payright.customer.dev'
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            resValue "string", "build_config_package", "com.payright.customer.dev"
        }
        uat {
            applicationId 'com.payright.customer.uat'
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            resValue "string", "build_config_package", "com.payright.customer.uat"
        }
        prod {
            applicationId 'com.payright.customer'
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            resValue "string", "build_config_package", "com.payright.customer"
        }
    }

Where should I update in order for EAS Submit to deploy the “dev” version to the right project on Play Store?

Regards

see the flags you can pass in:

╰─$ eas submit --help
Submits build artifact to app store

USAGE
  $ eas submit --platform=(android|ios)

OPTIONS
  --id=id                       ID of the build to submit
  --latest                      Submit the latest build for specified platform
  --path=path                   Path to the .apk/.aab file
  -p, --platform=(android|ios)  For which platform you want to submit a build
  --url=url                     App archive url
  --verbose                     Always print logs from Submission Service

  Android specific options
  --android-package=android-package                     Android package name (default: expo.android.package from app config)
  --key=key                                             Path to the JSON key used to authenticate with Google Play
  --release-status=(completed|draft|halted|inProgress)  [default: completed] Release status (used when uploading new APKs/AABs)
  --track=(production|beta|alpha|internal|rollout)      [default: internal] The track of the application to use
  --type=(apk|aab)

@notbrent

#!/bin/bash -eo pipefail
eas submit --platform android --android-package=com.payright.customer.dev --latest --key=android/***.json
- Linking to project @payright/payright
✔ Linked to project @payright/payright


Project ID:          59c8a51b-789d-4ede-922c-63806d03b6e0
Android package:     com.payright.customer
Release track:       internal
Release status:      completed
Archive type:        AAB
Build ID:            [latest]
Google Service Key:  android/pc-api-9136511296602971461-220-d3952f3c27fd.json

So adding that argument to the eas submit does not seem to get picked up, still tried to submit with the wrong package name??

it won’t filter out the latest build with that package name, it will just use the latest build. pass in the build id if you have a build that isn’t the latest that you’d like to submit with a given package name

In this case I actually created a new build so it was the latest build.

I was able to get it working although i don’t think it is the ideal way. I had to change the app.json package name to com.payright.customer.dev in order for the eas submit to work. Oddly, eas build does NOT work in this case. eas build:configure tries to set the defaultConfig applicationId in build.gradle to com.payright.customer.dev, although i set this as com.payright.customer and then add a suffix for productFlavour as below.

        dev {
            applicationIdSuffix ".dev"
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            resValue "string", "build_config_package", "com.payright.customer.dev"
        }

When i run this in circle i edit the app.json after running eas build in order to run eas submit successfully.

I guess the workaround is to conditionally render or use env variables to set the applicationId in the defaultConfig based on the productFlavor (??).

I don’t see that the android-package flag is actually working as you would expect when running eas submit.