Android Studio Gradle Configuration Errors总结

1.

Error:Configuration with name 'default' not found.

 这样的错误乍看无从下手,但是gradle提供了一个命令可以进一步地定位具体的错误

gradlew.bat assembleDebug --info

 此时将获取到进一步的错误信息,比如我的

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Cannot evaluate module PullToRefresh : Configuration with name 'default' not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

 此时可以发现 Cannot evaluate module PullToRefresh 有可能是出错的根源,接来下的验证就比较简单了,查看工程目录下有没有把这个module添加进去之类的。

2.

Error:(?, 0) Gradle DSL method not found: 'compile()'

查看你的application(整个工程)的build.gradle,里面 dependencies 不要包含 

classpath 'com.android.tools.build:gradle:1.3.0'

 之外的依赖

3.

Android Studio混淆编译时,Generate Signed APK遇到

Execution failed for task ':app:packageRelease'
Unable to compute hash of XXX\classes.jar

 返回到cmd里面执行

gradle packageRelease --stacktrace

 获取到核心err信息

java.io.IOException: The same input jar XXX is specified twice

 解决方法

把proguard-rules.pro中自己定义的 -libraryjars 都注释掉

相关推荐