VirtualBoxでICS的
手順
- VirtualBox用のICSイメージを取得する
- 起動確認できたら終了
- VM設定画面でネットワークアダプタを「ブリッジアダプタ」に変更
- 起動する
- VMのIPアドレス確認
- ADBHOSTの設定
- デバイスが見れるのを確認
VirtualBox用のICSイメージを取得する
このサイトでVirtualBoxのイメージを取得する
http://www.borncity.com/blog/2011/11/28/testing-android-x86-ice-cream-sandwich-image-from-vmlite/
少し下の「for free download.」リンクからDL
ファイル名:Android-v4.7z
ネットワーク設定の変更
VM設定画面でネットワークアダプタを「ブリッジアダプタ」に変更
起動する
IPアドレスの確認
以下のコードを適当なサーバに上げて、VMでDLしてインストールして実行
書くのメンドクサイやつはこっからもってけ
http://bit.ly/wtolVw
package com.hidecheck.ipaddress; import java.io.IOException; import java.net.InetAddress; import java.net.NetworkInterface; import java.util.Enumeration; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class IPAddressSampleActivity extends Activity { public static final String BR = System.getProperty("line.separator"); /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView tv = (TextView)findViewById(R.id.text_ipaddress); StringBuilder sb = new StringBuilder(); try { sb.append(getIpAddress()); } catch (IOException e) { e.printStackTrace(); } tv.setText(sb.toString()); } private String getIpAddress() throws IOException{ StringBuilder sb = new StringBuilder(); Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while(interfaces.hasMoreElements()){ NetworkInterface network = interfaces.nextElement(); Enumeration<InetAddress> addresses = network.getInetAddresses(); while(addresses.hasMoreElements()){ String address = addresses.nextElement().getHostAddress(); //127.0.0.1と0.0.0.0以外のアドレスが見つかったらそれを返す if(!"127.0.0.1".equals(address) && !"0.0.0.0".equals(address)){ sb.append(address); sb.append(BR); } } } return sb.toString(); } }
ADBHOSTの設定
adbhostを設定してadb-serverの再起動
デバイスが見れたらOK
ついでにEclipseから見れることも確認してみよう
export ADBHOST=[ip address] $ adb kill-server $ adb devices * daemon not running. starting it now on port 5037 * * daemon started successfully * List of devices attached emulator-5554 device
2/25 wPhone勉強会もよろしくね
AndroidだらけのwPhone(ウーフォン)勉強会
お題「x86のエミュレータをビルドする」