- 论坛徽章:
- 0
|
ubuntu7.10 安装 Android
ubuntu7.10 安装 Android 转至
http://www.forwind.cn/2007/11/16/ubuntu710-android/
[color="#dea600"]其中非黑色文字是我自己添加的,中途遇到一些问题,记录下来,以便解决问题。[color="#ff5f00"]感谢windstorm!
上次介绍完Android之后,连我自己都被自己说动了,准备亲自尝试一下这玩意,当然不是为了那10000000美金吶,所有认识的人都知道我不用Java。只是我本身对这个平台很感兴趣,也希望看一看其上层库与底层Linux结合的机制,就想试一下了。其实对Java一直持比较排斥的态度的,总觉得C才是正统用来作嵌入式的语言,不过没办法,谁让是人家定标准呢,考虑到一次编译到处运行的机制,Google选择Java还是蛮有道理的。好了,同志们,我们不仅要对Google有爱,更要勇敢秀出来。
OK,首先,就是安装Eclipse以及JDK和JRE。
sudo apt-get install eclipse
sudo apt-get install sun-java6-jdk
sudo apt-get install sun-java6-jre
运行“sudo apt-get install eclipse”时,我的出了如下信息:
solar@solar-Yang:~$ sudo apt-get install eclipse
E: 无法识别在安装源列表 /etc/apt/sources.list.d/lyriczilla.list 里,第 1 行中的软件包类别“
解决办法:
这个问题是因为歌词显示插件引起的,如果暂时不需要更新歌词显示插件,可以将[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"]删除所有内容,保存退出。
然后就是去总站下载android_sdk_linux_m3-rc20a,解压,能看到解压出了几个文件和目录。记住解压出来的tools这个文件夹的
路径,在.bashrc文件中,将该路径增加到Path变量。如果.bashrc中本来没有对Path的定义,则直接添加一句exportPATH=$
{PATH}:/tools即可。这样作的目的,是让你无须进入这个tools就可以使用AndroidDebug
Bridge(adb)以及其他一些命令行工具。顺便要注意,当这个路径改变或者升级你的SDK的时候,要记住更新这个path变量。怎么知道成功没有
呢?重开终端或者source一下新的.bashrc,然后在终端中执行acp,一旦有程序用法提示,就表示path变量修改成功。
接下来就应该安装EclipsePlugin(ADT)了。这个是针对希望拿Eclipse作为开发IDE的朋友的,事实上Google官方推荐用
Eclipse来作为你的开发IDE,可以理解,毕竟是Java开发么,不过我估计过两天还是会探索一下不用Eclipse开发的方法。这个ADT是
Android
DevelopmentTools,增加了对于Androidprojects和tools的集成化支持,其中包括了各种各样的强大的扩展,能让你更快和
更方便地创建运行以及调试Android应用程序。OK,至于安装办法嘛,Google文档上有很详细的描述,我这里就可耻地直接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,我们现在已经配置完成了开发环境,接下来就是新建一个Android应用程序,运行和调试它。当然是针对Android for Eclipse 插件进行的,因为我还没有研究别的方式^_^.
要开发一个Android程序,
首先当然是创建工程了。如果你前面安装顺利,那么File > New
>Project里面就会出现Android的选项,一路选下去,设置好,Finish后就可以在工程目录下看到项目配置文件
AndroidManifest.xml以及存放源代码和库等东西的文件夹。先不管这,试一下运行和调试吧。选择Run
>Run,弹出的对话框中选择AndroidApplication--》New_configuration,属性框里面Android标签下把
Project和Activity选上,另外两个标签先不管,Apply就行了。
[color="#ff5f00"]其中有一个问题值得注意,那就是Package name.包名因该设置为 "projectname.packagename"而不是"packagename",需要在包名前加入工程名。否则出现“Package name must have at least two identifiers” 错误。我参考的实例为:
Project name: HelloWorld
Package name: com.javaeedev.android.hello
Activity name: Hello
Application name: Hello
最后,点击这个对话框下面的Run,嘿嘿,告诉我,你看见了什么?
[color="#ff5f00"]再次感谢windstorm!
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/52475/showart_458210.html |
|