Slackbot
10/28/2022, 3:34 PMHemanth Sai Veluvolu
10/29/2022, 5:13 AMMark
10/29/2022, 5:41 AMBuild file '/path/to/repo/MyProject/build.gradle.kts' line: 26
Plugin [id: 'com.android.test', version: '7.3.1', artifact: 'com.android.tools.build:gradle:7.3.1', apply: false] was not found in any of the following sources:
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.android.test', version: '7.3.1', artifact: 'com.android.tools.build:gradle:7.3.1', apply: false] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.android.tools.build:gradle:7.3.1')
Searched in the following repositories:
Gradle Central Plugin Repository
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.resolveToFoundResult(DefaultPluginRequestApplicator.java:238)
<clipped>
I can get past this error by removing the automatic changes to the project level build.gradle.kts
but then I run into other errors.
These were the extra lines added by the wizard:
plugins {
...
id("com.android.test") version "7.3.1" apply false
id("org.jetbrains.kotlin.android") version "1.7.20" apply false
}
Hemanth Sai Veluvolu
10/29/2022, 6:15 AMid("com.android.test") version "7.3.1" apply false
is a newer convention for applying android plugins instead of adding buildscript.dependencies.classpath. It looks fine to change it and keep it consistent with how "com.android.application" is getting applied in your project. What error do you get after deleting the extra lines?Mark
10/29/2022, 6:58 AMid("com.android.test")
is the same convention I’m using for com.android.application (except that one is applied in the app-level build.gradle.kts
. Once I remove those 2 new lines, the project successfully syncs but when I try to build and deploy the app, I see there are a bunch of errors in the AndroidManifest.xml caused by the wizard mangling the <profileable>
tag. When I manually fix that (side note: should I ensure the tools:targetApi matches the app targetSdkVersion?) then I can build the app. However, when switching to the new benchmark variant fooBarBenchmark
I get a bunch of dependency errors like: :lib-base has variant "release" select, but the modules … depend on variant "debug"
In the build output I see Unable to resolve dependency for ':benchmark@benchmark/testTarget'
which perhaps is due to not including com.android.test
?Hemanth Sai Veluvolu
10/29/2022, 7:19 AMid("com.android.test") version "7.3.1" apply false
convention. module level build.gradle will have id("com.android.application")
, id("com.android.library")
, id("com.android.test")
etc. You can remove id("com.android.test") version "7.3.1" apply false
from root build.gradle if there is no id("com.android.application") version "7.3.1" apply false
. But that seems sorted now.
Not sure what part of <profileable> was mangled, but you should fix any syntax errors manually. The tools:targetApi inside <profileable> should be "q" or 29, not dependent on your targetSdkVersion. This can later be moved to AndroidManifest in benchmark sourceset, to leave your release builds unaffected.
Are you using AS "select build variant" to switch? If so, check all modules are switched to correct variant. If you app has custom flavors, you'll have specify which dimension to use in your benchmark build.gradle using missingDimensionStrategyMark
10/29/2022, 8:49 AMHemanth Sai Veluvolu
10/29/2022, 9:57 AMMark
10/29/2022, 10:04 AMCould not determine the dependencies of task ':benchmark:connectedBenchmarkAndroidTest'.
> Could not determine the dependencies of null.
> Could not resolve all task dependencies for configuration ':benchmark:benchmarkTestedApks'.
> Could not resolve project :app-main.
Required by:
project :benchmark
> The consumer was configured to find a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'benchmark', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.3.1'. However we cannot choose between the following variants of project :app-main:
- foo1Bar1BenchmarkRuntimeElements
- foo1Bar2BenchmarkRuntimeElements
- foo2Bar2BenchmarkRuntimeElements
All of them match the consumer attributes:
- Variant 'foo1Bar1BenchmarkRuntimeElements' capability MyProject:app-main:unspecified declares a runtime of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.3.1', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'benchmark':
- Unmatched attributes:
- Provides attribute 'com.android.build.api.attributes.ProductFlavor:lang' with value 'foo1' but the consumer didn't ask for it
- Provides attribute 'com.android.build.api.attributes.ProductFlavor:tier' with value 'bar1' but the consumer didn't ask for it
- Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'foo1Bar1Benchmark' but the consumer didn't ask for it
- Provides attribute 'foodimension' with value 'foo1' but the consumer didn't ask for it
- Provides a library but the consumer didn't ask for it
- Provides attribute 'org.gradle.jvm.environment' with value 'android' but the consumer didn't ask for it
- Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
- Provides attribute 'tier' with value 'bar1' but the consumer didn't ask for it
<clipped>
Hemanth Sai Veluvolu
10/29/2022, 10:38 AMmissingDimensionStrategy("lang", "foo1")
missingDimensionStrategy("tier", "bar1")
This will tell benchmark to use foo1Bar1 variant of app-mainMark
10/30/2022, 8:10 AM./gradlew :benchmark:pixel6Api31BenchmarkAndroidTest
I get:
> Task :benchmark:pixel6Api31BenchmarkAndroidTest
Exception thrown during onBeforeAll invocation of plugin com.google.testing.platform.plugin.android.AndroidDevicePlugin.
Failed to install APK: /path/to/repo/MyProject/app/build/outputs/apk/fooBar/benchmark/app-main-foo-bar-x86_64-benchmark.apk, with option -r,-t
com.google.testing.platform.api.plugin.PluginException: Failed to install APK: /path/to/repo/MyProject/app/build/outputs/apk/fooBar/benchmark/app-main-foo-bar-x86_64-benchmark.apk, with option -r,-t
at com.google.testing.platform.plugin.android.AndroidDevicePlugin.beforeAll(AndroidDevicePlugin.kt:109)
My app is fairly large so perhaps it’s a storage issue, however I can’t see anything in the error regarding this. Also, where to find the available configuration options for setting up a managedDevice?
Update: I can generate the baseline-prof.txt
by running the BaselineProfileGenerator from AS, but it would be nice to be able to use a managedDevice.Mark
10/30/2022, 11:58 AMmissingDimensionStrategy
statements in the benchmark gradle script are fine if we hardcode a variant, but how to deal with this generically?Hemanth Sai Veluvolu
10/30/2022, 12:22 PMMark
10/30/2022, 3:29 PMMark
10/31/2022, 5:32 AMbaseline-prof.txt
in the appropriate fooBar
variant folder. It only seems to get picked up when placed in main
Mark
11/02/2022, 2:13 PMbaseline-prof.txt
from the relevant variant folder to main
androidComponents {
...
onVariants { variant ->
...
if (variant.buildType == "release") {
val taskName = "${variant.name}CopyBaselineProfile"
val copyProfileTask = tasks.register<Copy>(taskName) {
val flavor = variant.name.removeSuffix("Release")
val path = "src/$flavor/baseline-prof.txt"
println ("copying $path")
from(path)
into("src/main")
if (inputs.sourceFiles.isEmpty) {
throw GradleException("File not found: $path")
}
}
However, I don’t know where to place the dependsOn(copyProfileTask)
Any ideas?