A fully functional Android app built entirely with Kotlin and Jetpack Compose
Use flavor and buildType to properly define package name
Tomáš Mlynariče63586d4d937
diff --git a/benchmark/build.gradle.kts b/benchmark/build.gradle.ktsindex f59e32dd3..fab2055e7 100644--- a/benchmark/build.gradle.kts+++ b/benchmark/build.gradle.kts@@ -13,6 +13,9 @@* See the License for the specific language governing permissions and* limitations under the License.*/+import com.google.samples.apps.nowinandroid.Flavor+import com.google.samples.apps.nowinandroid.FlavorDimension+import com.google.samples.apps.nowinandroid.configureFlavorsplugins {id("nowinandroid.android.test")@@ -25,7 +28,6 @@ android {defaultConfig {minSdk = 23testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"- missingDimensionStrategy("contentType", "demo")}buildTypes {@@ -40,6 +42,11 @@ android {}}+ // Use the same flavor dimensions as the application to allow generating Baseline Profiles on prod,+ // which is more close to what will be shipped to users (no fake data), but has ability to run the+ // benchmarks on demo, so we benchmark on stable data.+ configureFlavors(this)+targetProjectPath = ":app"experimentalProperties["android.experimental.self-instrumenting"] = true}diff --git a/benchmark/src/main/java/com/google/samples/apps/nowinandroid/Utils.kt b/benchmark/src/main/java/com/google/samples/apps/nowinandroid/Utils.ktnew file mode 100644index 000000000..5db7b5c91--- /dev/null+++ b/benchmark/src/main/java/com/google/samples/apps/nowinandroid/Utils.kt@@ -0,0 +1,25 @@+/*+ * 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.+ */++package com.google.samples.apps.nowinandroid++import com.google.samples.apps.nowinandroid.benchmark.BuildConfig++/**+ * Convenience parameter to use proper package name with regards to build type and build flavor.+ */+const val PACKAGE_NAME =+ "com.google.samples.apps.nowinandroid.${BuildConfig.FLAVOR}.${BuildConfig.BUILD_TYPE}"diff --git a/benchmark/src/main/java/com/google/samples/apps/nowinandroid/baselineprofile/BaselineProfileGenerator.kt b/benchmark/src/main/java/com/google/samples/apps/nowinandroid/baselineprofile/BaselineProfileGenerator.ktindex 2fdc28bad..450524cc2 100644--- a/benchmark/src/main/java/com/google/samples/apps/nowinandroid/baselineprofile/BaselineProfileGenerator.kt+++ b/benchmark/src/main/java/com/google/samples/apps/nowinandroid/baselineprofile/BaselineProfileGenerator.kt@@ -20,6 +20,7 @@ import androidx.benchmark.macro.ExperimentalBaselineProfilesApiimport androidx.benchmark.macro.junit4.BaselineProfileRuleimport androidx.test.uiautomator.Byimport androidx.test.uiautomator.Direction+import com.google.samples.apps.nowinandroid.PACKAGE_NAMEimport org.junit.Ruleimport org.junit.Test@@ -32,9 +33,7 @@ class BaselineProfileGenerator {@Testfun startup() =- baselineProfileRule.collectBaselineProfile(- packageName = "com.google.samples.apps.nowinandroid.demo.benchmark"- ) {+ baselineProfileRule.collectBaselineProfile(PACKAGE_NAME) {pressHome()// This block defines the app's critical user journey. Here we are interested in// optimizing for app startup. But you can also navigate and scrolldiff --git a/benchmark/src/main/java/com/google/samples/apps/nowinandroid/startup/StartupBenchmark.kt b/benchmark/src/main/java/com/google/samples/apps/nowinandroid/startup/StartupBenchmark.ktindex 49194ed4c..b33acacc7 100644--- a/benchmark/src/main/java/com/google/samples/apps/nowinandroid/startup/StartupBenchmark.kt+++ b/benchmark/src/main/java/com/google/samples/apps/nowinandroid/startup/StartupBenchmark.kt@@ -26,6 +26,7 @@ import androidx.benchmark.macro.StartupMode.WARMimport androidx.benchmark.macro.StartupTimingMetricimport androidx.benchmark.macro.junit4.MacrobenchmarkRuleimport androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner+import com.google.samples.apps.nowinandroid.PACKAGE_NAMEimport org.junit.Ruleimport org.junit.Testimport org.junit.runner.RunWith@@ -74,7 +75,7 @@ abstract class AbstractStartupBenchmark(private val startupMode: StartupMode) {fun startupFullCompilation() = startup(CompilationMode.Full())private fun startup(compilationMode: CompilationMode) = benchmarkRule.measureRepeated(- packageName = "com.google.samples.apps.nowinandroid",+ packageName = PACKAGE_NAME,metrics = listOf(StartupTimingMetric()),compilationMode = compilationMode,iterations = 10,