Android工作室,配置gradle项目需要永远

Posted

技术标签:

【中文标题】Android工作室,配置gradle项目需要永远【英文标题】:Android studio, configure gradle project takes forever 【发布时间】:2014-03-13 22:40:10 【问题描述】:

将gradle build文件改成使用gradle build tool 0.8.+后,

classpath 'com.android.tools.build:gradle:0.8.+'

我的 Android 工作室永远停留在“刷新 X Gradle 项目”上。我试图重新启动AS,没有工作。我什至将 gradle 构建工具改回 0.7.+,甚至将我的 AS 从 0.4.4 降级回 0.4.2,仍然没有希望。以前有人经历过吗?请帮忙 谢了。

更新:现在我尝试删除所有旧的 .iml 文件和 .idea 文件夹,然后重新导入,现在它卡在“Building X Gradle 项目信息”,似乎永远。

从命令行构建非常好。

更新 2:按要求包含日志文件 (.AndroidStudioPreview\system\log\idea.log)

2014-02-17 00:45:27,412 [  46868]   WARN -      #org.jetbrains.idea.maven - Failed to update Maven indices for: [http://download.crashlytics.com/maven] http://download.crashlytics.com/maven 
org.jetbrains.idea.maven.server.MavenServerIndexerException: java.lang.RuntimeException: java.io.FileNotFoundException: Resource nexus-maven-repository-index.properties does not exist
    at org.jetbrains.idea.maven.server.Maven3ServerIndexerImpl.updateIndex(Maven3ServerIndexerImpl.java:210)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
    at sun.rmi.transport.Transport$1.run(Transport.java:177)
    at sun.rmi.transport.Transport$1.run(Transport.java:174)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:160)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148)
    at $Proxy99.updateIndex(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.intellij.execution.rmi.RemoteUtil$2$1$1.compute(RemoteUtil.java:106)
    at com.intellij.execution.rmi.RemoteUtil.executeWithClassLoader(RemoteUtil.java:167)
    at com.intellij.execution.rmi.RemoteUtil$2$1.invoke(RemoteUtil.java:102)
    at $Proxy99.updateIndex(Unknown Source)
    at org.jetbrains.idea.maven.server.MavenIndexerWrapper$3.execute(MavenIndexerWrapper.java:110)
    at org.jetbrains.idea.maven.server.RemoteObjectWrapper.perform(RemoteObjectWrapper.java:118)
    at org.jetbrains.idea.maven.server.MavenIndexerWrapper.updateIndex(MavenIndexerWrapper.java:105)
    at org.jetbrains.idea.maven.indices.MavenIndex.updateContext(MavenIndex.java:317)
    at org.jetbrains.idea.maven.indices.MavenIndex.updateOrRepair(MavenIndex.java:276)
    at org.jetbrains.idea.maven.indices.MavenIndices.updateOrRepair(MavenIndices.java:126)
    at org.jetbrains.idea.maven.indices.MavenIndicesManager.doUpdateIndices(MavenIndicesManager.java:260)
    at org.jetbrains.idea.maven.indices.MavenIndicesManager.access$200(MavenIndicesManager.java:49)
    at org.jetbrains.idea.maven.indices.MavenIndicesManager$3.run(MavenIndicesManager.java:231)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:464)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$8.run(ProgressManagerImpl.java:373)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:436)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:153)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.io.FileNotFoundException: Resource nexus-maven-repository-index.properties does not exist
    at org.jetbrains.idea.maven.server.Maven3ServerIndexerImpl$2.run(Maven3ServerIndexerImpl.java:193)
    at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.executeWithMavenSession(Maven3ServerEmbedderImpl.java:314)
    at org.jetbrains.idea.maven.server.Maven3ServerIndexerImpl.updateIndex(Maven3ServerIndexerImpl.java:159)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
    at sun.rmi.transport.Transport$1.run(Transport.java:177)
    at sun.rmi.transport.Transport$1.run(Transport.java:174)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: Resource nexus-maven-repository-index.properties does not exist
    at org.jetbrains.idea.maven.server.Maven3ServerIndexFetcher.retrieve(Maven3ServerIndexFetcher.java:108)
    at org.sonatype.nexus.index.updater.AbstractResourceFetcher.retrieve(AbstractResourceFetcher.java:22)
    at org.sonatype.nexus.index.updater.DefaultIndexUpdater.downloadIndexProperties(DefaultIndexUpdater.java:484)
    at org.sonatype.nexus.index.updater.DefaultIndexUpdater.access$100(DefaultIndexUpdater.java:65)
    at org.sonatype.nexus.index.updater.DefaultIndexUpdater$IndexAdaptor.setProperties(DefaultIndexUpdater.java:771)
    at org.sonatype.nexus.index.updater.DefaultIndexUpdater.fetchAndUpdateIndex(DefaultIndexUpdater.java:945)
    at org.sonatype.nexus.index.updater.DefaultIndexUpdater.fetchAndUpdateIndex(DefaultIndexUpdater.java:150)
    at org.jetbrains.idea.maven.server.Maven3ServerIndexerImpl$2.run(Maven3ServerIndexerImpl.java:190)
    ... 17 more
