skip to Main Content

I’m new to React Native and Firebase and decided to improve my knowledge in this regard, I read some articles on interaction and how to connect one to the other, but I can’t figure out how to split my app in firebase into dev and prod, because for deva, I want to use collections and logging auth ticks of what I use in development, and when compiling in prod I already used a real collection.

I thought that it could be arranged according to the type of prefixes:

  • [Prod] My App
  • [Dev] My App

But I see that firebase does not allow me to create another app with the same "Android package name" and, accordingly, I need different SHA1 signatures according to debug.keystore and my [release].keystore, what should I do with this? Can you point me in the right direction, what to look at, what to read to understand this issue, because for the most part what I found is 80% water and 20% what I know myself, but it still does not answer my questions how to be with such separation and how it should behave.

2

Answers


  1. You do not need 2 Google files, one can also work here.

    Example:

    Create Development and Staging folders inside Android/app/src and put your JSON file there

    enter image description here

    Add envConfigFiles inside android/app/build.gradle

    project.ext.envConfigFiles = [Development: "../../.env.Development",
                                  Staging    : "../../.env.Staging",
                                  Production : "../../.env.Production"]
    

    enter image description here

    Add resValue in defaultConfig resValue "string", "build_config_package", "com.package"

    Add flavorDimensions, signingConfigs and productFlavors above buildTypes

     flavorDimensions "default"
        signingConfigs {
            development {
                storeFile file("../keystore/zypeDevKeyStore")
                storePassword System.getenv("STORE_PASSWORD")
                keyAlias System.getenv("KEY_ALIAS")
                keyPassword System.getenv("KEY_PASSWORD")
            }
            staging {
                storeFile file("../keystore/zypeStgKeyStore")
                storePassword System.getenv("STORE_PASSWORD")
                keyAlias System.getenv("KEY_ALIAS")
                keyPassword System.getenv("KEY_PASSWORD")
            }
            production {
                storeFile file("../keystore/zypeKeyStore")
                storePassword System.getenv("STORE_PASSWORD")
                keyAlias System.getenv("KEY_ALIAS")
                keyPassword System.getenv("KEY_PASSWORD")
            }
        }
        productFlavors {
            Development {}
            Staging {}
            Production {}
        }
    

    enter image description here

    Add these codes inside buildTypes

      debug {
                productFlavors.Development.signingConfig signingConfigs.development
                productFlavors.Staging.signingConfig signingConfigs.staging
                productFlavors.Production.signingConfig signingConfigs.production
            }
    
    Login or Signup to reply.
  2. You do not need 2 Google files, one can also work here.

    Example:

    Create Development and Staging folders inside Android/app/src and put your JSON file there

    enter image description here

    Add envConfigFiles inside android/app/build.gradle

    project.ext.envConfigFiles = [Development: "../../.env.Development",
                                  Staging    : "../../.env.Staging",
                                  Production : "../../.env.Production"]
    

    enter image description here

    Add resValue in defaultConfig resValue "string", "build_config_package", "com.package"

    Add flavorDimensions, signingConfigs and productFlavors above buildTypes

     flavorDimensions "default"
        signingConfigs {
            development {
                storeFile file("../keystore/KeyStore")
                storePassword System.getenv("STORE_PASSWORD")
                keyAlias System.getenv("KEY_ALIAS")
                keyPassword System.getenv("KEY_PASSWORD")
            }
            staging {
                storeFile file("../keystore/KeyStore")
                storePassword System.getenv("STORE_PASSWORD")
                keyAlias System.getenv("KEY_ALIAS")
                keyPassword System.getenv("KEY_PASSWORD")
            }
            production {
                storeFile file("../keystore/KeyStore")
                storePassword System.getenv("STORE_PASSWORD")
                keyAlias System.getenv("KEY_ALIAS")
                keyPassword System.getenv("KEY_PASSWORD")
            }
        }
        productFlavors {
            Development {}
            Staging {}
            Production {}
        }
    

    enter image description here

    Add these codes inside buildTypes

      debug {
                productFlavors.Development.signingConfig signingConfigs.development
                productFlavors.Staging.signingConfig signingConfigs.staging
                productFlavors.Production.signingConfig signingConfigs.production
    

    after all of these use the below command to build

       "android": "npx nx run-android zype-mobile --mode=StagingDebug",
       "android-prod": "npx nx run-android zype-mobile --mode=ProductionDebug",
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search