Cannot get property 'compileSdkVersion' on extra properties extension as it does not exit

报错为:Error:(9, 0) Cannot get property 'compileSdkVersion' on extra properties extension as it does not exist

<a href="openFile:D:\zyl\projects\7 doing\DroidPluginDemo\DroidPlugin\build.gradle">Open File</a>



解决方法:在Buid.gradle(project:XXX) 中根目录添加

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

//添加此处 解决rootProject.ext.compileSdkVersion 不存在的问题
ext {
    compileSdkVersion = 26
    buildToolsVersion = "25.0.3"
    minSdkVersion = 15
    targetSdkVersion = 26
}

回答: 这个错误是由于在build.gradle文件中缺少相应的属性导致的。根据引用\[1\]和引用\[2\]的建议,你需要在extra properties extension中添加buildToolsVersioncompileSdkVersion属性。具体的解决方法是在build.gradle文件中添加以下代码: ``` android { // 添加buildToolsVersion属性 buildToolsVersion "版本号" // 添加compileSdkVersion属性 compileSdkVersion 版本号 } ``` 此外,根据引用\[3\]的建议,你还需要在dependencies块中添加相应的依赖项。具体的解决方法是在build.gradle文件中的dependencies块中添加以下代码: ``` 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 } ``` 通过以上的修改,你应该能够解决这个错误。 #### 引用[.reference_title] - *1* *2* [Cannot get property 'compileSdkVersion' on extra properties extension as it does not exist问题解决](https://blog.csdn.net/u013768203/article/details/53140449)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [ERROR: Cannot get property 'dependencies' on extra properties extension as it does not exist](https://blog.csdn.net/weixin_40420578/article/details/102934754)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值