diff --git a/Android/src/app/build.gradle.kts b/Android/src/app/build.gradle.kts
index b051876..70b62fb 100644
--- a/Android/src/app/build.gradle.kts
+++ b/Android/src/app/build.gradle.kts
@@ -16,6 +16,8 @@
plugins {
alias(libs.plugins.android.application)
+ // Note: set apply to true to enable google-services (requires google-services.json).
+ alias(libs.plugins.google.services) apply false
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.kotlin.serialization)
@@ -95,6 +97,8 @@ dependencies {
implementation(libs.protobuf.javalite)
implementation(libs.hilt.android)
implementation(libs.hilt.navigation.compose)
+ implementation(platform(libs.firebase.bom))
+ implementation(libs.firebase.analytics)
kapt(libs.hilt.android.compiler)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
diff --git a/Android/src/app/src/main/AndroidManifest.xml b/Android/src/app/src/main/AndroidManifest.xml
index 6bacbd3..b4218ac 100644
--- a/Android/src/app/src/main/AndroidManifest.xml
+++ b/Android/src/app/src/main/AndroidManifest.xml
@@ -31,6 +31,7 @@
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/Android/src/app/src/main/java/com/google/ai/edge/gallery/GalleryApplication.kt b/Android/src/app/src/main/java/com/google/ai/edge/gallery/GalleryApplication.kt
index 1574f0b..f19d9ec 100644
--- a/Android/src/app/src/main/java/com/google/ai/edge/gallery/GalleryApplication.kt
+++ b/Android/src/app/src/main/java/com/google/ai/edge/gallery/GalleryApplication.kt
@@ -20,6 +20,7 @@ import android.app.Application
import com.google.ai.edge.gallery.common.writeLaunchInfo
import com.google.ai.edge.gallery.data.DataStoreRepository
import com.google.ai.edge.gallery.ui.theme.ThemeSettings
+import com.google.firebase.FirebaseApp
import dagger.hilt.android.HiltAndroidApp
import javax.inject.Inject
@@ -35,5 +36,7 @@ class GalleryApplication : Application() {
// Load saved theme.
ThemeSettings.themeOverride.value = dataStoreRepository.readTheme()
+
+ FirebaseApp.initializeApp(this)
}
}
diff --git a/Android/src/app/src/main/java/com/google/ai/edge/gallery/MainActivity.kt b/Android/src/app/src/main/java/com/google/ai/edge/gallery/MainActivity.kt
index cd3c9ea..b923c4f 100644
--- a/Android/src/app/src/main/java/com/google/ai/edge/gallery/MainActivity.kt
+++ b/Android/src/app/src/main/java/com/google/ai/edge/gallery/MainActivity.kt
@@ -18,6 +18,7 @@ package com.google.ai.edge.gallery
import android.os.Build
import android.os.Bundle
+import android.util.Log
import android.view.WindowManager
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
@@ -27,12 +28,26 @@ import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.google.ai.edge.gallery.ui.theme.GalleryTheme
+import com.google.firebase.analytics.FirebaseAnalytics
+import com.google.firebase.analytics.ktx.analytics
+import com.google.firebase.ktx.Firebase
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
+ private var firebaseAnalytics: FirebaseAnalytics? = null
+
override fun onCreate(savedInstanceState: Bundle?) {
+ firebaseAnalytics =
+ runCatching { Firebase.analytics }
+ .onFailure { exception ->
+ // Firebase.analytics can throw an exception if goolgle-services is not set up, e.g.,
+ // missing google-services.json.
+ Log.w(TAG, "Firebase Analytics is not available", exception)
+ }
+ .getOrNull()
+
installSplashScreen()
super.onCreate(savedInstanceState)
@@ -46,4 +61,8 @@ class MainActivity : ComponentActivity() {
// Keep the screen on while the app is running for better demo experience.
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}
+
+ companion object {
+ private const val TAG = "AGMainActivity"
+ }
}
diff --git a/Android/src/build.gradle.kts b/Android/src/build.gradle.kts
index fe99361..072ce67 100644
--- a/Android/src/build.gradle.kts
+++ b/Android/src/build.gradle.kts
@@ -17,6 +17,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
+ alias(libs.plugins.google.services) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.compose) apply false
alias(libs.plugins.hilt.application) apply false
diff --git a/Android/src/gradle/libs.versions.toml b/Android/src/gradle/libs.versions.toml
index 57b3aa1..10dd2e5 100644
--- a/Android/src/gradle/libs.versions.toml
+++ b/Android/src/gradle/libs.versions.toml
@@ -31,6 +31,8 @@ netOpenidAppauth = "0.11.1"
splashscreen = "1.2.0-beta01"
hilt = "2.56.2"
hiltNavigation = "1.2.0"
+googleService = "4.4.3"
+firebaseBom = "33.16.0"
[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -73,6 +75,10 @@ hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt"
hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "hiltNavigation" }
hilt-android-testing = { module = "com.google.dagger:hilt-android-testing", version.ref = "hilt" }
hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt" }
+firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebaseBom" }
+# When using the Firebase BoM, you don't specify versions in Firebase
+# library dependencies.
+firebase-analytics = { group = "com.google.firebase", name = "firebase-analytics" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
@@ -81,3 +87,4 @@ kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "ko
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "serializationPlugin" }
protobuf = {id = "com.google.protobuf", version.ref = "protobuf"}
hilt-application = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
+google-services = { id = "com.google.gms.google-services", version.ref = "googleService" }
\ No newline at end of file