【经验】Android Gradle配置问题
2016-04-03 21:18
435 查看
翻墙后搞了一天Gradle,到处找资料,结果都不行,记录一点经验,以备之后再次出错
一、有时,配置Gradle出现如下错误
![](https://img-blog.csdn.net/20160403211113282?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
偶然间stackoverflow上找到个可用的方法,先看看下面我的build.gradle
解决这个问题,只要把allprojects{}之后的东西全部删掉即可
如下所示
二、git clone下来的文件在AS中使用时,经常性卡在gradle里,尝试了下解决方法,大致如下,很大机会能保证正常编译,但不100%保证能编译成功
1.在工程目录下有gradle/wrapper/gradle-wrapper.properties文件,其中有一句类似于
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip修改其中gradle-xx.zip的版本号,改为你现在有的
2.其中下面gradle版本号也改为你能用的一个(新建一个项目,看看里面对应的用的是哪个版本)dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-rc1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
3.另外,此处版本也相应改为和1处相同的版本
一、有时,配置Gradle出现如下错误
Gradle DSL method not found:'android()'
偶然间stackoverflow上找到个可用的方法,先看看下面我的build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.0.0-rc1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } android { compileSdkVersion 22 buildToolsVersion '23.0.3' }
解决这个问题,只要把allprojects{}之后的东西全部删掉即可
如下所示
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.0.0-rc1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } }
二、git clone下来的文件在AS中使用时,经常性卡在gradle里,尝试了下解决方法,大致如下,很大机会能保证正常编译,但不100%保证能编译成功
1.在工程目录下有gradle/wrapper/gradle-wrapper.properties文件,其中有一句类似于
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip修改其中gradle-xx.zip的版本号,改为你现在有的
2.其中下面gradle版本号也改为你能用的一个(新建一个项目,看看里面对应的用的是哪个版本)dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-rc1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
3.另外,此处版本也相应改为和1处相同的版本
相关文章推荐
- Android设计模式应用-桥接模式
- Android入门(二十二)解析JSON
- Android入门(二十一)解析XML
- Android入门(十八)服务
- Android入门(十七)Android多线程
- Android入门(十六)调用摄像头相册
- Android入门(十五)通知
- Android入门(十四)内容提供器-实现跨程序共享实例
- Android入门(十三)内容提供器
- Android部分常用控件
- Android入门(十二)SQLite事务、升级数据库
- Android入门(十一)SQLite CURD
- Android入门(十)SQLite创建升级数据库
- Android之SurfaceView使用总结
- Android入门(九)文件存储与SharedPreferences存储
- Android入门(八)广播
- Android入门(七)碎片的生命周期与限定符
- Android中View的事件体系(1)——坐标体系与移动
- Android入门(六)碎片
- Android中自定义控件的步骤