无法在额外的属性扩展上获取属性“compileSdkVersion",因为它不存在打开文件 [英] Cannot get property 'compileSdkVersion' on extra properties extension as it does not exist Open File

查看:25
本文介绍了无法在额外的属性扩展上获取属性“compileSdkVersion",因为它不存在打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将从 GitHub 下载的项目作为模块导入到我的 Android Studio 项目中.导入模块..."向导工作正常,但是当 Adroid Studio 尝试重建项目时,它返回了这个错误:

I imported a project downloaded from GitHub into my Android Studio project as module. The "Import module..." wizard worked fine, but when the Adroid Studio tried to rebuild the project, it returned me this error:

Cannot get property 'compileSdkVersion' on extra properties extension as it does not exist Open File

错误与导入模块的build.gradle"文件中的这一行有关:

The error is related to this line in the "build.gradle" file of the imported module:

compileSdkVersion rootProject.compileSdkVersion

我尝试在项目build.gradle"中添加ext"部分,如下所示:

I tried to add "ext" section in the project "build.gradle" like this:

ext {
    compileSdkVersion 26
}

但是这样我收到了一个新错误:

But in this way I receive a new error:

Gradle DSL method not found: 'compileSdkVersion()' Possible causes: ... 

推荐答案

在您的顶级文件中使用:

ext {
    compileSdkVersion = 26
}

在你的 module/build.gradle 文件中使用:

In your module/build.gradle file use:

android {
  compileSdkVersion rootProject.ext.compileSdkVersion
  ...
}

这篇关于无法在额外的属性扩展上获取属性“compileSdkVersion",因为它不存在打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