Short question:
How can I change the package name for debug or release build type in a library module?
Context:
In an Android project with MVP + Clean architecture, we have the repository pattern in a library module. We want to include Firebase on that library with two environments (development and production).
I already created the project in Firebase (com.example.com
and com.example.com.dev
) and then downloaded the respective google-services.json
to src/main and src/debug folders.
Gradle google-services plugin validates the module package name with the client ID defined in the google-services.json, but Android restrict to change the applicationId
in a library (I can't find the technical reason why)
Things that I tried:
- Have two AndroidManifest.xml with different package property.
com.example.com
in the src/main andcom.example.com.dev
in src/debug/ but the second one it is just ignored - Set
manifest.srcFile
in Gradle sourceSets. The file is in the list when I run./gradlew sourceSets
but the package name doesn't change - Two different flavors in the library module and set different manifests for each one. The package anyway doesn't change.
At this moment I have just two suitable solutions: 1. Keep the Firebase setup and implementation in the app module outside of the repository. 2. Have only one environment for Firebase.
Thanks a lot for any help or advice.
EDIT:
Consider that I need to modify the package in a module (library), not in the app. For some weird reason Gradle shows this error when I try to use applicationIdSuffix
or applicationId
in a module:
ERROR: Library projects cannot set applicationIdSuffix.