android greendao plugin config confusing

78 Views Asked by At

In latest androidstudio, the project build.gradle format changed as below:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false
    id 'org.greenrobot-gradle-plugin' version '3.2.1' apply false
}

The 3rd line report error: P

lugin [id: 'org.greenrobot-gradle-plugin', version: '3.2.1', apply: false] was not found in any of the following sources:

I know the old androidstudio use below format:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1'
    }
}

How should I convert old build.gradle config to new format?

1

There are 1 best solutions below

0
L. Swifter On

I faced the same problem, And I found a way to make greendao work in new format, but I don't think this's the best way to go about it:

settings.gradle:

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
    resolutionStrategy {
        eachPlugin {
            if (requested.id.id == 'org.greenrobot.greendao') {
                useModule('org.greenrobot:greendao-gradle-plugin:3.3.1')
            }
        }
    }
}

//......

app module's build.gradle:

plugins {
    id 'com.android.application'
    id 'org.greenrobot.greendao'
}

//......

dependencies {

    implementation 'org.greenrobot:greendao:3.3.0'

}