Caused by: java.lang.RuntimeException: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to locate resource in repository
    at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:139)
    at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:116)
    at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
    at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
    at org.jetbrains.idea.maven.server.Maven3ServerIndexFetcher.retrieve(Maven3ServerIndexFetcher.java:100)
    ... 24 more
Caused by: java.io.FileNotFoundException: http://download.crashlytics.com/maven/.index/nexus-maven-repository-index.properties
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1664)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1662)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1660)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1243)
    at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:122)
    ... 28 more
Caused by: java.io.FileNotFoundException: http://download.crashlytics.com/maven/.index/nexus-maven-repository-index.properties
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1613)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
    at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:115)
    ... 28 more
2014-02-17 00:45:56,749 [  76205]   INFO -                  TestNG Runner - Create TestNG Template Configuration 
2014-02-17 00:45:56,750 [  76206]   INFO -                  TestNG Runner - Create TestNG Template Configuration 
2014-02-17 00:45:56,756 [  76212]   INFO - ellij.project.impl.ProjectImpl - 25 project components initialized in 20 ms 
2014-02-17 00:45:56,757 [  76213]   INFO - le.impl.ModuleManagerComponent - 0 module(s) loaded in 0 ms 
2014-02-17 00:47:30,887 [ 170343]   INFO - .project.GradleProjectResolver - Gradle project resolve error 
org.gradle.tooling.GradleConnectionException: Could not run build action using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.9-bin.zip'.
    at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:55)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
    at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
    at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter.run(DefaultBuildActionExecuter.java:43)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.doResolveProjectInfo(GradleProjectResolver.java:170)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.access$000(GradleProjectResolver.java:61)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$1.fun(GradleProjectResolver.java:117)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$1.fun(GradleProjectResolver.java:113)
    at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:182)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:113)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:61)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:48)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:471)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4$2.run(ExternalSystemUtil.java:549)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:464)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$8.run(ProgressManagerImpl.java:373)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:436)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:153)
