2011年8月30日 星期二

VirtualBox 與Guest Additions 安裝


由於工作上需要使用舊版本的Sun VirtualBox,但是由於顯示效果無法放到最大,所以改用下列方式解決
Step 1:  下載 VirtualBox Guest Additions ISO
你使用 VirtualBox 選單的「安裝 Guest Additions ...」之後,VirtualBox 通常會自動下載客端額外功能軟體的 CD ISO 影像檔,並且自動掛載。
若你使用的Ubuntu 太新,需要自行到官方網站下載 http://download.virtualbox.org/virtualbox/ , 選擇越新版的越好。
Step 2: 掛載 VBoxGuestAdditions CD ISO檔後,開啟它,並以 root 的權限執行其中的 VBoxLinuxAdditions-x86.run (32bit) / VBoxLinuxAdditions-amd64.run (64bit)。
Step 3: 用putty連線進去,關閉 gdm。
root@wayne-NB:~#  sudo service gdm stop
Step 4: 設定螢幕解析度,並重新啟動 gdm。
root@wayne-NB:~# sudo bash
root@wayne-NB:~# Xorg -configure

X.Org X Server 1.10.1
Release Date: 2011-04-15
X Protocol Version 11, Revision 0
Build Operating System: Linux 2.6.24-29-server i686 Ubuntu
Current Operating System: Linux wayne-NB 3.0.3 #1 SMP Mon Aug 29 17:15:22 CST 2011 i686
Kernel command line: BOOT_IMAGE=/boot/vmlinuz-3.0.3 root=/dev/sda1 ro quiet splash vt.handoff=7
Build Date: 19 April 2011  03:33:17PM
xorg-server 2:1.10.1-1ubuntu1 (For technical support please see http://www.ubuntu.com/support)
Current version of pixman: 0.20.2
        Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Tue Aug 30 14:13:14 2011
List of video drivers:
        mga
        savage
        r128
        ati
        nouveau
        radeon
        siliconmotion
        intel
        cirrus
        rendition
        vmwlegacy
        apm
        sis
        s3virge
        vmware
        voodoo
        ztv
        i740
        openchrome
        sisusb
        trident
        ark
        i128
        neomagic
        qxl
        s3
        geode
        tdfx
        chips
        tseng
        mach64
        vboxvideo
        fbdev
        vesa
(EE) Failed to load module "vmwgfx" (module does not exist, 0)
(EE) vmware: Please ignore the above warnings about not being able to to load module/driver vmwgfx
(EE) vmware: Unexpected failure while loading the "vmwlegacy" driver. Giving up.
(EE) Failed to load module "vmware" (a required submodule could not be loaded, -1074796280)
(++) Using config file: "/root/xorg.conf.new"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
(EE) open /dev/fb0: No such file or directory
Number of created screens does not match number of detected devices.
  Configuration failed.
ddxSigGiveUp: Closing log
root@wayne-NB:~# cp xorg.conf.new /etc/X11/xorg.conf
root@wayne-NB:~# service gdm start
gdm start/running, process 5080

Step 4:那麼在「顯示」控制台中,選擇我們所想要的螢幕解析度。
當我安裝額外功能並重新啟動 guest 系統後的第一次晝面,我的螢幕解析度有 1280x768 (按預設 12MB 顯示記憶體)。我啟動 Ubuntu Desktop 的「顯示」控制台,一開始顯示我可以選擇從 1280x768 到 640x480 的5種解析度。接著我將螢幕解析度下調到 1024x768。調整完畢後,我很訝異地發現,在「顯示」控制台內,我可以選擇的解析度只剩下 1024x768 到 640x480 的3種解析度了。我沒有辦法再往上調整更高的解析度了。
如果你跟我一樣碰到這種情形,我們需要編輯 /etc/X11/xorg.conf ,手動在 Screen 段落中,加入 Display 的子段落,明確地列出我們希望能調整的解析度項目。如下所示:
Section "Screen"
   Identifier   "Default Screen"
   Monitor      "Configured Monitor"
   Device      "Configured Video Device"

   DefaultDepth    24
   SubSection      "Display"
      Depth           24
      Modes           "800x600" "1440x900" "1360x768" "1280x1024" "1280x960" "1152x864" "1024x768" 
   EndSubSection

EndSection

上例設定範例,列出7種解析度,那麼在「顯示」控制台中,就會至少出現這7種解析度供我們選擇。不再愈調愈少。
登入晝面(GDM)會取 Modes 中的第一個項目作為解析度。所以我把 800x600 放在第一個。

2011年6月3日 星期五

在 Ubuntu 設置 Android 開發環境

1. 下載 eclipse
http://www.eclipse.org/downloads/
"Eclipse IDE for Java Developers" -> eclipse-java-ganymede-SR2-linux-gtk.tar.gz
解壓縮到 /home/kiang/programs/android/eclipse
2. 下載 ADT
http://developer.android.com/sdk/adt_download.html
-> ADT-0.9.0.zip
3. 下載 Android SDK
http://developer.android.com/sdk/1.5_r1/index.html
-> android-sdk-linux_x86-1.5_r1.zip
解壓縮到 /home/kiang/programs/android-sdk-linux_x86-1.5_r1
4. 開啟 eclipse
-> 執行 /home/kiang/programs/android/eclipse/eclipse
*我的 workspace 設定在 /home/kiang/android
5. 安裝 ADT
5.1 點選 Help > Software Updates....
5.2 點選 Available Software
5.3 點選 Add Site...
5.4 點選 Archive... ,跟著視窗引導找到剛剛下載的 ADT-0.9.0.zip
5.5 點選 OK
5.6 在左邊找到 jar:file/xxx/ADT-0.9.0.zip!/ ,勾選它
5.7 點選右邊的 Install...
5.8 等... 視窗會停在 Calculating requirements and dependencies 狀態,因為在下載有依存關係的外掛
*官方比較建議用 update 方式安裝:
http://developer.android.com/guide/developing/tools/adt.html#installingplugin
但不知為何,一直出現錯誤,所以改採離線方式安裝
6. 設定 Android SDK
6.1 點選 Window -> Preferences
6.2 點選 Android
-> 在這裡會出現錯誤訊息,會問要不要離開程式,選擇不要
6.3 點選 SDK Location 右邊的 Browse... 按鈕,指向
/home/kiang/programs/android-sdk-linux_x86-1.5_r1
7. 新增 Android 專案
7.1 點選 File -> New -> Project...
7.2 點選 Android 旁的箭頭將它展開,選擇 Android Project ,接著點選 Next
7.3 表單:
Project name - helloWorld
Build Target - Android 1.5
Properties
Application name: helloWorld
Package name: helloWorld.android.olc.tw
Create Activity: helloWorld
7.4 點選 Finish
完成後如果出現下面錯誤:
no classfiles specified
Conversion to Dalvik format failed with error 1
點一下 Project -> Clean... ,參考這篇討論:
http://groups.google.com/group/android-beginners/browse_thread/thread/38ed44f6a915ee60
想要執行剛剛建立的程式時會出現下面這個錯誤:
Failed to find an AVD compatible with target 'Android 1.5'. Launch aborted.
...原來還沒完成設定,參考這篇討論:
http://developer.android.com/guide/developing/eclipse-adt.html#Running
8. 產生虛擬機器 AVD
kiang@kiang-ubuntu:~/programs/android-sdk-linux_x86-1.5_r1/tools$ ./android create avd --name avdKiang --target 2
Android 1.5 is a basic Android platform.
Do you wish to create a custom hardware profile [no]
Created AVD 'avdKiang' based on Android 1.5
9. 在專案圖示點選右鍵 ,選擇 Run As -> Android Application 就可以看到空的模擬器了

 Ubuntu has a mechanism, that is, the installed network card (NIC) will be renamed to another name when the system is booted. Although there...