2012年7月24日 星期二

ubuntu 12.04安裝android emulation

※082412另一較快方式,平板電腦大畫面,請到8月
ubuntu 12.04用virtualbox安裝android android-x86-4.0-RC2

072612整理如下

sudo add-apt-repository ppa:upubuntu-com/devel

sudo apt-get update

sudo apt-get install android-sdk

Note: Android SDK will be installed in the "/usr/bin/android-sdk-linux" folder), you should include this path in Eclipse (Preferences window) after adding the ADT plugin.

上述裝好後,
在 附屬應用程式 有 Android SDK Manager
在 軟体開發 有 Eplicse

方法1→簡單
(從 Android SDK Manager→Tools
先安裝 Android SDK Tools, Android SDK Platform-tools
要幾次重入更新
"..., if use Eclipse, Help > check for Update,..."
Android SDK Tools rev 20.0.1
Android SDK Platform-tools rev 13
增加Android 4.1(API 16)所有6項,要安裝很久
則Android SDK Manager→Tools會出現test Android 4.1→start)

方法2→一步一步完成
從 Eplicse

Use the dash to start Eclipse and go to Help > Install New Software
In the pop-up window, click the Add button and enter the following details and click OK:

Name: ADT Plugin
Location: https://dl-ssl.google.com/android/eclipse/

Check on Developer Tools and click Next:

You will shortly get a list of tools to be downloaded. Click Next:

Accept terms of the license agreements and click Finish to start the installation of selected items:

When the installation finishes, restart Eclipse so that changes take effect. You can now start developing your Android apps and games!

中途顯示要認證續安裝,完後重新reload Elipse,顯示要install new SDK,
※改選Target Location→/usr/bin/android-sdk-linux
Contribute UsageStatistics?→yes→finish
Choose Packages to install→3個依次選安裝(選第1個,3個會自動安裝)
(SDK v14→v20)
Android SDK Tools rev 20.0.1
Android SDK Platform-tools rev 13
Android 4.1(API 16)
結束後由Android進入,找所有not installed安裝(要安裝很久)

完後由Android SDK Manager進入,由tools→new→test→等Android 4.1(API 16)→512(MB)→等test ADV出現→start
→Launch→ok成功了→第1次要等很久
以後只要由Android SDK Manager進入,由tools→Manager ADVs..→test→Start→Launch


Android圖示在下(072412 安裝成功)之後

072412 安裝成功
取自How To Install Android SDK (Release 18) Via PPA On Ubuntu 12.04/11.10
http://www.upubuntu.com/2012/05/how-to-install-android-sdk-release-18.html
並參考
http://milochen.wordpress.com/2010/05/22/newbie-tutorial-to-create-android-app-developer-environment-on-ubuntu-10-04-9-10-64bits/
在Eclipse的設定圖片

Android SDK is a development kit targeted at mobile devices running the Android operating system. With Android SDK, you can develop, debug, and test apps via a built-in emulator that emulates the Android OS in many platforms (Linux, Windows, etc.).

In this page we will help you install the latest vesrion of Android SDK (Release 18) under Ubuntu 12.04/11.10 via our PPA. If you want to install it manually, you can check this page for more information.


Android SDK (Release 18) Installation


Open the terminal and run the following commands to install Android SDK + Eclipse on Ubuntu 12.04/11.10:

sudo add-apt-repository ppa:upubuntu-com/devel

sudo apt-get update

sudo apt-get install android-sdk

Note: Android SDK will be installed in the "/usr/bin/android-sdk-linux" folder), you should include this path in Eclipse (Preferences window) after adding the ADT plugin.

You can now start Android SDK Manager from the Unity dash to start adding Android platforms and other related packages:
可由此開始 Android SDK Manager


ADT Plugin Installation in Eclipse


Use the dash to start Eclipse and go to Help Install Software:


In the pop-up window, click the Add button and enter the following details and click OK:

NameADT Plugin
Locationhttps://dl-ssl.google.com/android/eclipse/


Check on Developer Tools and click Next:


You will shortly get a list of tools to be downloaded. Click Next:


Accept terms of the license agreements and click Finish to start the installation of selected items:


