Android 被告知项目没有使用 gradle 构建系统
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20362473/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Being told project is not using the gradle build system when it is
提问by Sega dude
When I open my project in Android Studio, I always get this.
当我在 Android Studio 中打开我的项目时,我总是得到这个。
Back when Android Studio first came out, I went through thisprocess so the project should have the Gradle build system. There is a build.gradle file in the root of the project. I can still build and run the project, but I don't understand why it always says this since the project should use gradle build system. Any help with this would be great.
回到 Android Studio 刚出来的时候,我经历了这个过程,所以项目应该有 Gradle 构建系统。项目根目录中有一个 build.gradle 文件。我仍然可以构建和运行该项目,但我不明白为什么它总是这么说,因为该项目应该使用 gradle 构建系统。对此的任何帮助都会很棒。
回答by Shawn
The android studio support two "build mode". one is "legacy" and one is "gradle based". If you are using an very early version of android studio, probably you are still using the legacy build mode. You need to re-import your project using "gradle mode" then this warning will be gone.
android studio 支持两种“构建模式”。一种是“遗留”,一种是“基于 gradle”。如果您使用的是 android studio 的早期版本,则可能您仍在使用旧版构建模式。您需要使用“gradle 模式”重新导入您的项目,然后此警告将消失。
To do so, select "file/import project", select your project root directory, and in the next dialog choose "Import project from external model" and select gradle. Then, you may choose "gradle wrapper" or use your own gradle distribution (1.8 for now[12/2013]).
为此,请选择“文件/导入项目”,选择您的项目根目录,然后在下一个对话框中选择“从外部模型导入项目”并选择 gradle。然后,您可以选择“gradle 包装器”或使用您自己的 gradle 发行版(现在为 1.8 [12/2013])。
回答by angel parra
This link can help, https://developer.android.com/studio/intro/migrate.html
此链接可以提供帮助,https://developer.android.com/studio/intro/migrate.html
Import as a Project:
作为项目导入:
- Start Android Studio and close any open Android Studio projects.
- From the Android Studio menu click File > New > Import Project. Alternatively, from the Welcome screen, click Import project (Eclipse ADT, Gradle, etc.).
- Select the Eclipse ADT project folder with the AndroidManifest.xml file and click Ok.
- 启动 Android Studio 并关闭所有打开的 Android Studio 项目。
- 从 Android Studio 菜单中单击文件 > 新建 > 导入项目。或者,从欢迎屏幕中,单击导入项目(Eclipse ADT、Gradle 等)。
- 选择包含 AndroidManifest.xml 文件的 Eclipse ADT 项目文件夹,然后单击 Ok。
回答by madhur
In my case the the problem was that studio version I am using does not support the gradle version of file, so in build.gradle I had to change the gradle version to 2.3.0 and everything is smooth now
就我而言,问题是我使用的工作室版本不支持文件的 gradle 版本,因此在 build.gradle 中,我不得不将 gradle 版本更改为 2.3.0,现在一切都很顺利
回答by user172094
i know this is an old question but is still valid with newer versions of AS.
我知道这是一个老问题,但对于较新版本的 AS 仍然有效。
If you try to import and import againa and still have the same issue, check if there's a gradle.build file on the root directory, if there's not just create one.
如果您尝试再次导入和导入仍然有相同的问题,请检查根目录下是否有 gradle.build 文件,如果没有创建一个。
In my case I had to migrate an old project to the new version because with the 0.4.4+ version it stopped recognizing it, and it kept failing, and that was the problem.
就我而言,我不得不将一个旧项目迁移到新版本,因为在 0.4.4+ 版本中它停止识别它,并且它一直失败,这就是问题所在。
Curious thing is the top level build.gradle file just contains this comment:
奇怪的是顶级 build.gradle 文件只包含以下评论:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
回答by Ravi Prakash Yadav
I fixed this issue with the following steps:
我通过以下步骤解决了这个问题:
Make sure that the following two files are in your project directory. If not, create a new one with reference of your other Android projects. These are default auto-generated files.
- settings.gradle
- build.gradle
If it is still showing any errors when you open your project, restart your project by selecting file/(invalidate /restart).
确保以下两个文件在您的项目目录中。如果没有,请参考您的其他 Android 项目创建一个新项目。这些是默认的自动生成的文件。
- 设置.gradle
- 构建.gradle
如果在打开项目时仍然显示任何错误,请通过选择 file/(invalidate /restart) 重新启动项目。
回答by Mahmoud Alnouno
import Project
导入项目
File --> New -->import Project
文件 --> 新建 --> 导入项目