Android Studio 使用技巧

初次使用 Android Studio(后文用 AS 替代),会碰到和 Eclipse 不同的问题,此外还会踩到这样或那样的“坑”。本文做长期的更新,记录使用 AS IDE 过程遇到的问题。html

0. 启动 AS 时,报错“Failed to create JVM: error code -4.”bash

缘由:安装时配置的内存过大,致使内存不够用。app

解决办法:找到安装目录的 bin 目录,编辑其中的 studio.ext.vmoptions 文件,设置: -Xmx750m 为: -Xmx512m 便可。保存文件,从新启动。jvm

1. 建立 Project 和 Moduleide

1

Minimum SDK 选择为 API 16:Android 4.1版本gradle

2

新建立的 Project 时,默认的 Module 为 app,上图为该 Module 设置 Activity Name 和 Layout Name。注意:若勾选“Backwords Compatibility (AppCompat)”,则新建的 MainActivity 会继承自 AppCompatActivity。ui

3

上图为建立新的 Module 。其中 Application/Library name 指应用程序名称,也就是显示在设备上的App名称;Module name 指的是该 Project 中的模块名称。spa

2. 启动 Android Studio 报错,环境以下:JDK 1.8.xx 32bit code

Error:Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/3.3/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 1572864KB object heap

解决办法:修改 Project的 gradle.properties内容:org.gradle.jvmargs=-Xmx1536m为:1024便可正常运行。(前者为1.5GB内存空间,修改成后者的1.0GB)htm

相关文章
相关标签/搜索