Skip to content

Plugin cannot be applied as documented #38

Description

@jhansche

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.

--- 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions