A fully functional Android app built entirely with Kotlin and Jetpack Compose
Add Firebase dependencies
Ben Weissf316be1d692f
diff --git a/app/build.gradle.kts b/app/build.gradle.ktsindex 3cc48f284..09efa62fd 100644--- a/app/build.gradle.kts+++ b/app/build.gradle.kts@@ -20,8 +20,8 @@ plugins {id("nowinandroid.android.application.compose")id("nowinandroid.android.application.jacoco")id("nowinandroid.android.hilt")+ id("nowinandroid.firebase")id("jacoco")- id("nowinandroid.firebase-perf")}android {diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.ktsindex 453085807..d1f3b3ab9 100644--- a/build-logic/convention/build.gradle.kts+++ b/build-logic/convention/build.gradle.kts@@ -68,9 +68,9 @@ gradlePlugin {id = "nowinandroid.android.hilt"implementationClass = "AndroidHiltConventionPlugin"}- register("firebase-perf") {- id = "nowinandroid.firebase-perf"- implementationClass = "FirebasePerfConventionPlugin"+ register("firebase") {+ id = "nowinandroid.firebase"+ implementationClass = "FirebaseConventionPlugin"}}}diff --git a/build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.ktindex 772064942..29cb748c2 100644--- a/build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.kt+++ b/build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.kt@@ -14,14 +14,11 @@* limitations under the License.*/-import com.android.build.api.variant.LibraryAndroidComponentsExtension-import com.google.samples.apps.nowinandroid.configureJacocoimport org.gradle.api.Pluginimport org.gradle.api.Projectimport org.gradle.api.artifacts.VersionCatalogsExtensionimport org.gradle.kotlin.dsl.dependenciesimport org.gradle.kotlin.dsl.getByType-import org.gradle.kotlin.dsl.kotlinclass AndroidHiltConventionPlugin : Plugin<Project> {override fun apply(target: Project) {diff --git a/build-logic/convention/src/main/kotlin/FirebaseConventionPlugin.kt b/build-logic/convention/src/main/kotlin/FirebaseConventionPlugin.ktnew file mode 100644index 000000000..70054408d--- /dev/null+++ b/build-logic/convention/src/main/kotlin/FirebaseConventionPlugin.kt@@ -0,0 +1,45 @@+/*+ * Copyright 2022 The Android Open Source Project+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * https://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import org.gradle.api.Plugin+import org.gradle.api.Project+import org.gradle.api.artifacts.VersionCatalogsExtension+import org.gradle.kotlin.dsl.dependencies+import org.gradle.kotlin.dsl.getByType++class FirebaseConventionPlugin : Plugin<Project> {+ override fun apply(target: Project) {+ // Only apply this to Google Play releases.+ if (!target.hasProperty("use-google-services"))+ return+ with(target) {+ with(pluginManager) {+ apply("com.google.gms.google-services")+ apply("com.google.firebase.firebase-perf")+ apply("com.google.firebase.crashlytics")+ }++ val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")+ dependencies {+ val bom = libs.findLibrary("firebase-bom").get()+ add("releaseImplementation", platform(bom))+ "releaseImplementation"(libs.findLibrary("firebase.analytics").get())+ "releaseImplementation"(libs.findLibrary("firebase.crashlytics").get())+ "releaseImplementation"(libs.findLibrary("firebase.performance").get())+ }+ }+ }+}diff --git a/build-logic/convention/src/main/kotlin/FirebasePerfConventionPlugin.kt b/build-logic/convention/src/main/kotlin/FirebasePerfConventionPlugin.ktdeleted file mode 100644index 48f750678..000000000--- a/build-logic/convention/src/main/kotlin/FirebasePerfConventionPlugin.kt+++ /dev/null@@ -1,29 +0,0 @@-/*- * Copyright 2022 The Android Open Source Project- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * https://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--import org.gradle.api.Plugin-import org.gradle.api.Project--class FirebasePerfConventionPlugin : Plugin<Project> {- override fun apply(target: Project) {- with(target) {- pluginManager.findPlugin("com.google.firebase.firebase-perf").apply {- version = "1.4.1"- }- }- }--}\ No newline at end of filediff --git a/build.gradle.kts b/build.gradle.ktsindex 6f6d375d7..bd395ceac 100644--- a/build.gradle.kts+++ b/build.gradle.kts@@ -23,12 +23,21 @@ buildscript {maven { url = uri("../nowinandroid-prebuilts/m2repository") }}+ dependencies {+ if (project.hasProperty("use-google-services")) {+ classpath(libs.firebase.crashlytics.gradle)+ }+ }}+// Lists all plugins used throughout the project without applying them.plugins {alias(libs.plugins.android.application) apply falsealias(libs.plugins.kotlin.jvm) apply falsealias(libs.plugins.kotlin.serialization) apply false+ alias(libs.plugins.firebase.crashlytics) apply false+ alias(libs.plugins.firebase.perf) apply false+ alias(libs.plugins.gms) apply falsealias(libs.plugins.hilt) apply falsealias(libs.plugins.secrets) apply false}\ No newline at end of filediff --git a/gradle/libs.versions.toml b/gradle/libs.versions.tomlindex 887769cbf..4d6b694cc 100644--- a/gradle/libs.versions.toml+++ b/gradle/libs.versions.toml@@ -28,6 +28,10 @@ androidxUiAutomator = "2.2.0"androidxWindowManager = "1.0.0"androidxWork = "2.7.1"coil = "2.2.2"+firebaseBom = "31.0.3"+firebaseCrashlyticsPlugin = "2.9.2"+firebasePerfPlugin = "1.4.2"+gmsPlugin = "4.3.14"hilt = "2.44.2"hiltExt = "1.0.0"jacoco = "0.8.7"@@ -96,6 +100,11 @@ androidx-work-testing = { group = "androidx.work", name = "work-testing", versiocoil-kt = { group = "io.coil-kt", name = "coil", version.ref = "coil" }coil-kt-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil" }coil-kt-svg = { group = "io.coil-kt", name = "coil-svg", version.ref = "coil" }+firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref="firebaseBom"}+firebase-analytics = { group = "com.google.firebase", name = "firebase-analytics-ktx"}+firebase-crashlytics = { group = "com.google.firebase", name = "firebase-crashlytics-ktx"}+firebase-crashlytics-gradle = { group = "com.google.firebase", name="firebase-crashlytics-gradle", version.ref = "firebaseCrashlyticsPlugin"}+firebase-performance = { group = "com.google.firebase", name = "firebase-perf-ktx"}hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }hilt-android-testing = { group = "com.google.dagger", name = "hilt-android-testing", version.ref = "hilt" }hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" }@@ -126,6 +135,9 @@ kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plandroid-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }android-test = { id = "com.android.test", version.ref = "androidGradlePlugin" }+firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebaseCrashlyticsPlugin"}+firebase-perf = { id = "com.google.firebase.firebase-perf", version.ref = "firebasePerfPlugin"}+gms = { id = "com.google.gms.google-services", version.ref = "gmsPlugin"}hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }