Cannot get property 'dependencies' on extra properties extension as it does not exist
时间: 2024-04-25 10:24:40 浏览: 122
Android添加ButterKnife时报错Error:(2, 0) Cannot add extension with name 'android'的解决办法
回答: 这个错误是由于在build.gradle文件中缺少相应的属性导致的。根据引用\[1\]和引用\[2\]的建议,你需要在extra properties extension中添加buildToolsVersion和compileSdkVersion属性。具体的解决方法是在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 ]
阅读全文