错误提示
今天在从github clone下项目源码之后,导入到IDEA报错。导入方式为File->New->Project from exitsting sources
,错误提示如下。
解决过程
查看log发现如下的日志代码:
2015-07-04 09:51:24,642 [3036843] INFO - .BaseProjectImportErrorHandler - Failed to import Gradle project at 'F:/ideaWS/Volley-demo-master'
org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.2.1-all.zip'.
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:57)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56)
Caused by: org.gradle.internal.exceptions.LocationAwareException: Build file 'F:\ideaWS\Volley-demo-master\volleydemoapp\build.gradle' line: 17
A problem occurred evaluating project ':volleydemoapp'.
at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:77)
Caused by: org.gradle.api.GradleScriptException: A problem occurred evaluating project ':volleydemoapp'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
... 32 more
Caused by: org.gradle.api.UncheckedIOException: Could not normalize path for file 'C:\Android\android-sdk-windows\tools;C:\Android\android-sdk-windows\platform-tools\tools\proguard\proguard-android.txt'.
从log可以看出是sdk路径不被识别,而路径一般是在local.properties
文件中,所以觉得问题可能出现在这里。
解决办法
用能够正常项目的local.properties
文件覆盖该项目的该文件,有的项目git下来可能没有这个文件,就复制添加上。
经过试验,这个方法的效果还是很明显的。
这里吐槽一下IDEA比Android Studio不足的地方,Android Studio是可以输出gradle log的,而IDEA只能去查看又臭又长的log文件。