解决ERROR: Cannot get property 'dependencies' on extra properties extension as it does not exist,亲测有效

项目开发需要统一配置信息及第三方依赖,这时建立了config.gradle,

config.gradle的内容

ext {
    ……………………
    dependencies = [
            appcompat       : "androidx.appcompat:appcompat:1.0.2",
            constraintlayout: "androidx.constraintlayout:constraintlayout:1.1.3"

    ]

    testDependencies = [
            junit        : 'junit:junit:4.12',
            runner       : "androidx.test:runner:1.1.1",
            espresso_core: 'androidx.test.espresso:espresso-core:3.1.1'
    ]
}

build.gradle(app)中

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation rootProject.ext.dependencies.appcompat
    implementation rootProject.ext.dependencies.constraintlayout
    testImplementation rootProject.ext.testDependencies.junit
    androidTestImplementation rootProject.ext.testDependencies.runner
    androidTestImplementation rootProject.ext.testDependencies.espresso_core
}

解决方法:

build.gradle(Project:***)中,最上方加入如下代码即可。

apply from: "config.gradle"

GitHub 加速计划 / de / Dependencies
8.61 K
704
下载
A rewrite of the old legacy software "depends.exe" in C# for Windows devs to troubleshoot dll load dependencies issues.
最近提交(Master分支:2 个月前 )
1997a400 - 2 年前
2f423539 - 2 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