AngeloAvv / flutter_flavorizr

A flutter utility to easily create flavors in your flutter application
https://pub.dev/packages/flutter_flavorizr
MIT License
456 stars 81 forks source link

The following fields are null or undefined: [firebase] #258

Closed vaibhavaroraneo closed 4 months ago

vaibhavaroraneo commented 4 months ago

I've added firebase to the project having 3 flavors. Now upon running flutter pub run flutter_flavorizr there appears an error that The following fields are null or undefined: [firebase]. Read the docs for further details.

The exact message received is

Deprecated. Use `dart run` instead.
Building package executable... 
Built flutter_flavorizr:flutter_flavorizr.
The following fields are null or undefined: [firebase]. Read the docs for further details

The flavor code added is

flavorizr:
  app:
    android:
      flavorDimensions: "app_flavor"

  flavors:
    staging:
      app:
        name: " Staging"
      android:
        applicationId: "com.app.staging"
        firebase:
        config: "android/app/src/staging/google-services.json"
      ios:
        bundleId: "com.app.staging"
        firebase:
        config: "ios/config/staging/GoogleService-Info.plist"

    preprod:
      app:
        name: "PreProd"
      android:
        applicationId: "com.app.preprod"
        firebase:
        config: "android/app/src/preprod/google-services.json"
      ios:
        bundleId: "com.app.preprod"
        firebase:
        config: "ios/config/preprod/GoogleService-Info.plist"

    prod:
      app:
        name: "Prod"
      android:
        applicationId: "com.app.live"
        firebase:
        config: "android/app/src/prod/google-services.json"
      ios:
        bundleId: "com.app.live"
        firebase:
        config: "ios/config/prod/GoogleService-Info.plist"

Google-service files for android are present in 3 directories staging prepared prod created in android > app > src > staging/preprod/prod

Google service files for iOS are present in 3 directories staging prepared prod created in ios > config >staging/preprod/prod

@AngeloAvv please help out what is being missed out.

AngeloAvv commented 4 months ago

The problem is related to the firebase config definition which is not properly indented:

flavorizr:
  app:
    android:
      flavorDimensions: "app_flavor"

  flavors:
    staging:
      app:
        name: " Staging"
      android:
        applicationId: "com.app.staging"
        firebase:
          config: "android/app/src/staging/google-services.json"
      ios:
        bundleId: "com.app.staging"
        firebase:
          config: "ios/config/staging/GoogleService-Info.plist"

    preprod:
      app:
        name: "PreProd"
      android:
        applicationId: "com.app.preprod"
        firebase:
          config: "android/app/src/preprod/google-services.json"
      ios:
        bundleId: "com.app.preprod"
        firebase:
          config: "ios/config/preprod/GoogleService-Info.plist"

    prod:
      app:
        name: "Prod"
      android:
        applicationId: "com.app.live"
        firebase:
          config: "android/app/src/prod/google-services.json"
      ios:
        bundleId: "com.app.live"
        firebase:
          config: "ios/config/prod/GoogleService-Info.plist"

I also suggest changing the config path of your firebase files because they will be overwritten over and over if you're using the same path as the destination path.

vaibhavaroraneo commented 4 months ago

@AngeloAvv thanks for the quick response.

flavorizr:
  app:
    android:
      flavorDimensions: "neozap_flavor"

  flavors:
    staging:
      app:
        name: "NeoZAP Staging"
      android:
        applicationId: "com.neozap.staging"
        firebase:
          config: "android/app/src/staging/google-services.json"
      ios:
        bundleId: "com.neozap.staging"
        firebase:
          config: "ios/runner/staging/GoogleService-Info.plist"

    preprod:
      app:
        name: "NeoZAP PreProd"
      android:
        applicationId: "com.neozap.preprod"
        firebase:
          config: "android/app/src/preprod/google-services.json"
      ios:
        bundleId: "com.neozap.preprod"
        firebase:
          config: "ios/runner/preprod/GoogleService-Info.plist"

    prod:
      app:
        name: "NeoZAP"
      android:
        applicationId: "com.neozap.live"
        firebase:
          config: "android/app/src/prod/google-services.json"
      ios:
        bundleId: "com.neozap.live"
        firebase:
          config: "ios/runner/prod/GoogleService-Info.plist"

this is updated path that I've set for the firebase files. I am facing a strange issue of app crashes on iOS for staging and preprod. Only prod is getting run for simulators and devices. the error received is

Terminating app due to uncaught exception 'com.firebase.core', reason: 'App name can only contain alphanumeric, hyphen (-), and underscore (_) characters'

The firebase files are updated with the names. but somehow its getting crashed stating the same error.

Is there anything that I'm missing out?

AngeloAvv commented 4 months ago

Closing as you're requesting help for a different subject