android / codelab-android-performance

Apache License 2.0
21 stars 10 forks source link

Questions about New Module by Baseline Profile Generator on Android Studio Iguana #25

Open Kane-Shih opened 5 months ago

Kane-Shih commented 5 months ago

Env:

Non-Bundled Plugins: com.github.copilot (1.5.1.5285)


- Project

AGP 8.2.0 Gradle 8.2 Kotlin 1.9.20 BaselineProfile 1.2.3 profileInstaller 1.3.1

modules: app, total: 1


## Question 1
(1) My app has 3 build types and 3 product flavors, thus there're 9 build variants.

build types: debug, internal, release product flavors(region): us, eu, tw; Each of them has an unique application ID.



(2) My app uses plugin `com.google.gms.google-services` so there're 9 `google-play-services.json` files for each variant.

(3) After created a new baselineprofile module by Baseline Profile Generator on Android Studio Iguana (to `:app:baselineprofile`), it added `NonMinified` and `Benchmark` for non-debug builds, so I got 12(=(3-1)x3x2) more build variants. 

Because of (2)+(3), I'll need to create 12 more folders for new variants to place each `google-play-services.json` file. 

Example
- /app/src/us`NonMinified`Internal/google-play-services.json
- /app/src/us`NonMinified`Release/google-play-services.json
- /app/src/us`Benchmark`Internal/google-play-services.json
- /app/src/us`Benchmark`Release/google-play-services.json

Otherwise the error is
> * What went wrong:
Execution failed for task ':app:processUsNonMinifiedInternalGoogleServices'.
> File google-services.json is missing. 
  The Google Services Plugin cannot function without it. 
  Searched locations: ...

Is it expected? Any suggestions?

## Question 2
The generator in Android Studio created `baselineprofile` under `app` with a build.gradle.kts which defined productFlavors(us/eu/tw), but didn't define buildTypes(debug/internal/release). So the error message is like this:
> Could not determine the dependencies of task ':app:mergeUsInternalBaselineProfile'.
> Could not resolve all task dependencies for configuration ':app:usInternalBaselineProfile'.
   > Could not resolve project :app:baselineprofile.
     Required by:
         project :app
      > No matching variant of project :app:baselineprofile was found. The consumer was configured to find a component for use during 'baselineProfile', preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'internal', attribute 'com.android.build.api.attributes.ProductFlavor:region' with value 'us', attribute 'androidx.baselineprofile.gradle.configuration.attribute.BaselineProfilePluginAgpVersionAttr' with value '8.2.0', attribute 'androidx.baselineprofile.gradle.configuration.attribute.BaselineProfilePluginVersionAttr' with value 'alpha1' but:
          ...

## Question 3
`mergeIntoMain` must be in `app/build.gradle.kts` instead of `app/baselineprofile/build.gradle.kts`, is it expected?
It seems reasonable, just doesn't mention in https://developer.android.com/topic/performance/baselineprofiles/configure-baselineprofiles#generate-for-variants
There are many build.gradle.kts files in a repo, and sometimes the doc doesn't specify.

## Question 4
In StartupBenchmarks.kt and BaselineProfileGenerator.kt, the package name is hardcoded. What's the recommendation for multiple apps? By separating src folders?

Thanks :D