Android Studio简介使用

官方文档

离线更新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,选择java Library:

配置项目路径等:


配置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!");
    }
}

运行main()方法所在的类:

运行结果:


快速构造方法(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 "<component name="FacetManager">" XML element that shouldn't be present. In the case above, the solution is to edit "MyProject.iml" and to remove the "<component name="FacetManager">" part as shown here:

<?xml version="1.0" encoding="UTF-8"?>
<module external.system.id="GRADLE" type="JAVA_MODULE" version="4">
  <component name="FacetManager">
    ...remove this element and everything inside such as <facet> elements...
  </component>
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    ...keep this part...
  </component>
</module>

删除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()
    }
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值