Android Studio(IntelliJ IDEA)使用笔记

防止程序运行时打开logcat(Android Monitor)

Run > Edit Configurations... > Android Applications > app > Miscellaneous
去勾(不选)Show logcat automatically
How to prevent AndroidStudio from opening LogCat (tab) when pressing “Run”?

导入Eclipse ADT工程

File > New > Import Project...
然后选择工程所在目录
Migrating from Eclipse ADT

常用编辑器设置:显示行号等

File > Settings > Editor > General > Appearence
显示行号:Show line numbers
How can I permanently have line numbers in IntelliJ?
显示空白提示:Show whitespaces
File > Settings > Editor > General > Auto Import
自动删除不需要的import:Optimize import on the fly
自动添加所需要的import:Add unamiguous import on the fly

自动编译

File > Settings > Build, Exception, Deployment > Compiler
勾选 Make project automatically
Intellij IDEA Java classes not auto compiling on save

Gradle插件与代理服务器

在使用代理服务器上网的情况下,必须为Gradle插件设置代理服务器:
File > Settings > Appearance & Behavior > System Settings > Http Proxy
或者直接修改工程中 gradle.properties 文件
(如果使用https的话只能直接修改这个属性文件)
Gradle Sync failed while using proxy server

SDK Manager与代理服务器

在使用代理服务器上网的情况下,必须为SDK Manager设置代理服务器:
Tools > Android > SDK Manager > Launch Standalone SDK Manager
打开独立程序SDK Manager
Tools > Settings
在打开的Settings对话框中设置 Http Proxy Server 以及 Http Proxy Port
然后勾选 Force https://... sources to be fetched using http://...
Android SDK Manager won't update: connection to https://dl-ssl.google.com refused

Android Emulator与代理服务器

在使用代理服务器上网的情况下,必须为Android Emulator设置代理服务器:
Settings > Wireless & networks > More > Mobile(Cellular) networks > Access Point Names > T-Mobile US
设置Proxy与Port等代理服务器信息,然后打开菜单Save
回到Wireless & networks后切换一次Airplane mode让新的设置生效
How do I add -http-proxy to an android emulator launch from Android Studio 2.0

Gradle同步与代理服务器

在使用代理服务器上网的情况下,在Gradle同步时可能因为无法下载数字证书而在下载程序包时出错:
Unable to find valid certification path to requested target
此时需要

  1. 将 build.gradle 中的各个 maven 中心仓库的下载地址改为 http:
    jcenter() 改为 maven { url "http://jcenter.bintray.com"}
    mavenCentral() 改为 maven { url "http://repo.maven.apache.org/maven2/"}
  2. 将 gradle-wrapper.properties 中的 gradle下载地址改为 http:
    distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
    改为
    distributionUrl=http\://services.gradle.org/distributions/gradle-3.3-all.zip
  3. 访问各个 maven 中心仓库,手动下载数字证书。
    访问 https://jcenter.bintray.com,打开 Google的开发工具,找到 Security 页,下载证书并保存为 xxx.cer 文件。
    访问 https://repo.maven.apache.org/maven2/,如法炮制。
  4. 在 Android Studio 中导入数字证书
    File > Settings > Tools > Server Certificates
    这里可以添加数字证书。
  5. 在 Android Studio 所使用的 JDK 中导入数字证书
    File > Project Structure > SDK Location > JDK Location
    这里先确认 SDK 的位置。
    下载并安装 KeyStore Explorer
    以管理员身份启动 KeyStore Explorer。
    打开 JDK 的 cacerts 文件(在 JDK 安装目录的 jre\lib\security 下)
    输入密码 changeit
    导入数字证书文件 xxx.cer
    保存并退出。
Android Studio - Unable to find valid certification path to requested target

Gradle编译太慢

在 <username>\.gradle 下新建 gradle.properties 文件,并添加以下这一行:
org.gradle.daemon=true
Building and running app via Gradle and Android Studio is slower than via Eclipse

Project View 与编辑窗口同步

点击 Project View 右上角的齿轮图标
选择 Autoscroll to source 或 Autoscroll from source
How do you track an active file in the project list in Android Studio?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值