- 論壇徽章:
- 0
|
ubuntu7.10 安裝 Android
ubuntu7.10 安裝 Android 轉(zhuǎn)至
http://www.forwind.cn/2007/11/16/ubuntu710-android/
[color="#dea600"]其中非黑色文字是我自己添加的,中途遇到一些問題,記錄下來,以便解決問題。[color="#ff5f00"]感謝windstorm!
上次介紹完Android之后,連我自己都被自己說動(dòng)了,準(zhǔn)備親自嘗試一下這玩意,當(dāng)然不是為了那10000000美金吶,所有認(rèn)識(shí)的人都知道我不用Java。只是我本身對(duì)這個(gè)平臺(tái)很感興趣,也希望看一看其上層庫與底層Linux結(jié)合的機(jī)制,就想試一下了。其實(shí)對(duì)Java一直持比較排斥的態(tài)度的,總覺得C才是正統(tǒng)用來作嵌入式的語言,不過沒辦法,誰讓是人家定標(biāo)準(zhǔn)呢,考慮到一次編譯到處運(yùn)行的機(jī)制,Google選擇Java還是蠻有道理的。好了,同志們,我們不僅要對(duì)Google有愛,更要勇敢秀出來。
OK,首先,就是安裝Eclipse以及JDK和JRE。
sudo apt-get install eclipse
sudo apt-get install sun-java6-jdk
sudo apt-get install sun-java6-jre
運(yùn)行“sudo apt-get install eclipse”時(shí),我的出了如下信息:
solar@solar-Yang:~$ sudo apt-get install eclipse
E: 無法識(shí)別在安裝源列表 /etc/apt/sources.list.d/lyriczilla.list 里,第 1 行中的軟件包類別“
解決辦法:
這個(gè)問題是因?yàn)楦柙~顯示插件引起的,如果暫時(shí)不需要更新歌詞顯示插件,可以將[color="#ff8f00"]/etc/apt/sources.list.d/lyriczilla.list文件清空:
[color="#ff8f00"]sudo cp [color="#ff8f00"]/etc/apt/sources.list.d/lyriczilla.list [color="#ff8f00"]/etc/apt/sources.list.d/lyriczilla.list.backup
[color="#ff8f00"]sudo gedit [color="#ff8f00"]/etc/apt/sources.list.d/lyriczilla.list
[color="#ff8f00"]刪除所有內(nèi)容,保存退出。
然后就是去總站下載android_sdk_linux_m3-rc20a,解壓,能看到解壓出了幾個(gè)文件和目錄。記住解壓出來的tools這個(gè)文件夾的
路徑,在.bashrc文件中,將該路徑增加到Path變量。如果.bashrc中本來沒有對(duì)Path的定義,則直接添加一句exportPATH=$
{PATH}:/tools即可。這樣作的目的,是讓你無須進(jìn)入這個(gè)tools就可以使用AndroidDebug
Bridge(adb)以及其他一些命令行工具。順便要注意,當(dāng)這個(gè)路徑改變或者升級(jí)你的SDK的時(shí)候,要記住更新這個(gè)path變量。怎么知道成功沒有
呢?重開終端或者source一下新的.bashrc,然后在終端中執(zhí)行acp,一旦有程序用法提示,就表示path變量修改成功。
接下來就應(yīng)該安裝EclipsePlugin(ADT)了。這個(gè)是針對(duì)希望拿Eclipse作為開發(fā)IDE的朋友的,事實(shí)上Google官方推薦用
Eclipse來作為你的開發(fā)IDE,可以理解,畢竟是Java開發(fā)么,不過我估計(jì)過兩天還是會(huì)探索一下不用Eclipse開發(fā)的方法。這個(gè)ADT是
Android
DevelopmentTools,增加了對(duì)于Androidprojects和tools的集成化支持,其中包括了各種各樣的強(qiáng)大的擴(kuò)展,能讓你更快和
更方便地創(chuàng)建運(yùn)行以及調(diào)試Android應(yīng)用程序。OK,至于安裝辦法嘛,Google文檔上有很詳細(xì)的描述,我這里就可恥地直接copy過來了
To create the project, follow these steps:
Start Eclipse, then select Help > Software Updates > Find and Install…. In the dialog that appears, select Search for new features to installNext. and press Press New Remote Site.
In the resulting dialog box, enter a name for the remote site (e.g.
Android Plugin) and enter this as its URL:
https://dl-ssl.google.com/android/eclipse/ Press OK.
You should now see the new site added to the search list (and checked). Press Finish. In the subsequent Search Results dialog box, select the checkbox for Android Plugin > Eclipse Integration > Android Development Tools and press Next. Read the license agreement and then select Accept terms of the license agreement, if appropriate. Press Next. Press Finish. The ADT plugin is not signed; you can accept the installation anyway by pressing Install All.Restart Eclipse.After restart, update your Eclipse preferences to point to the SDK directory:Select Window > Preferences… to open the Preferences panel. (Mac OS X: Eclipse > Preferences)Select Android from the left panel.For the SDK Location in the main panel, press Browse… and locate the SDK directory.Press Apply, then OK To update the ADT plugin to the latest version, follow these steps:
Select Help > Software Updates > Find and Install…. Select Search for updates of the currently installed features and press Finish. If any update for ADT is available, select and install.Alternatively,
Select Help > Software Updates > Manage Configuration. Navigate down the tree and select Android Development Tools Select Scan for Updates under Available Tasks.OK,我們現(xiàn)在已經(jīng)配置完成了開發(fā)環(huán)境,接下來就是新建一個(gè)Android應(yīng)用程序,運(yùn)行和調(diào)試它。當(dāng)然是針對(duì)Android for Eclipse 插件進(jìn)行的,因?yàn)槲疫沒有研究別的方式^_^.
要開發(fā)一個(gè)Android程序,
首先當(dāng)然是創(chuàng)建工程了。如果你前面安裝順利,那么File > New
>Project里面就會(huì)出現(xiàn)Android的選項(xiàng),一路選下去,設(shè)置好,F(xiàn)inish后就可以在工程目錄下看到項(xiàng)目配置文件
AndroidManifest.xml以及存放源代碼和庫等東西的文件夾。先不管這,試一下運(yùn)行和調(diào)試吧。選擇Run
>Run,彈出的對(duì)話框中選擇AndroidApplication--》New_configuration,屬性框里面Android標(biāo)簽下把
Project和Activity選上,另外兩個(gè)標(biāo)簽先不管,Apply就行了。
[color="#ff5f00"]其中有一個(gè)問題值得注意,那就是Package name.包名因該設(shè)置為 "projectname.packagename"而不是"packagename",需要在包名前加入工程名。否則出現(xiàn)“Package name must have at least two identifiers” 錯(cuò)誤。我參考的實(shí)例為:
Project name: HelloWorld
Package name: com.javaeedev.android.hello
Activity name: Hello
Application name: Hello
最后,點(diǎn)擊這個(gè)對(duì)話框下面的Run,嘿嘿,告訴我,你看見了什么?
[color="#ff5f00"]再次感謝windstorm!
本文來自ChinaUnix博客,如果查看原文請(qǐng)點(diǎn):http://blog.chinaunix.net/u1/52475/showart_458210.html |
|