Coder Social home page Coder Social logo

Product Flavors | Value null for applicationId in defaultConfig (works without flavors implementation) about react-native-ultimate-config HOT 6 OPEN

maxkomarychev avatar maxkomarychev commented on May 28, 2024 3
Product Flavors | Value null for applicationId in defaultConfig (works without flavors implementation)

from react-native-ultimate-config.

Comments (6)

pcaro10 avatar pcaro10 commented on May 28, 2024 2

@wkoutre thanks! I will try

from react-native-ultimate-config.

pcaro10 avatar pcaro10 commented on May 28, 2024

@wkoutre any update?

from react-native-ultimate-config.

wkoutre avatar wkoutre commented on May 28, 2024

@pcaro10 I haven't heard anything about this one, no, nor have I looked into it further.

In the production apps I manage, I've just been using the workaround I've mentioned above:

If I remove project.ext.flavorEnvMapping, run yarn rnuc env.staging.yaml, then run react-native run-android --variant devDebug (or cd android; ./gradlew assembleDevDebug), everything works perfectly without any other changes.

from react-native-ultimate-config.

tehong avatar tehong commented on May 28, 2024

I am having the same problem and tried various steps with no avail. I had to run the yarn rnuc .env.staging.yaml first.

from react-native-ultimate-config.

samermurad avatar samermurad commented on May 28, 2024

I had a similar issue, but for me I needed to adjust the android versionCode dynamically based on the flavor (dev / prod).

I have two yaml files, which are setup in the following way:

project.ext.flavorEnvMapping = [
        prod: "../.env.prod.yaml",
        staging: "../.env.staging.yaml",
]

and I attempted to do something like the following:

defaultConfig {
        applicationId <MY_APP_ID>
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode project.config.get("APP_BUILD_NUMBER")
        versionName project.config.get("APP_VERSION")
    }

This however, failed when created an app bundle, with the error: "Version code not found in manifest".
Apparently, project.config.get is null, and both APP_BUILD_NUMBER and APP_VERSION came back as null as well (Obviously).

I traced the code back to "../../node_modules/react-native-ultimate-config/android/rnuc.gradle".
There, you can see that at the end of the script, the following is being done: project.ext.set("config", rootConfig).

rootConfig is a map containing all the flavors with all their keys.

I went on to print it, inside defaultConfig like so:

defaultConfig {
       println "MY CONFIG ${project.config}"
        applicationId <MY_APP_ID>
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode project.config.get("APP_BUILD_NUMBER")
        versionName project.config.get("APP_VERSION")
    }

The result looked like so:

MY CONFIG [prod:[BASE_URL:<OMITTED>, IS_PROD:true, ENVIRONMENT:production, TARGET_NAME:<OMITTED>, APP_NAME:<OMITTED>, APP_BUILD_NUMBER:36, APP_VERSION:1.1.3], staging:[BASE_URL:<OMITTED> IS_PROD:false, ENVIRONMENT:staging, TARGET_NAME:<OMITTED>, APP_NAME:<OMITTED>, APP_BUILD_NUMBER:40, APP_VERSION:1.2.0]]

so the project.config is just a dictionary containing the values per flavor.

My end working solution now looks like this:

productFlavors {
        prod {
            applicationId <PROD_BUNDLE_ID>
            versionName project.config.prod.APP_VERION
            versionCode project.config.prod.APP_BUILD_NUMBER
        }
        staging {
            applicationId <STAGING_BUNDLE_ID>
            versionName project.config.staging.APP_VERION
            versionCode project.config.staging.APP_BUILD_NUMBER
        }
    }

Granted, this is not Ideal, but it works, and achieves the needed result.

I hope this helps someone.

Although it is kind of a bug to be honest, I would've expected the lib to deliver these values automatically

from react-native-ultimate-config.

gtfunes avatar gtfunes commented on May 28, 2024

I had the same issue when trying to set applicationId with flavors. This is what I ended up doing:

productFlavors {
  dev {

  }
  production {

  }
  all { flavor ->
    applicationId project.ext.config.get(flavor.name).get("APP_ID")
  }
}

from react-native-ultimate-config.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.