Caused by: java.nio.channels.OverlappingFileLockException
    at sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255)
    at sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152)
    at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1017)
    at org.gradle.cache.internal.filelock.LockStateAccess.tryLock(LockStateAccess.java:83)
    at org.gradle.cache.internal.filelock.LockFileAccess.tryLockState(LockFileAccess.java:83)
    at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.lockStateRegion(DefaultFileLockManager.java:317)
    at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.lock(DefaultFileLockManager.java:260)
    at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.<init>(DefaultFileLockManager.java:132)
    at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:87)
    at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:74)
    at org.gradle.cache.internal.OnDemandFileAccess.readFile(OnDemandFileAccess.java:36)
    at org.gradle.cache.internal.SimpleStateCache.get(SimpleStateCache.java:40)
    at org.gradle.cache.internal.FileIntegrityViolationSuppressingPersistentStateCacheDecorator.get(FileIntegrityViolationSuppressingPersistentStateCacheDecorator.java:31)
    at org.gradle.launcher.daemon.registry.PersistentDaemonRegistry.getAll(PersistentDaemonRegistry.java:62)
    at org.gradle.launcher.daemon.registry.PersistentDaemonRegistry.getIdle(PersistentDaemonRegistry.java:77)
    at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connect(DefaultDaemonConnector.java:67)
    at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:149)
    at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:74)
    at org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:42)
    at org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:29)
    at org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:53)
    at org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:30)
    at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:106)
    at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:100)
    at org.gradle.tooling.internal.provider.DefaultConnection.run(DefaultConnection.java:143)
    at org.gradle.tooling.internal.consumer.connection.ActionAwareConsumerConnection.run(ActionAwareConsumerConnection.java:40)
    at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter$1.run(DefaultBuildActionExecuter.java:53)
    at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:82)
    at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58)
    at org.gradle.tooling.internal.consumer.connection.LoggingInitializerConsumerActionExecutor.run(LoggingInitializerConsumerActionExecutor.java:44)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
2014-02-17 00:47:30,893 [ 170349]   INFO - .BaseProjectImportErrorHandler - Failed to import Gradle project at 'C:/Users/Tung/TripGoify/TripGoify' 
org.gradle.tooling.GradleConnectionException: Could not run build action using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.9-bin.zip'.
    at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:55)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
    at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
    at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter.run(DefaultBuildActionExecuter.java:43)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.doResolveProjectInfo(GradleProjectResolver.java:170)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.access$000(GradleProjectResolver.java:61)
    at 

【问题讨论】:

您是否尝试过重新导入项目?只需删除所有 .iml 文件和 .idea 文件夹并重新导入即可。而且,从命令行构建会给您带来任何错误吗? 我认为这不是 rciovati 的问题。 @rciovati 从命令行构建很好。仍在尝试重新导入,AS 现在已经需要一些时间了。 我用 gradle build tools v0.11 得到这个,但不是 0.10 / android.buildToolsVersion 19.0.1。建议的解决方案都不起作用。我相信这与 CrashLytics 有关。日志说File: http://download.crashlytics.com/maven/.index/nexus-maven-repository-index.properties , ReasonPhrase:Not Found. 我遇到了和你类似的问题,在IDEA中打开了这个bug:youtrack.jetbrains.com/issue/IDEA-127247 【参考方案1】:

如果你在 Windows 上检查

C:\Users\YOUR_USER\.gradle\wrapper\dists

gradle 1.10-all 是否安装在目录中。

Android Studio 首次下载整个发行版大约 60 MB,因此需要一些时间。

检查 gradle/gradle-wrapper.properties 中的 distributionUrl 并在您的 dist 目录中匹配,如果它不可用,工作室将下载它。分发网址如下所示:

distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip

将其更改为已安装的任何内容都可以解决问题。

注意: dist 中的目录名和 Zip 名必须相同。尝试下载时将创建目录,检查 Zip 是否正确安装。

【讨论】:

tks,我目前的设置和你建议的一样。还有什么要检查的吗? 可以包含idea.log文件吗? 在Linux中也是一样,使用这个文件夹名:~/.gradle/wrapper/dists distributionUrl in gradle/gradle-wrapper.properties 在 Windows 上在哪里? 在你的项目根目录/gradle中【参考方案2】:

这可能是任何情况,但在我的情况下,这是由于 HTTP 代理无效并且无法下载某些库。在 Settings-> HTTP Proxy 中,设置为“None”。

【讨论】:

这是安装Android Studio后的默认配置 是的,我建议其他人查看下面的@pyus13 答案 就我而言,我在我的机器上使用了 HTTP 代理。杀死它(Charles.app)导致 Android Studio 立即完成构建我的项目。 我也让查尔斯跑了。关闭 Charles 为我解决了这个问题。 现在是:设置->外观&行为-->系统设置-->HTTP代理【参考方案3】:

