shorebirdtech / shorebird

Code Push for Flutter and other tools for Flutter businesses.
https://shorebird.dev
Other
2.37k stars 143 forks source link

fix: flavors with multiple dimensions cause release command to not find aab #1830

Closed eseidel closed 7 months ago

eseidel commented 8 months ago

With flavors across multiple dimensions, our release command cannot find the generated aab.

For example:

    flavorDimensions "track", "country"
    productFlavors {
        internal {
            dimension "track"
            applicationIdSuffix ".internal"
            manifestPlaceholders = [applicationLabel: "[Internal] Shorebird Example"]
        }
        stable {
            dimension "track"
            manifestPlaceholders = [applicationLabel: "Shorebird Example"]
        }
        global {
            applicationIdSuffix ".gl"
            dimension "country"
            manifestPlaceholders = [applicationLabel: "Shorebird Example"]
        }
        local {
            applicationIdSuffix ".lcl"
            dimension "country"
            manifestPlaceholders = [applicationLabel: "Shorebird Example"]
        }
    }

With this, running shorebird release android --flavor stableGlobal generates an aab at build/app/outputs/bundle/stableGlobalRelease/app-stable-global-release.aab, but our tool fails with:

✗ Exception: Failed to extract version name from app bundle: [BT:1.15.6] Error: File '/Users/bryanoltman/shorebirdtech/samples/flavors/build/app/outputs/bundle/stableGlobalRelease/app-stableGlobal-release.aab' was not found.
java.lang.IllegalArgumentException: File '/Users/bryanoltman/shorebirdtech/samples/flavors/build/app/outputs/bundle/stableGlobalRelease/app-stableGlobal-release.aab' was not found.

Changing stable and global to stableFlavor and globalFlavor yields:

✗ Failed to build: Gradle build failed to produce an .aab file. It's likely that this file was generated under /Users/bryanoltman/shorebirdtech/samples/flavors/build, but the tool couldn't find it.

The output:

⑆ l /Users/bryanoltman/shorebirdtech/samples/flavors/build/app/outputs/bundle/stableFlavorGlobalFlavorRelease
total 50104
drwxr-xr-x@ 3 bryanoltman  staff    96B Apr 22 12:09 .
drwxr-xr-x@ 7 bryanoltman  staff   224B Apr 22 12:09 ..
-rw-r--r--@ 1 bryanoltman  staff    24M Apr 22 12:09 app-stableFlavor-globalFlavor-release.aab

Originally posted by @AbhijithKonnayil in https://github.com/shorebirdtech/shorebird/issues/515#issuecomment-2022555249

eseidel commented 8 months ago

@bryanoltman looks like this is an error in our handling of flavor names? I recall we do some camel-case to snake-case conversion that maybe gets confused here?

bryanoltman commented 7 months ago

Fixed by https://github.com/shorebirdtech/shorebird/pull/1861

eseidel commented 7 months ago

@AbhijithKonnayil we released this in 1.0.1 but ended up reverting it in 1.0.2. We'd love to work with you to figure out what the right fix is here?

bryanoltman commented 7 months ago

Reverted https://github.com/shorebirdtech/shorebird/pull/1861 due to a customer report of a camel case flavor name (retailStaging) being incorrectly converted to kebab case (retail-staging)

eseidel commented 7 months ago

I suspect we need to compare the two gradle configs that are failing (one with the patch, one without the patch) and figure out what is the right change to make to make both pass.

bryanoltman commented 7 months ago

Our previous (and now current) behavior is working using the latest Shorebird and latest version of Flutter (1.0.2 and 3.19.5, respectively). I updated our flavors example in https://github.com/shorebirdtech/samples/ to use stableFlavor as a flavor name and it was not converted to kebab case:

Your next step is to upload the app bundle to the Play Store:
/Users/bryanoltman/shorebirdtech/samples/flavors/build/app/outputs/bundle/stableFlavorRelease/app-stableFlavor-release.aab
bryanoltman commented 7 months ago

@AbhijithKonnayil I'd be curious to know

  1. Which Flutter version was used to generate the project (if you remember)
  2. If you've made any changes to your build.gradle or settings.gradle files since generating the project
  3. What shorebird doctor -v shows you.
GalacticTitan commented 7 months ago

@eseidel can we do pick first aab file that is present in that folder?. Like *.aab like that? @AbhijithKonnayil

bryanoltman commented 7 months ago

That seems sort of error-prone – what if there are multiple aabs in the directory? How would we know we're choosing the right one?

bryanoltman commented 7 months ago

What I'd really like to know is what Gradle/Flutter setting is causing the flavor names to be converted to kebab case and address that

AbhijithKonnayil commented 7 months ago

@AbhijithKonnayil I'd be curious to know

  1. Which Flutter version was used to generate the project (if you remember)
  2. If you've made any changes to your build.gradle or settings.gradle files since generating the project
  3. What shorebird doctor -v shows you.
  1. As you can see in the screenshot shared at the starting of the ticket, flutter version is 3.19.4
  2. I dont remember adding any thing else other than the product flavour config which is as follows

    
    flavorDimensions "environment", "country"

