环境搭建所需可至 http://pan.baidu.com/s/1gd1Kf4Z 下载
注:
此处假定 Ubuntu 用户名为 chenfei
开发相关全部存放在 /home/chenfei/Dev/ 下
一、准备
1.1 下载 JDK
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
选择 Accept License Agreement
选择 Linux x64 tar.gz 进行下载
此处选择 jdk-7u51-linux-x64.tar.gz 进行下载
文件: /home/chenfei/Dev/jdk-7u51-linux-x64.tar.gz
1.2 下载 Android SDK
http://developer.android.com/sdk/index.html
选择其他平台
文件: /home/chenfei/Dev/android-sdk_r22.3-linux.tgz
1.3 下载 IntelliJ IDEA
http://www.jetbrains.com/idea/
http://www.jetbrains.com/idea/download/
选择 Linux,下载 Community Edition 版本
文件: /home/chenfei/Dev/ ideaIC-13.0.1.tar.gz
1.4 下载 Genymotion 及 IntelliJ IDEA 的 Genymotion 插件
https://cloud.genymotion.com/page/launchpad/download/
文件:
/home/chenfei/Dev/genymotion-2.0.3_x64.bin
/home/chenfei/Dev/genymotion-idea-plugin-20130716.jar
1.5 注册 Genymotion
https://cloud.genymotion.com/
二、安装
打开 “终端” / “Terminal” 执行如下命令进入 Dev 目录:
cd Dev/
2.1 安装 JDK
tar zxvf jdk-7u51-linux-x64.tar.gz
目录: /home/chenfei/Dev/jdk1.7.0_51
2.2 安装 Android SDK
tar zxvf android-sdk_r22.3-linux.tgz
目录: /home/chenfei/Dev/android-sdk-linux
2.3 安装 VisutalBox
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian quantal non-free contrib" >> /etc/apt/sources.list.d/virtualbox.org.list'
sudo apt-get update
sudo apt-get install virtualbox-4.3
2.4 安装 Genymotion
chmod +x genymotion-2.0.3_x64.bin
./ genymotion-2.0.3_x64.bin
目录: /home/chenfei/Dev/genymotion
2.5 安装 IntelliJ IDEA
tar zxvf ideaIC-13.0.1.tar.gz
目录: /home/chenfei/Dev/idea-IC-133.331
三、配置
3.1 配置 JDK
执行: sudo gedit /etc/profile 打开 profile 文件,复制如下内容到文件末尾,并保存:
export JAVA_HOME=/home/chenfei/Dev/jdk1.7.0_51
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:${PATH}
注销重新登录
3.2 配置 Android SDK
执行: /home/chenfei/Dev/android-sdk-linux/tools/android 打开 Android SDK Manager
等待联网加载 packages 完毕
安装:
Tools
Android SDK Platform-tools
Android SDK Build-tools
Android 4.4.2 (API 19)
Documentation for Android SDK
SDK Platform
ARM EABI v7a System Image
Intel x86 Atom System Image
Google APIs
Sources for Android SDK
Extras
Android Support Library
点击 Install 9 packages --> Choose Packages to install --> 依次选中安装项下 Accept --> Install
等待下载安装完毕,关闭 “Android SDK Manager” 窗口
执行: sudo gedit /etc/profile 打开 profile 文件,复制如下内容到文件末尾,并保存:
export ANDROID_SDK_HOME= /home/chenfei/Dev/android-sdk-linux
export PATH=${ANDROID_SDK_HOME}/tools: ${ANDROID_SDK_HOME}/platform-tools : ${PATH}
3.3 配置 Genymotion
执行: /home/chenfei/Dev/genymotion/ genymotion 打开 Genymotion
3.3.1 新增虚拟设备
Add a first virtual device --> Yes --> “Virtual device creation wizard”
Connect --> “Connect to Genymotion Cloud”
Username --> Password --> Connect
选择虚拟设备 --> Next --> “Name of the Genymotion virtual device to create” --> Next --> “Retrieve and deploy Genymotion virtual device”
等待下载完成 --> Finish
3.3.2 Settings
General
ADB
/home/chenfei/Dev/android-sdk-linux
OK
3.4 配置 IntelliJ IDEA
打开主文件夹
进入目录: /home/chenfei/Dev/idea-IC-133.331/bin/ 双击 idea.sh,点击 “运行”,打开 IntelliJ IDEA
I do not have a previous version of IntelliJ IDEA or I do not want to import my settings --> OK
3.4.1 锁定到启动器
右击 “IntelliJ IDEA” 在启动器上的图标
锁定到启动器
3.4.2 安装 IntelliJ IDEA 的 Genymotion 插件
Plugins --> Install plugin from disk --> /home/chenfei/Dev/genymotion-idea-plugin-20130716.jar --> OK
OK --> Restart
3.4.2 创建 Empty Project
Finish --> “Empty Project - - IntelliJ IDEA 13.0.1 ”
关闭 “Project Structure”
3.4.3 配置 IntelliJ IDEA
3.4.3.1 View --> Toolbar
3.4.3.2 View --> Tool Buttons
3.4.3.3
File --> Settings... --> “Settings”
Genymotion --> Select the path to the Genymotion folder --> /home/chenfei/Dev/genymotion --> OK --> OK
3.4.3.4
待补充
四、开发
4.1 创建Android Module
File --> New Module --> “New Module”
Application Module --> Module name --> Module SDK
Module name : HelloWord
Module SDK :
New... --> “Cannot Create SDK”
OK --> “Select Home Directory for JDK”
/home/chenfei/Dev/jdk1.7.0_51 --> OK --> “Select Home Directory for Android SDK”
/home/chenfei/Dev/android-sdk-linux --> OK --> “Create New Android SDK”
OK
Next --> Application name --> Package name* --> Create "Hello, World!" activity --> Activity name --> Show device chooser dialog --> Finish
4.2 运行
4.2.1 运行 Genymotion 虚拟设备
点击 --> “Genymotion Device Manager”
选择 3.3.1 中创建的虚拟设备 --> Start...
等待虚拟设备启动完成后关闭 “Genymotion Device Manager”
4.2.2 运行 Android 程序
点击 --> “Choose Device” --> Choose a running device --> 选择刚启动的虚拟设备 --> OK