Android Studio - Gradle 同步项目失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22148584/
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
Android Studio - Gradle sync project failed
提问by vcapra1
In Android Studio, I simply created a new project, and it says that:
在 Android Studio 中,我简单地创建了一个新项目,它说:
Gradle project sync failed. Basic functionality will not work properly.
Gradle project sync failed. Basic functionality will not work properly.
I have searched the web and tried everything, but nothing worked. I have v0.4.6 of Android Studio using Gradle 1.11.
我已经在网上搜索并尝试了所有方法,但没有任何效果。我有使用 Gradle 1.11 的 Android Studio v0.4.6。
The Error Message Is:
错误信息是:
FAILURE: Build failed with an exception. * Where: Build file 'C:\Users\Vinnie\AndroidStudioProjects\MyFirstAppProject\MyFirstApp\build.gradle' line: 9 * What went wrong: A problem occurred evaluating project ':MyFirstApp'. > Gradle version 1.10 is required. Current version is 1.11. If using the gradle wrapper, try editing the distributionUrl in C:\Users\Vinnie\AndroidStudioProjects\MyFirstAppProject\MyFirstApp\gradle\wrapper\gradle-wrapper.properties to gradle-1.10-all.zip * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 1 mins 7.011 secs
采纳答案by rciovati
The Android plugin 0.8.x doesn't support Gradle 1.11, you need to use 1.10.
Android 插件 0.8.x 不支持 Gradle 1.11,您需要使用 1.10。
You can read the proper error message in the "Gradle Console" tab.
您可以在“Gradle Console”选项卡中阅读正确的错误消息。
EDIT
编辑
You need to change gradle/wrapper/gradle-wrapper.properties
file in this way:
您需要以gradle/wrapper/gradle-wrapper.properties
这种方式更改文件:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
回答by Manee.O.H
This may be helpful for some.
这可能对某些人有帮助。
My problem exactly is incomplete gradle-1.12-all
file download.
我的问题正是gradle-1.12-all
文件下载不完整。
Below is screen shot of the Error
下面是错误的屏幕截图
- I re-downloaded the file from the gradle site hereand extracted it in
path/to/the/gradle
, in my case was inC:\Users\maneeOsman\.gradle\wrapper\dists\gradle-1.12-all\2apkk7d25miauqf1pdjp1bm0uo
- I closed the android studio and reopen it in administrator privilege (Run as administrator).
- 我从这里的gradle 站点重新下载了文件并将其解压缩到
path/to/the/gradle
.C:\Users\maneeOsman\.gradle\wrapper\dists\gradle-1.12-all\2apkk7d25miauqf1pdjp1bm0uo
- 我关闭了 android studio 并以管理员权限重新打开它(以管理员身份运行)。
The android studio starts downloading the necessary files for building and debugging. You can notice that from bottom-left indicator bar.
android studio 开始下载构建和调试所需的文件。您可以从左下角的指示器栏中注意到这一点。
After this, it is working fine.
在此之后,它工作正常。
See the screen shot below
请参阅下面的屏幕截图
回答by Cerlin
In my case NDK location was the issue.
就我而言,NDK 位置是问题所在。
go to File->Project Structure->SDK Location
and add NDK location
转到File->Project Structure->SDK Location
并添加 NDK 位置
回答by StevenZ
Here is the solution I found: On the project tree "app", right click mouse button to get the context menu. Select "open module setting", on the tree "app" - "properties" tab, select the existing "build tools version" you have. The gradle will start to build.
这是我找到的解决方案:在项目树“app”上,右键单击鼠标按钮以获取上下文菜单。选择“打开模块设置”,在树“应用程序”-“属性”选项卡上,选择您拥有的现有“构建工具版本”。gradle 将开始构建。
回答by hungtam
I have encountered this problem And I solved it as follows: File->Sync Project with Gradle Files
我遇到了这个问题,我解决了如下问题:File->Sync Project with Gradle Files
good luck!
祝你好运!
回答by Martin Joly
After applying this fix that was found here... https://code.google.com/p/android/issues/detail?id=208295
应用在此处找到的此修复程序后... https://code.google.com/p/android/issues/detail?id=208295
in file $SDK/ndk_bundle/source.properties replace "12.0.2753695 beta 1" to "12.0.2753695-beta1"
在文件 $SDK/ndk_bundle/source.properties 中将“12.0.2753695 beta 1”替换为“12.0.2753695-beta1”
My project was built successfully and ran on device and emulators although 5 warnings still remains.
我的项目已成功构建并在设备和模拟器上运行,但仍然存在 5 个警告。
回答by Snag
Remove the dependency "junit:junit:4.12" from app modules...!!! This solution is for gradle to sync all files.
从应用程序模块中删除依赖项“junit:junit:4.12”...!!!此解决方案用于 gradle 同步所有文件。
回答by Zeyad Asem
it was hard to solve but i did it look go to C:\Users\Vinnie\ delete .gradle file its you didn't see it it may be in hidden filesso if you use windows 7 right click then click on properties and click on hidden to be not checked
这很难解决,但我确实查看了 C:\Users\Vinnie\ 删除 .gradle 文件,您没有看到它可能在隐藏文件中,因此如果您使用 Windows 7 右键单击然后单击属性并单击在隐藏不被检查
then the file will appear then delete it i hope this works
然后文件将出现然后删除它我希望这有效
回答by Stuey
I know this is an old thread but I ended up here with the same issue.
我知道这是一个旧线程,但我最终遇到了同样的问题。
I solved it by comparing the dependencies classpath in the build.gradle script(Project) to the installed version.
我通过将 build.gradle 脚本(项目)中的依赖项类路径与已安装的版本进行比较来解决它。
The error message was pointing to the following folder
错误消息指向以下文件夹
C:\Program Files\Android\android-studio3 preview\gradle\m2repository\com\android\tools\build\gradle
C:\Program Files\Android\android-studio3 preview\gradle\m2repository\com\android\tools\build\gradle
It turned out that the alpha2 version was installed but the classpath was still pointing to alpaha1. A simple change to the classpath ('com.android.tools.build:gradle:3.0.0-alpha2') was all that was needed.
结果是安装了 alpha2 版本,但类路径仍然指向 alpaha1。只需要对类路径 ('com.android.tools.build:gradle:3.0.0-alpha2') 进行简单的更改。
This may not help everyone, but I do hope it help most people out.
这可能不会对每个人都有帮助,但我确实希望它可以帮助大多数人。
回答by Ravi Parekh
I was behind firewall|proxy
.
我落后了firewall|proxy
。
In my case with Studio, ERROR:Gradle sync failed
& Cannot find symbol
.
I have used
在我的 Studio 中,ERROR:Gradle sync failed
& Cannot find symbol
。我用过了
repositories {
jcenter(); // Points to HTTPS://jcenter.bintray.com
}
Replace it with http and maven
用 http 和 maven 替换它
repositories {
maven { url "http://jcenter.bintray.com" }
}