productFlavors {

    dev {
       dimension "environment"
    }
    stg {
       dimension "environment"

    }
    prod {
       dimension "environment"

    }
     india {
        applicationIdSuffix ".in"
        dimension "country"
        manifestPlaceholders += [countryCode:"in"]
        manifestPlaceholders = [autoVerifyValue: true]
    }
    global {
        applicationIdSuffix ".gl"
        dimension "country"
        manifestPlaceholders += [countryCode:"global"]
        manifestPlaceholders = [autoVerifyValue: false]
    }
    }


3. I dont have the out put of `shorebird doctor  -v` for the version when I gave the pr, here is the result of the same in `v 1.0.2` for which the the release issue exist

<img width="1210" alt="Screenshot 2024-04-22 at 12 14 23 PM" src="https://github.com/shorebirdtech/shorebird/assets/25204682/b67b4049-501c-4f2c-8ae0-cbd18be4fad7">
AbhijithKonnayil commented 7 months ago

Our previous (and now current) behavior is working using the latest Shorebird and latest version of Flutter (1.0.2 and 3.19.5, respectively). I updated our flavors example in https://github.com/shorebirdtech/samples/ to use stableFlavor as a flavor name and it was not converted to kebab case:

Your next step is to upload the app bundle to the Play Store:
/Users/bryanoltman/shorebirdtech/samples/flavors/build/app/outputs/bundle/stableFlavorRelease/app-stableFlavor-release.aab

can you share the command you used for that release

AbhijithKonnayil commented 7 months ago

Reverted #1861 due to a customer report of a camel case flavor name (retailStaging) being incorrectly converted to kebab case (retail-staging)

can you give somemore context on it, like screenshot of sample output

bryanoltman commented 7 months ago

Our previous (and now current) behavior is working using the latest Shorebird and latest version of Flutter (1.0.2 and 3.19.5, respectively). I updated our flavors example in https://github.com/shorebirdtech/samples/ to use stableFlavor as a flavor name and it was not converted to kebab case:

Your next step is to upload the app bundle to the Play Store:
/Users/bryanoltman/shorebirdtech/samples/flavors/build/app/outputs/bundle/stableFlavorRelease/app-stableFlavor-release.aab

can you share the command you used for that release

I ran shorebird release android --flavor stableFlavor

bryanoltman commented 7 months ago

@AbhijithKonnayil I'd be curious to know

  1. Which Flutter version was used to generate the project (if you remember)
  2. If you've made any changes to your build.gradle or settings.gradle files since generating the project
  3. What shorebird doctor -v shows you.
  1. As you can see in the screenshot shared at the starting of the ticket, flutter version is 3.19.4
  2. I dont remember adding any thing else other than the product flavour config which is as follows
flavorDimensions "environment", "country"

productFlavors {

       dev {
          dimension "environment"
       }
       stg {
          dimension "environment"

       }
       prod {
          dimension "environment"

       }
        india {
           applicationIdSuffix ".in"
           dimension "country"
           manifestPlaceholders += [countryCode:"in"]
           manifestPlaceholders = [autoVerifyValue: true]
       }
       global {
           applicationIdSuffix ".gl"
           dimension "country"
           manifestPlaceholders += [countryCode:"global"]
           manifestPlaceholders = [autoVerifyValue: false]
       }
       }
  1. I dont have the out put of shorebird doctor -v for the version when I gave the pr, here is the result of the same in v 1.0.2 for which the the release issue exist
Screenshot 2024-04-22 at 12 14 23 PM

Looking at this, it appears that prod and global are two different flavors. Can you share the command you ran to trigger the original issue above?

AbhijithKonnayil commented 7 months ago

@AbhijithKonnayil I'd be curious to know

  1. Which Flutter version was used to generate the project (if you remember)
  2. If you've made any changes to your build.gradle or settings.gradle files since generating the project
  3. What shorebird doctor -v shows you.
  1. As you can see in the screenshot shared at the starting of the ticket, flutter version is 3.19.4
  2. I dont remember adding any thing else other than the product flavour config which is as follows
flavorDimensions "environment", "country"

productFlavors {

       dev {
          dimension "environment"
       }
       stg {
          dimension "environment"

       }
       prod {
          dimension "environment"

       }
        india {
           applicationIdSuffix ".in"
           dimension "country"
           manifestPlaceholders += [countryCode:"in"]
           manifestPlaceholders = [autoVerifyValue: true]
       }
       global {
           applicationIdSuffix ".gl"
           dimension "country"
           manifestPlaceholders += [countryCode:"global"]
           manifestPlaceholders = [autoVerifyValue: false]
       }
       }
  1. I dont have the out put of shorebird doctor -v for the version when I gave the pr, here is the result of the same in v 1.0.2 for which the the release issue exist
Screenshot 2024-04-22 at 12 14 23 PM

Looking at this, it appears that prod and global are two different flavors. Can you share the command you ran to trigger the original issue above?

The screenshot is not uploaded properly, i guess.

The commond I used is in the screenshot shared at the starting shorebird release android --flavor prodGlobal --target lib/mains/main_prod_global.dart

bryanoltman commented 7 months ago

Oh interesting, I didn't see that you have flavors across multiple dimensions. Let me experiment with that locally and see if I can reproduce your issue.

bryanoltman commented 7 months ago

Updated the issue description. It seems like we aren't handling the multi-dimensional flavor case correctly. Will fix as soon as we can.