Android Studio 0.8.2 - Gradle 项目同步失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24847693/
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 0.8.2 - Gradle project sync failed
提问by NukeouT
In hindsight I should not have enabled L build stuff.
事后看来,我不应该启用 L 构建的东西。
I am new to programming and I created a new Android Studio project which is throwing the Gradle errror right away.
我是编程新手,我创建了一个新的 Android Studio 项目,该项目立即抛出 Gradle 错误。
Errors are:
错误是:
yellow bar at the top - Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly. Try again Open Event Log Show Log in Finder
顶部的黄色条 - Gradle 项目同步失败。基本功能(例如编辑、调试)将无法正常工作。再试一次 打开事件日志 在 Finder 中显示日志
messages gradle sync - compileSdkVersion android-L requires compiling with JDK-7. open sdk settings, open file.
消息 gradle sync - compileSdkVersion android-L 需要使用 JDK-7 进行编译。打开sdk设置,打开文件。
tried looking through google and other stack overflow comments but did not find much I could make sense of except for Android Studio - Gradle sync project failed
尝试查看谷歌和其他堆栈溢出评论,但除了Android Studio之外没有找到太多我能理解的内容- Gradle 同步项目失败
tried converting URL to 1.10 instead of 1.12 and syncing but that failed after syncing
尝试将 URL 转换为 1.10 而不是 1.12 并同步但同步后失败
I need help either getting L working or removing it so that a new studio project can compile to device without errors.
我需要帮助让 L 工作或删除它,以便新的工作室项目可以编译到设备而不会出错。
采纳答案by reku
I too faced the same issue and after days of trouble I figured it out. Just check if Java is installed
我也遇到了同样的问题,经过几天的麻烦我想通了。只需检查是否安装了Java
- Open a Terminal window and type:
- 打开终端窗口并输入:
java -version
版本
Any version above JDK 6 is OK
JDK 6 以上的任何版本都可以
- In terminal type
- 在终端类型
open -a TextEdit ~/.bash_profile
open -a TextEdit ~/.bash_profile
- Copy and paste the following lines of into textedit
- 将以下几行复制并粘贴到 textedit 中
export JAVA_HOME=$(/usr/libexec/java_home)
导出 JAVA_HOME=$(/usr/libexec/java_home)
export JDK_HOME=$(/usr/libexec/java_home)
导出 JDK_HOME=$(/usr/libexec/java_home)
- Save it, close editor and type the following to apply changes
- 保存它,关闭编辑器并键入以下内容以应用更改
source ~/.bash_profile
源 ~/.bash_profile
Now try gradle sync now, you must be able to complete sync
现在尝试 gradle sync ,你必须能够完成同步
回答by igor
The most simple solution (at least for me) would be:
最简单的解决方案(至少对我而言)是:
Go to SDK manager (with Administrator rights), scroll down till the end, download "Android Support Library".
转到 SDK 管理器(具有管理员权限),向下滚动到最后,下载“Android 支持库”。
And it works (don't forget Administrator rights).
它有效(不要忘记管理员权限)。
回答by Anshu Kumar Gupta
- Uncheck "Offline work" in File>Settings>Gradle>Global Gradle Settings
- Resync the project, for example by restarting the Android Studio.
- Once synced, you can check the option again to work offline
- Update java if Android L SDK installed
- 在文件>设置>Gradle>全局Gradle设置中取消选中“离线工作”
- 重新同步项目,例如通过重新启动 Android Studio。
- 同步后,您可以再次选中该选项以离线工作
- 如果安装了 Android L SDK,则更新 java
回答by Mac
For me Changing the JDK path worked. I changed it to /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
对我来说,更改 JDK 路径有效。我把它改成 /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
in File--> ProjecStructure-> JDK location.
在文件--> 项目结构-> JDK 位置。
回答by Jazib Sheikh
- Open Gradle Settings in File > Settings > Gradle
- Select the Option 'Use local gradle distribution'
- Enter the URL of your local gradle version here.
- 在文件 > 设置 > Gradle 中打开 Gradle 设置
- 选择选项“使用本地 gradle 发行版”
- 在此处输入您本地 gradle 版本的 URL。
回答by kingcong
When installing Android Studio on Mac OSX Sierra, I received an error that my JVM is not valid. So I came hereto a different post and installed Apple's legacy version and the up-to-date version. It worked. Then when I was creating a project I ran into another error which was the Gradle sync issue. Came here (this very post by "Mac") again and changed the JDK version that Android Studio was pointing to (obviously I chose to "detect" instead of browsing for the up-to-date version). Everything is working fine now.
在 Mac OSX Sierra 上安装 Android Studio 时,我收到一个错误,指出我的 JVM 无效。所以,我来到这里,以不同的职位和安装苹果的旧版本和上最新版本。有效。然后当我创建一个项目时,我遇到了另一个错误,即 Gradle 同步问题。再次来到这里(“Mac”的这篇文章)并更改了 Android Studio 指向的 JDK 版本(显然我选择“检测”而不是浏览最新版本)。现在一切正常。
回答by Mina Fawzy
this happen with me when I try import wrong repository
complie 'me.dm7.barcodescanner:zxing:1.7.2'
, so any one face this problem may be that be the reason
当我尝试导入错误的存储库时会发生这种情况
complie 'me.dm7.barcodescanner:zxing:1.7.2'
,所以任何人都面临这个问题可能就是这个原因
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
}
回答by Julio Enrique Rincon Lopez
The most simple solution (at least for me) would be:
最简单的解决方案(至少对我而言)是:
Go to SDK manager (with Administrator rights), scroll down till the end, download "Android Support Library".
转到 SDK 管理器(具有管理员权限),向下滚动到最后,下载“Android 支持库”。
And it works (don't forget Administrator rights).
它有效(不要忘记管理员权限)。
I am using windows 7 works properly thanks igor
我正在使用 Windows 7 工作正常,感谢 igor
回答by Adrian
回答by Joel
Mine was looking for the Java SDK in "Macintosh_HD>System>Library>Java> etc." but my most recent update was in "Macintosh_HD>Library>Java etc."
我正在“Macintosh_HD>系统>库>Java>等”中寻找Java SDK。但我最近的更新是在“Macintosh_HD>Library>Java 等”中。
I set this after clicking in the error window saying 'open SDK' 'open file' which brings you to the screen where to set the path for Java.
在错误窗口中单击“打开 SDK”“打开文件”后,我进行了设置,这会将您带到设置 Java 路径的屏幕。