An Android application showcasing the implementation of Firebase features using Clean Architecture and MVVM design pattern.
Dark Mode (Emulator) | Light Mode (Real Device) |
---|---|
- Firebase Authentication: Implementing user authentication using Firebase Authentication [Google Sign and Anonymous].
Google SignIn/SignUp | Profile Screen | Anonymous SignIn (Skip) |
---|---|---|
- Remote Config: Dynamic app configuration using Firebase Remote Config.
Remote Config (Dark) | Remote Config (Light) |
---|---|
The project follows the Clean Architecture principles and MVVM design pattern. It is structured into multiple layers:
- Presentation: Contains UI (view) components and ViewModels.
- Domain: Holds business logic and use case implementations.
- Data: Manages data sources, repositories, and interacts with external APIs (Firebase in this case).
Before building and running the project, you need to set up your Firebase project:
- Create a new project on the Firebase Console.
- Add your Android app to the project and download the
google-services.json
file. - Place the
google-services.json
file in theapp
module of your project.
- Open Android Studio.
- Click on the "Gradle" tab on the right side.
- Navigate to
Your App -> Tasks -> android -> signingReport
. - Run
signingReport
. The SHA-1 fingerprint will be displayed in the "Run" tab at the bottom.
- Go to the Firebase Console. Open your Firebase project.
- Navigate to "Authentication" in the left-hand menu.
- Go to the "Sign-in method" tab.
- Enable "Google" and "Anonymous" as a sign-in provider.
- In the "Web client ID" section, copy the client id.
- In the "Project settings" page, navigate to the "General" tab.
- In the "SHA certificate fingerprints" section, click on "Add fingerprint." and save the changes.
- Create a file called
apiKeys.properties
in root directory.
WEB_CLIENT_ID = "9...435.apps.googleusercontent.com"
-
In
build.gradle.kts
(module)android { val apikeyPropertiesFile = rootProject.file("apiKeys.properties") val apikeyProperties = Properties() /** Just use it here or separately in release and debug buildtypes. **/ defaultConfig { buildConfigField("String", "WEB_CLIENT_ID", apikeyProperties["WEB_CLIENT_ID"].toString() ) } buildTypes { degug { // Build Config field } release { // Build Config field } } buildFeatures { compose = true buildConfig = true } }
- In Firebase console navigate to Remote Config dashboard. Click on "Add Parameter" to define a new parameter.
- Configure the parameter with a key, default value, and optional description.
- After setting up parameters, click on "Publish Changes" to make them live.
- You can provide default values for Firebase Remote Config in Android Studio either using an XML file (R.xml) or directly in Kotlin code.
- For Sample JSON data Click here
-
Create an XML file in the
res/xml
directory, e.g.,remote_config_defaults.xml
:<!-- res/xml/remote_config_defaults.xml --> <defaultsMap> <entry> <key>your_parameter_key</key> <value>default_value</value> </entry> </defaultsMap>
-
In your Kotlin code, set the default values using the resource ID:
val defaultResId = R.xml.remote_config_defaults firebaseRemoteConfig.setDefaultsAsync(defaultResId)
val firebaseRemoteConfig = FirebaseRemoteConfig.getInstance()
val configSettings = FirebaseRemoteConfigSettings.Builder()
.setMinimumFetchIntervalInSeconds(3600) // 1 hour
.build()
firebaseRemoteConfig.setConfigSettingsAsync(configSettings)
// Set default values directly in Kotlin
firebaseRemoteConfig.setDefaultsAsync(
mapOf(
"your_parameter_key" to "default_value",
// Add more entries as needed
)
)
Feel free to contribute to this project by opening issues, providing feedback, or submitting pull requests. Your contributions are highly appreciated.