Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
cordova-android-7.0.0
-
None
-
Important
Description
I am a full-time plugin developer. Like many other plugins, I import Google Play Services dependencies in addition to Android Support libraries (appcompat-v7).
By far the biggest problem I encounter with my users is Gradle conflicts due to multiple plugins importing different versions of play-services / Firebase / com.android.support libraries.
Many plugin authors do the wrong thing and simply use version ":+", eg: cordova-plugin-firebase].
Quite often, my solution for these users is to edit platforms/android/project.properties, which is not the best long-term solution, since this file is volatile.
What I've been doing since cordova@7.1.0 is expose custom config properties in my plugins' plugin.xml. This is nice, but users must align their google-play / Firebase / Support dependencies for each plugin that exposes these helpful properties (and not many plugins do).
What would really help, is if cordova-android could expose variables in the app's config.xml in the same manner as:
- cdvCompileSdkVersion
- cdvBuildToolsVersion
- cdvMinSdkVersion
I would like to see the following properties added:
- cdvGooglePlayServicesVersion
- cdvSupportLibVersion
(Note: cdvGooglePlayServicesVersion could be named cdvGoogleApiVersion as a more common name, since both Firebase and Google Play Services dependencies must be aligned to the same version.)
I would like to be able to access these properties in my plugin's plugin.xml here] instead of using my plugin's custom $GOOGLE_API_VERSION variable.
In a React Native app, which provides direct control over one's top-level build.gradle, we do it like this]. 3rd-party plugins then check for the existence of these Gradle Config Properties when importing their Google dependencies, like this.
This technique is also recommend at android.developer.com in the document Gradle Tips and Tricks (search "project-wide properties")