androidkotlingradle-kotlin-dslobjectbox

How to implement ObjectBox with Android Version Catalog (TOML)


I couldn't implement ObjectBox plugin with:

objectbox = { id = "io.objectbox.objectbox-gradle-plugin", version.ref = "objectbox" }

The result error is: Was not found in any of the following sources.

My settings.gradle already has:

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

Solution

  • The ObjectBox Gradle plugin does not ship a Gradle plugin marker artifact. To work around this, add a plugin resolution rule that maps the dependency to a name of your choosing:

    pluginManagement {
        resolutionStrategy {
            eachPlugin {
                if (requested.id.id == "io.objectbox.plugin") {
                    useModule("io.objectbox:objectbox-gradle-plugin:${requested.version}")
                }
            }
        }
    }
    

    Then use that name in the TOML file:

    objectbox = { id = "io.objectbox.plugin", version.ref = "objectbox" }
    

    See also the related GitHub issue.