9.04.2014

安裝Android (AOSP) Build Environment

1. Installing the JDK

Java 7: For the latest version of Android
$ sudo apt-get update
$ sudo apt-get install openjdk-7-jdk

Optionally, update the default Java version by running:
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac



2. Installing required packages (Ubuntu 12.04)

You will need a 64-bit version of Ubuntu. Ubuntu 12.04 is recommended. Building using an older version of Ubuntu is not supported on master or recent releases.

$ sudo apt-get install git gnupg flex bison gperf build-essential \
  zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
  libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
  libgl1-mesa-dev g++-multilib mingw32 tofrodos \
  python-markdown libxml2-utils xsltproc zlib1g-dev:i386
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

錯誤訊息:
The following packages have unmet dependencies:
 libgl1-mesa-glx:i386 : Depends: libglapi-mesa:i386 (= 8.0.4-0ubuntu0.6)
                        Recommends: libgl1-mesa-dri:i386 (>= 7.2)
E: Unable to correct problems, you have held broken packages.



參考:http://source.android.com/source/initializing.html


錯誤訊息解法參考:(未測試)
http://www.rover12421.com/2013/08/12/ubuntu-12-04-on-libgl1-mesa-glx-i386-installation-problems.html
http://blog.csdn.net/lqxandroid2012/article/details/9792365


3. 取得Android源始碼


3.1 準備必要的工具

要下載 AOSP 的程式碼,你至少需要 curl、git、python 這三個程式。在 Debian 或 Ubuntu 上面你只要使用:
$ sudo apt-get install curl git python
就可以把它們弄到手。接下來我們要先設定 git:
$ git config --global user.name 名字
$ git config --global user.email email


3.2 下載 repo 版本管理工具

接下來我們必需下載 repo 版本管理工具,我們可以在家目錄之下建立一個資料夾,並把這個資料夾加到 $PATH 裡面:

$ mkdir ~/bin
$ export PATH=~/bin:$PATH 

$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo   (錯誤)
$ curl http://git-repo.googlecode.com/files/repo-1.13 > ~/bin/repo
$ chmod +x ~/bin/repo


3.3 開始下載 Android 程式碼

下載 Android 程式碼,首先我們先建立一個用來放置 Android 程式碼的資料夾:
$ mkdir ~/android-src
$ cd ~/android-src

初始化 repo 相關的設定:(查找自己要下載的版本)
$ repo init -u https://android.googlesource.com/platform/manifest

接著 repo 會問你一些問題,通常使用預設值就可以了。最後就是按下:
$ repo sync
# 備註:你可以加上 -j2 或 -j4 平行下載。


或是選擇自已要下載的版本,這裡舉4.3為例
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.3_r2.1


之後經過漫長的等待,你就會有一份完整的 Android 程式碼!



參考:
http://blog.logan.tw/2011/10/android-open-source-project-android.html
http://blog.chinaunix.net/uid-26074270-id-2458828.html
http://www.360doc.com/content/14/0109/11/11948835_343813571.shtml



Linux捷徑建立


終端機指令:
vm@vm:~$ sudo ln -s /mnt/hgfs/VITA_640GB /home/vm/VITA_640GB


在VM的桌面目錄下建立一個VITA_640GB的捷徑,指向目錄/mnt/hgfs/VITA_640GB.

9.03.2014

Ubuntu 12.04 application shortcut on top panel

建立捷徑
You are logged into Gnome-Classic session with compiz enabled "Gnome-Classic (with effects)". Compiz block those customization.


Drag and drop

  1. First Logout from this session.
  2. Log into "Gnome-Classic (without effects)" session
  3. Then choose a menu item, Press and hold Alt key and drag the icon at the top panel.
You can now Logout and Login again to the "Gnome-Classic (with effect)" session.


Without drag and drop

  1. Login to "Gnome-Classic (No effect)" session
  2. Press and Hold the Alt
  3. While holding Alt key, right click on the top panel
  4. Select "Add to panel"
  5. Choose "Application launcher"
  6. Click on the "Forward" button at the bottom.
  7. Select the desired application icon from the list. You can add a complete category such as "Sound & Video" to the panel!
  8. Click "Add" button or double click the Application entry.
You're done. Now login again to Gnome-Classic (with effect) session.
If you want to remove any icon, Login back to the "gnome-classic (No effect" session and remove the icon by holding the Alt key , right click and select "Remove from panel".


參考:http://superuser.com/questions/476634/ubuntu-12-04-application-shortcut-on-top-panel

Install google chrome on ubuntu 12.04

安裝Chrome

Method 1
We can install chrome from google official repository . first we need to add the repository source to the update manager.
Step 1 » Setup key .
vm@vm:~$ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

Step 2 » Type this command exactly to add chrome repositories .
vm@vm:~$ sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'

Step 3 » Now Update the package list .
vm@vm:~$ sudo apt-get update

Step 4 » Finally install google chrome
vm@vm:~$ sudo apt-get install google-chrome-stable
google chrome ubuntu 12.04

