环境搭建所需可至 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
选择其他平台
![](https://i-blog.csdnimg.cn/blog_migrate/e95f6333a93ba356392ced6c2b57c050.png)
![](https://i-blog.csdnimg.cn/blog_migrate/66cff121a4bb5d58bae1f7afd4e61942.png)
![](https://i-blog.csdnimg.cn/blog_migrate/ffab4a1fa3e04128d8954d2cbb6f5980.png)
文件:
/home/chenfei/Dev/android-sdk_r22.3-linux.tgz
1.3 下载 IntelliJ IDEA
http://www.jetbrains.com/idea/
http://www.jetbrains.com/idea/download/
![](https://i-blog.csdnimg.cn/blog_migrate/49e6d7c478ea885964b8844f39711a38.png)
选择 Linux,下载 Community Edition 版本
![](https://i-blog.csdnimg.cn/blog_migrate/92bc9e438a081f1f75c352d983449257.png)
文件:
/home/chenfei/Dev/
ideaIC-13.0.1.tar.gz
1.4 下载 Genymotion 及
IntelliJ IDEA 的 Genymotion 插件
https://cloud.genymotion.com/page/launchpad/download/
![](https://i-blog.csdnimg.cn/blog_migrate/caff8e1a47f5877094769a3019a6bd5e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1775700a13857cae320f9f1a3ecedd99.png)
文件:
/home/chenfei/Dev/genymotion-2.0.3_x64.bin
/home/chenfei/Dev/genymotion-idea-plugin-20130716.jar
1.5 注册 Genymotion
https://cloud.genymotion.com/
![](https://i-blog.csdnimg.cn/blog_migrate/49e6d7c478ea885964b8844f39711a38.png)
二、安装
打开 “终端” / “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
![](https://i-blog.csdnimg.cn/blog_migrate/f1301d3fc37249fd47b3aced9a7fd39c.png)
ADB
![](https://i-blog.csdnimg.cn/blog_migrate/7f20093ab931c97d72d269c68bb3ab10.png)
/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” 在启动器上的图标
![](https://i-blog.csdnimg.cn/blog_migrate/bc772536d7bc12bea3f46d610b95aeb4.jpeg)
锁定到启动器
3.4.2
安装 IntelliJ IDEA 的 Genymotion 插件
![](https://i-blog.csdnimg.cn/blog_migrate/837f7b470b1cd4ae8f07f66658e150f2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/cc3cbe64616707e7f76ea8bdb615dc68.png)
Plugins --> Install plugin from disk -->
/home/chenfei/Dev/genymotion-idea-plugin-20130716.jar --> OK
OK --> Restart
3.4.2 创建 Empty Project
![](https://i-blog.csdnimg.cn/blog_migrate/2d2735dd6f9416786b49c596b5e074c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f087bda43c11cd494f85491c931ef2b1.png)
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
![](https://i-blog.csdnimg.cn/blog_migrate/3277c773a777ae134007a957cc0d32b9.png)
Module name : HelloWord
Module SDK :
New... --> “Cannot Create SDK”
![](https://i-blog.csdnimg.cn/blog_migrate/95a657dc36d1d550aa4bd6038ae61dc5.png)
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”
![](https://i-blog.csdnimg.cn/blog_migrate/4eb42d2c0ae2354d5a4a28bf8f280dd8.png)
OK
Next --> Application name --> Package name* --> Create "Hello, World!" activity --> Activity name --> Show device chooser dialog --> Finish
![](https://i-blog.csdnimg.cn/blog_migrate/0311be18a3e16c447d90e0e7aa1da332.png)
4.2 运行
![](https://i-blog.csdnimg.cn/blog_migrate/e7d0258a51b8e13bfe6184eac4c8b745.png)
4.2.1 运行 Genymotion 虚拟设备
点击
--> “Genymotion Device Manager”
![](https://i-blog.csdnimg.cn/blog_migrate/c0de35eb841e8f895d5efb0707b892cf.png)
选择 3.3.1 中创建的虚拟设备 --> Start...
等待虚拟设备启动完成后关闭 “Genymotion Device Manager”
4.2.2 运行 Android 程序
点击
--> “Choose Device” --> Choose a running device --> 选择刚启动的虚拟设备 --> OK
![](https://i-blog.csdnimg.cn/blog_migrate/db662dcda1121ce25af800875d88a7af.png)