When the installation finishes, restart Eclipse so that changes take effect. You can now start developing your Android apps and games!
或由Eclipse開始
※右側的test Adv要先建好,才會出現左側→按Start啟動Android
    或由Eclipse→Windows→AVD manager→按Start啟動Android

要等一下才會全顯示














072312取自
http://imzzh.com/android/avd-to-install ... -apps.html
※我依此安裝失敗※
Android SDK 在这里(http://developer.android.com/sdk/index.html),选择"Linux (i386)"下载到本地解压,解压后得到android-sdk-linux文件夹,命令行运行:
$ tools/android
在出现的 Android SDK 管理器图形界面中,勾选 Tools下的Android SDK Platform-tools 和 Android 2.3.3(API 10)下的 SDK Platform(具体的Android版本可以自己挑选,我选择2.3的原因是该版本下 软件比较多,也可以同时安装多个版本),点击 "Install" 按钮开始下载,然后等待安装完成关闭。→Android 4.1(API 16)
把sdk下的工具添加到系统path中:
$ sudo gedit /etc/profile
加入:
export PATH=/home/user/programs/android-sdk-linux/tools:/home/user/programs/android-sdk-linux/platform-tools
如果原来已经有path了,则接在后面,用:隔开
其中/home/user/programs/android-sdk-linux为我的Android SDK解压目录。
重启电脑
072412
u11.10重開機登入後顯示terminal error
到http://www.89geek.com/2012/01/fix-ubuntu-could-not-connect-to-bus.html

Fix Ubuntu "Could not connect to bus session" Problem

Good evening, the full error message is "could not connect to session bus: //bin/dbus-launch terminated abnormally without any error message" if you are facing this error that's because something is wrong with your PATH variable. To fix this problem press Ctrl+Alt+F2 log in and type

echo "export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" >> .profile
That's it, reboot your system and everything should be work


..

创建安卓模拟器

在终端下,运行:
$ android
调出 Android SDK 管理器图形界面中,选择菜单栏中的 Tools-》Manager AVDs,
进入模拟器管理界面:
1
新建一个安卓模拟器:
2
如上图我们创建了一个名字为test,安卓版本为2.3的模拟器。
接下来打开终端,输入:
emulator -avd test -memory 512 -partition-size 1024 -scale 0.8
这段命令很重要,因为默认的模拟器只有64M内存,在这段命令中,我们设置了内存为1G,可以加速虚模拟器,而且可以装更多的软件。其中-scale参数用于设置模拟器大小,可以自行调整

让安卓模拟器连上网

默认模拟器无法上网,因为他的默认ip和dns都是错的。
接下来我们来设置模拟器的ip和dns(局域网下):
模拟器启动完全以后(重要,必须等到安卓系统完全启动完毕,否则后续命令可能报错),打开终端,输入:
$ adb shell //如果报Device not found,可能是模拟器还在启动。如果已经启动完全,仍报错,关闭并重启模拟器,
$ getprop
//这一步可以发现安卓默认的ip和dns
3
$ setprop net.eth0.dns1 192.168.0.1//设置dns
$ setprop net.gprs.local-ip 192.168.0.200//设置ip
OK,现在,安卓模拟器 已经可以上网了.

到网上下载安卓程序安装包,后缀为apk
shell中执行:
adb connect 192.168.0.200
1,安装单个软件:在终端中输入:
adb install apk文件
2,安装多个软件,如果你下载了很多apk包,一个一个安装比较累。
解决方案:
(1)下载 easy_installer,并在shell下安装:
adb install easy_installer.apk
该软件可以实现批量安装软件
(2) 将test模拟器的SD卡的img文件(位于主目录的.android目录下)挂载在某文件夹下
先关闭模拟器(重要)
mkdir ~/img
sudo mount -o loop ~/.android/avd/test.avd/sdcard.img ~/img
右击主文件夹下的img文件夹,选择以管理员身份打开。把下载好的所有apk包都放到img文件夹下。
最后执行
sudo umount ~/img
重新打开模拟器:
emulator -avd test -memory 512 -partition-size 1024 -scale 0.8
用第一步已经安装好的easy_installer软件开始批量安装软件,开始试玩咯。
如果发现模拟器不能上网,请重新执行 《让安卓模拟器连上网》 这一步
Android是个好东西,祝大家玩的愉快,^_^。
附效果图一张:
0

 

 



沒有留言: