How is variables.gradle generated?

Hello,

I currently have this variables.gradle file generated when I perform npx cap add android

ext {
    minSdkVersion = 22
    compileSdkVersion = 33
    targetSdkVersion = 33
    androidxActivityVersion = '1.7.0'
    androidxAppCompatVersion = '1.6.1'
    androidxCoordinatorLayoutVersion = '1.2.0'
    androidxCoreVersion = '1.10.0'
    androidxFragmentVersion = '1.5.6'
    coreSplashScreenVersion = '1.0.0'
    androidxWebkitVersion = '1.6.1'
    junitVersion = '4.13.2'
    androidxJunitVersion = '1.1.5'
    androidxEspressoCoreVersion = '3.5.1'
    cordovaAndroidVersion = '10.1.1'
}

But for example I am using these two capacitor plugins @capacitor/Push-Notifications and @capacitor/Camera in which they have a section variables where it says that it will use these in the variables.gradle:

    firebaseMessagingVersion = '23.3.1'
    androidxExifInterfaceVersion='1.3.6'
    androidxMaterialVersion='1.10.0'

My question is that are these variables supposed to be generated automatically if you’re using the plugin or I need to add it on my own? Or are these variables optional where you defined to select the version you want to use, and if not used, i will use the default?

The file is generated when you run npx cap add android, but it only includes the variables that Capacitor itself uses.

You don’t really need to add those variables, the plugins document the name of the variables they use and the default version you use, so you only need to add the variable to the variables.gradle if you want to set it to a different version, in example if you have another plugin with the same variable but with a different default value which makes them to conflict.

It looks like you are using Capacitor 5, so you should be using version 5.x of the Capacitor plugins, which have different variables versions than the ones you mentioned.

In example push notifications plugin on version 5.x uses firebaseMessagingVersion 23.1.2

Alright thank you! That’s what I thought but I wanted to confirm.