Method 2 : ( Manual installation)
Download google-chrome-stable_current_i386.deb from official google website (https://www.google.com/chrome/) .
Just follow the steps .
Before installing , we need to install dependencies .
Step 1 » Type apt-get update on terminal as a sudo user.
vm@vm:~$ sudo apt-get updateThis command will update the packages list index.

Step 2 » Now we need to install libnss3-1d and libxss1
vm@vm:~$ sudo apt-get install libnss3-1d libxss1

Step 3 »  Finally install the downloaded package.
vm@vm:~$sudo dpkg -i google-chrome-stable_current_i386.deb

google chrome manual installation ubuntu 12_04



參考:http://www.krizna.com/ubuntu/install-google-chrome-ubuntu-12-04/

Installing VMware Tools in an Ubuntu virtual machine

視窗調整問題
Ubuntu or Ubuntu Server with a graphical user interface

To mount the CD image and extract the contents:
Power on the virtual machine.
Log into the virtual machine using an account with administrator or root privileges.
Go to Virtual Machine > Install VMware Tools (or VM > Install VMware Tools).

Note: If you are running the light version of Fusion, a version of Workstation without VMware Tools, or VMware Player, you are prompted to download VMware Tools before they can be installed. Click Download Now to begin the download.

Open the VMware Tools CD mounted on the Ubuntu desktop.
Right-click the file name that is similar to VMwareTools.x.x.x-xxxx.tar.gz, click Extract to, and select the Ubuntu Desktop to save the extracted contents.

The vmware-tools-distrib folder is extracted to the Ubuntu Desktop.
To install VMware Tools in Ubuntu:

1. Open a Terminal window. For more information, see Opening a command or shell prompt (1003892).
2. In the Terminal, run this command to navigate to the vmware-tools-distrib folder:
cd Desktop/vmware-tools-distrib

3. Run this command to install VMware Tools:
sudo ./vmware-install.pl -d

Note: The -d switch assumes that you want to accept the defaults. If you do not use -d, press Return to accept the defaults or supply your own answers.

4. Enter your Ubuntu password.
5. Restart the Ubuntu virtual machine after the VMware Tools installation completes.






參考:http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1022525

Ubuntu 12.04 切換至傳統介面Gnome

在 Ubuntu Linux 中若想要使用 Gnome 3 的話,就必須要自己裝,這裡就介紹如何在Ubuntu Linux 12.10 中自己安裝 Gnome 3 的桌面環境。

首先加入 Gnome 3 repository:
sudo add-apt-repository ppa:gnome3-team/gnome3
接著更新 apt:
sudo apt-get update

然後在安裝 Gnome 3 套件:
sudo apt-get install gnome-shell

裝完之後,在登入畫面的右上角就會出現一個的選單:

 


點下去就可以選擇使用 Gnome 作為桌面環境: 

 

其中 GNOME 是新版的介面,類似 Unity,如果不習慣,可以選擇 GNOME Classic,使用傳統的選單介面:

 
傳統 Gnome 選單介面


參考:http://www.gtwang.org/2012/11/ubuntu-linux-1210-gnome-3.html

Android開發環境配置On Ubuntu

Ubuntu 10.04 TLS 環境配置


一、安裝JDK 1.7.x
增加軟體源
$sudo add-apt-repository ppa:webupd8team/java

更新軟體源
$sudo apt-get update

安裝jdk
$sudo apt-get install oracle-java7-installer

檢查Java版本
$java -version

切換Java版本指令
$sudo update-alternatives --config java



二、安裝Eclipse環境
拷貝Eclipse 4.3資料夾至預放置的目錄下
1. 設置Android SDK指定目錄位置
    (解壓縮完的資料夾要改讀寫權限$ sudo chmod -R 755 android-sdk-linux/)
2. 安裝ADT plugin(Help->Install New Software)



3. 利用eclipse工具 Android SDK Manager下載Android API


三、設定在終端機下執行ADB環境配置
1. 編輯:vm@vm:~$ sudo gedit ~/.bashrc

2. 貼上配置

## For Android (OLD)
#export ANDROID_HOME=/home/vm/_develop_lib/android-sdk-linux
#export PATH=$PATH:$ANDROID_HOME/tools/
#export PATH=$PATH:$ANDROID_HOME/platform-tools/

#Android SDK
ANDROID_SDK_ROOT=~/_develop_lib/android-sdk-linux
PATH=$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$PATH
export PATH

#Android NDK
ANDROID_NDK_ROOT=~/_develop_lib/android-ndk-linux
PATH=$ANDROID_NDK_ROOT:$PATH
ANDROID_NDK_Sample=$ANDROID_NDK_ROOT/samples
ANDROID_NDK_Workspace=~/workspace
export ANDROID_NDK_ROOT ANDROID_NDK_Sample ANDROID_NDK_Workspace PATH

3. 更新環境變數:vm@vm:~$ source ~/.bashrc


4. 建立捷徑:sudo ln -s /home/vm/_developer_SDK/android-sdk/platform-tools/adb(實測不需要)

Notes:
如果在Ubuntu 64 OS下執行ADB會出現No Such file or directory
vm@vm:~$ ls -l adbls: cannot access adb: No such file or directory

解法:安裝lib32ncurses5和lib32stdc++6.
$sudo apt-get install lib32ncurses5 lib32stdc++6


實際測實ADB環境配置是否成功:
1. USB 連結Android Phone
2. $adb devices


----------------------------------------------------------------------------------------------

環境設置詳細參考如下

用戶環境變數通常被存儲在下面的文件中:
~/.profile
~/.bash_profile 或者 ~./bash_login
~/.bashrc
上述文件在Ubuntu 10.0以前版本不推薦使用。

系統環境變數一般保存在下面的文件中:
/etc/environment
/etc/profile
/etc/bash.bashrc
/etc/profile和/etc/bash.bashrc在Ubuntu 10.0版本中不推薦使用。


Ubuntu Linux 環境變數的優先級
/etc/profile:在登錄時,操作系統定制用戶環境時使用的第一個文件,此文件為系統的每個用戶設置環境信息,當用戶第一次登錄時,該文件自動被執行。
/etc/environment:在登錄時操作系統使用的第二個文件,系統在讀取你自己的profile前,設置環境文件的環境變數。
~/.bash_profile:在登錄時用到的第三個文件是.profile文件,每個用戶都可使用該文件輸入專用於自己使用的shell信息,當用戶登錄時,該文件僅僅執行一次!默認情況下,他設置一些環境變數,執行用戶的.bashrc文件。 /etc/bashrc:為每一個運行bash shell的用戶執行此文件.當bash shell被打開時,該文件被讀取.
~/.bashrc:該文件包含專用於你的bash shell的bash信息,當登錄時以及每次打開新的shell時,該該文件被讀取。
/etc/bash.bashrc:當用戶進入shell或桌面系統自動執行的腳本
幾個環境變數的優先級:1>2>3



Ubuntu Linux中設置adb環境變數
當前用戶(homer)
vi ~/.bashrc (root默認目錄下的bashrc文件)
在這個文件中加入:export PATH=/home/homer/android-sdk-linux/platform-tools/:$PATH
重啟或再次登陸後生效,如果想立即生效,則執行:source ~/.bashrc

超級用戶(root):
su root
vi ~/.bashrc (root默認目錄下的bashrc文件)
在這個文件中加入:export PATH=/home/homer/android-sdk-linux/platform-tools/:$PATH
重啟或再次登陸後生效,如果想立即生效,則執行:source ~/.bashrc

全局設置(homer、root、sudo):
1. 實現思路:
在PATH默認的bin目錄下,新建adb的軟鏈接

2. 查看sudo $PATH: echo 'echo $PATH' | sudo sh
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin

3. 進入sudo默認PATH:
cd /usr/local/bin/

4. 建立軟鏈接:
sudo ln -s /home/homer/android-sdk-linux/platform-tools/adb

5. 這樣,在普通用戶(homer)、超級用戶(root)、sudo用戶,都可以直接使用adb命令,因為這些用戶的PATH環境變數都包含了目錄/usr/local/bin

Ubuntu Linux 無法識別手機
homer@ubuntu:~$ adb devices
List of devices attached
???????????? no permissions

Ubuntu Linux 啟動手機識別
homer@ubuntu:~$ sudo adb kill-server
homer@ubuntu:~$ sudo adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
homer@ubuntu:~$ adb devices
List of devices attached
FH6111131808 device


參考:
http://blog.csdn.net/zero10100/article/details/8769303
http://www.360doc.com/content/14/0213/00/11400509_352058800.shtml

Android開發環境配置On Mac OS X

Mac OS X 10.9



------------------------------------------------------------------------------------
安裝Apache Ant
$ant -v

下載Apache Ant

http://ant.apache.org/bindownload.cgi
$ tar vxf apache-ant-1.9.4-bin.tar.gz
$ ln -s apache-ant-1.9.4/ apache-ant (建立捷徑)


------------------------------------------------------------------------------------
顯示隱藏檔
defaults write com.apple.finder AppleShowAllFiles TRUE;\killall Finder

不顯示隱藏檔
defaults write com.apple.finder AppleShowAllFiles FALSE;\killall Finder


------------------------------------------------------------------------------------
 方法︰
開啟Finderv --> 名字的目錄 --> .bash_profile檔


加入相關Lib路徑:
## For Java
export JAVA_HOME=/Library/Java/Home

## For Android
export ANDROID_HOME=/develope/Lib/android-sdk
export PATH=$PATH:/develope/Lib/android-sdk/tools/
export PATH=$PATH:/develope/Lib/android-sdk/platform-tools/

## For ANT
export ANT_HOME=/develope/Lib/apache-ant
export PATH=$PATH:$JAVA_HOME/bin:$ANDROID_HOME/bin:$ANT_HOME/bin

存檔-->離開
重啟或重新登入失效,則可以執行,即生效:
$source .bash_profile
$touch .bash_profile


檢查配置:
echo $JAVA_HOME
echo $ANDROID_HOME
echo $ANT_HOME
echo $PATH