android / android/project-replicator
Plugin cannot be applied as documented
- Dominant language
- Kotlin
- Stars
- 136
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
Trying to apply the plugin as described in https://github.com/android/project-replicator/blob/master/docs/USAGE.md results in multiple build errors, at various times:
```
* What went wrong:
A problem occurred evaluating project ':host-api-demo'.
> KOTLIN_STAT_ENABLED_PROPERTY
```
```
* What went wrong:
A problem occurred configuring project ':host-api-demo'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle
```
```
* What went wrong:
A problem occurred evaluating project ':host-api-demo'.
> Could not initialize class org.jetbrains.kotlin.gradle.plugin.KotlinGradleBuildServices
```
These Android modules do have compileSdkVersion (or compileSdk using newer dsl). Some modules are _not_ Android modules.
What worked for me was to move the buildscript/classpath entry from build.gradle into settings.gradle's pluginManagement block, add the plugin by id to settings.gradle's plugin{} block, add a resolutionStrategy (since there's no gradle plugin marker published) to resolve the plugin id, and then change the init.gradle's allprojects{apply} to apply by plugin id.
```diff
--- settings.gradle
+++ settings.gradle
@@ -48,0 +48,1 @@ pluginManagement {
+ id "com.android.gradle.project.replicator" version "0.2"
@@ -55,2 +56,5 @@ pluginManagement {
resolutionStrategy {
eachPlugin {
+ if (requested.id.id == "com.android.gradle.project.replicator") {
+ useModule("com.android.gradle.replicator:project-replicator:0.2")
+ }
@@ -69,0 +72,1 @@ plugins {
+ id "com.android.gradle.project.replicator" apply false
--- build.gradle
+++ build.gradle
@@ -27,0 +30,3 @@
+allprojects {
+ apply plugin: "com.android.gradle.project.replicator"
+}
```
This allowed `:getStructure` to complete successfully.
* Gradle 8.0.2
* AGP 7.4.2
* 202 total modules count
Contributor guide
Research direction
Start by comparing docs/USAGE.md with the reported settings.gradle, build.gradle, and init.gradle setup, then reproduce :getStructure using Gradle 8.0.2 and AGP 7.4.2. Check the plugin behavior across Android and non-Android modules; done means the documented application completes without the reported evaluation or configuration errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100