删除项目文件夹中的 gradle 文件夹,然后使用工作室重新打开它,在选择对话框中选择取消,不要使用等级包装器下载最新版本的 gradle

【讨论】:

【参考方案4】:

如果有人在 mac 中遇到此同步卡住问题,请尝试一下。

右击你的

android studio.app -> 显示包 -> 内容 -> gradle

并查看gradle 版本。在该文件夹中,现在进入您的 android studio IDE 并打开您的首选项并转到

构建、执行->构建工具->gradle

在那里检查偏好。验证 gradle 的路径是 content -> .... 最后会有 gradle 版本,看是否匹配 androidStudio.app 内容中的 gradle 版本

猜这对某人有帮助。

【讨论】:

帮助我感谢,在更新 Android Studio 并面临无休止的 gradle 同步之后。【参考方案5】:

在我的情况下,问题是 Genymotion 插件。一旦我将它从工作室中删除并重新启动。它工作得很好。 我仍然不知道这是怎么发生的,因为我经常在我的其他机器中使用带有工作室的 genymotion。 即使您通过从 genymotion 本身启动模拟器来删除工作室插件,您仍然可以运行 genymotion。

【讨论】:

【参考方案6】:

我在 virtualbox 5.0.16 虚拟机上安装了 centos 7 64 位和带有 Android Studio 2.0 的 gradle 版本 2.10

gradle的日志文件位于$HOME/.gradle/daemon/2.10 日志文件:daemon-&lt;some number&gt;.out.log

通过检查此日志文件,我发现aapt 没有找到libz.so.1

尽管命令“locate libz.so.1”的输出是

/usr/lib64/libz.so
/usr/lib64/libz.so.1
/usr/lib64/libz.so.1.2.7

aapt 找不到它。

为了解决我不得不执行的问题

yum install zlib.i686

安装后,Gradle 开始编译。祝你好运!

【讨论】:

【参考方案7】:

在这方面对我有用的是,从您可能尝试的相应项目中替换 GRDADLE jarproperties 文件进口 。

    新建一个项目,或者从工作项目中复制 gradle jar 和属性文件 现在,进一步复制这些文件并替换为“Originaly”您尝试导入的项目或 gradle build 挂起的项目的不工作 gradle 文件

有点晚了,但对以后的查询有一些帮助。

【讨论】:

【参考方案8】:

在我的例子中,我使用了多项目设置,并在 settings.gradle 中包含了两个独立的项目,具有一些重叠的属性。我不确定是哪个 exact 属性导致了这种情况,但它们很可能与名称有关。基本上,Gradle 没有抛出异常(“检测到重复的 [something]”),而是进入了无限循环。替换重复的属性很有帮助。

【讨论】:

【参考方案9】:

我解决了

删除 gradle 和 intellij 文件

rm -rf .idea/ *.iml .gradle/

在 intellij 上重新导入项目

为 gradle 选择与在 gradle 终端上使用的 jdk 相同的 jdk(如果您使用守护程序则有意义) 并从 gradle 2.4 升级到 2.13

【讨论】:

只有这个解决方案对我有帮助。 @sunnyday 我为你感到高兴 删除名为.gradle 的整个文件夹有帮助。谢谢。【参考方案10】:

如果有人在 2021 年看到此问题,我只需在 local.properties 中添加 ndk 位置即可解决此问题。

【讨论】:

我在卸载当前的 NDK 版本并安装新版本后遇到了这个问题。重新安装之前的NDK解决了问题,然后我只需要根据项目结构更改NDK版本即可。

以上是关于Android工作室,配置gradle项目需要永远的主要内容,如果未能解决你的问题,请参考以下文章

更新到 Android Studio 3.2 后,Gradle 构建卡住并且永远不会完成

如何建立与 Android studio和 gradle android 库

android studio使用指定gradle版本

Android gradle 自定义配置

Android gradle 自定义配置

gradle配置不成功,求助贴