官方文档
离线更新Gradle:
gradle下载地址
然后再c盘下的路径C:\Users\Administrator\.gradle\wrapper\dists,有一个gradle版本,进入后有一个乱码的文件夹,在文件夹下有两个文件.
然后将离线下载的压缩包,放到该路径下,然后启动Android Studio(我这下载的是2.2.1-all.zip).
如果是大版本更新必须联网的话,pc端的话,在gradle里面是没起作用的,需要在gragle.properties设置代理的服务器和端口:
systemProp.http.proxyHost=192.168.13.226
systemProp.http.proxyPort=8580
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost
systemProp.https.proxyHost=192.168.13.226
systemProp.https.proxyPort=8580
systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost
INSTALL_FAILED_OLDER_SDK:
将build.gradle中的最低sdk版本调小点。
编写java项目:
配置项目路径等:
配置model下的build.gradle:
apply plugin: 'java'
apply plugin: 'application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
编写main()方法:
public class MyClass {
public static void main(String[] args) {
System.out.print("hello,java!");
}
}
运行结果:
快速构造方法(get/set):
1.右键->Generate
2.alt+Insert
Task 'assemble' not found in root project 'project':
The real problem is that previous version of Android Studio misconfigured the IDEA file (e.g. MyProject.iml) -- it added an extra "
...remove this element and everything inside such as elements...
...keep this part...
删除FaceManager里面的配置就可以了。
java: -source 1.6 中不支持 switch 中存在字符串
File--->project struct--->Modules --->Sources ---> Language level 改为 7.0就可以了。
gradle依赖第三方项目,导致不能运行的问题:
1.重复导入项目
去掉重复导入的项目即可。
2.com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 655
点击打开链接
同时在工程中引入了多个第三方jar包,导致调用的方法数超过了android设定的65536个(DEX 64K problem),进而导致dex无法生成,也就无法生成APK文件。
3.gradle 更新
离线下载安装 gradle clean后,studio下载 使用命令行 gradle下载
4.SSL peer shut down incorrectly
访问maven仓库不需要。
在build.gradle中:
allprojects {
repositories {
mavenCentral()
}
}