﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-My C++-随笔分类-Android</title><link>http://www.cppblog.com/finehai/category/19060.html</link><description>当时只道是寻常~</description><language>zh-cn</language><lastBuildDate>Fri, 04 May 2012 00:18:45 GMT</lastBuildDate><pubDate>Fri, 04 May 2012 00:18:45 GMT</pubDate><ttl>60</ttl><item><title>Android中Message机制的灵活应用</title><link>http://www.cppblog.com/finehai/archive/2012/04/23/172481.html</link><dc:creator>Bluesea</dc:creator><author>Bluesea</author><pubDate>Mon, 23 Apr 2012 10:23:00 GMT</pubDate><guid>http://www.cppblog.com/finehai/archive/2012/04/23/172481.html</guid><wfw:comment>http://www.cppblog.com/finehai/comments/172481.html</wfw:comment><comments>http://www.cppblog.com/finehai/archive/2012/04/23/172481.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/finehai/comments/commentRss/172481.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/finehai/services/trackbacks/172481.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1.活用Android线程间通信的Message机制  1.1.Message 代码在frameworks\base\core\java\android\Os\Message.java中。  Message.obtain函数：有多个obtain函数，主要功能一样，只是参数不一样。作用是从Message  Pool中取出一个Message，如果Message  Pool中已经没有Message可取则...&nbsp;&nbsp;<a href='http://www.cppblog.com/finehai/archive/2012/04/23/172481.html'>阅读全文</a><img src ="http://www.cppblog.com/finehai/aggbug/172481.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/finehai/" target="_blank">Bluesea</a> 2012-04-23 18:23 <a href="http://www.cppblog.com/finehai/archive/2012/04/23/172481.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>基于 Android NDK 的学习之旅-----环境搭建</title><link>http://www.cppblog.com/finehai/archive/2012/04/23/172469.html</link><dc:creator>Bluesea</dc:creator><author>Bluesea</author><pubDate>Mon, 23 Apr 2012 09:05:00 GMT</pubDate><guid>http://www.cppblog.com/finehai/archive/2012/04/23/172469.html</guid><wfw:comment>http://www.cppblog.com/finehai/comments/172469.html</wfw:comment><comments>http://www.cppblog.com/finehai/archive/2012/04/23/172469.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/finehai/comments/commentRss/172469.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/finehai/services/trackbacks/172469.html</trackback:ping><description><![CDATA[<br />
<p style="text-indent: 21pt;"><span style="font-family: 宋体; font-size: 12pt;">工欲善其事</span> <span style="font-family: 宋体; font-size: 12pt;">必先利其器</span><span style="font-size: 12pt;"> , </span><span style="font-family: 宋体; font-size: 12pt;">下面介绍下</span><span style="font-size: 12pt;"> Eclipse SDK NDK Cygwin CDT </span><span style="font-family: 宋体; font-size: 12pt;">集成开发环境的搭建。</span></p><p style="text-indent: 21pt;"><span style="font-family: 宋体; font-size: 12pt;"><br /></span></p>
<h3><span style="font-size: 14pt;">1、Android开发环境搭建</span><span style="font-family: 宋体; font-size: 14pt;"></span></h3>
<p style="text-indent: 18pt;"><span style="font-size: 12pt;">Android</span><span style="font-family: 宋体; font-size: 12pt;">开发环境搭建不是重点</span><span style="font-size: 12pt;">,</span><span style="font-family: 宋体; font-size: 12pt;">相信看此文章的很多人都已经搭建成功</span><span style="font-size: 12pt;">,</span><span style="font-family: 宋体; font-size: 12pt;">这里随便概述性的说说。</span></p>
<p style="margin-left: 60pt; text-indent: -18pt;"><span><span style="font-size: 12pt;">1)<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: 宋体; font-size: 12pt;">下载</span><span style="font-size: 12pt;"> JDK</span></p>
<p style="margin-left: 60pt; text-indent: -18pt;"><span><span style="font-size: 12pt;">2)<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: 宋体; font-size: 12pt;">下载</span><span style="font-size: 12pt;"> Eclipse</span></p>
<p style="margin-left: 60pt; text-indent: -18pt;"><span><span style="font-size: 12pt;">3)<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: 宋体; font-size: 12pt;">下载</span><span style="font-size: 12pt;"> Android SDK</span></p>
<p style="margin-left: 60pt; text-indent: -18pt;"><span><span style="font-size: 12pt;">4)<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: 宋体; font-size: 12pt;">启动</span><span style="font-size: 12pt;">Eclipse , </span><span style="font-family: 宋体; font-size: 12pt;">安装</span><span style="font-size: 12pt;"> ADT</span></p>
<p style="margin-left: 42pt;"><span face="宋体" style="font-family: 宋体;"><br />
</span></p>
<h3><span style="font-size: 14pt;">2、下载安装Android NDK</span><span style="font-size: 14pt;"></span></h3>
<p style="margin-left: 18pt;"><span style="font-family: 宋体; font-size: 12pt;">我使用的</span><span style="font-size: 12pt;">NDK</span><span style="font-family: 宋体; font-size: 12pt;">版本为</span><span style="font-size: 12pt;">r5</span></p>
<p style="margin-left: 18pt;"><span style="font-size: 12pt;">Google </span><span style="font-family: 宋体; font-size: 12pt;">出的最新</span><span style="font-size: 12pt;">NDK </span><span style="font-family: 宋体; font-size: 12pt;">为</span><span style="font-size: 12pt;"> r6 </span><span style="font-family: 宋体; font-size: 12pt;">下载地址为</span> </p>
<p style="margin-left: 18pt;"><a href="http://developer.android.com/sdk/ndk/index.html"><span style="font-size: 12pt;">http://developer.android.com/sdk/ndk/index.html</span></a></p>
<p style="margin-left: 18pt;">&nbsp;</p>
<h3><span style="font-size: 14pt;">3、下载安装cygwin</span><span style="font-size: 14pt;"></span></h3>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 10.5pt; font-family: Verdana; color: #403226;">&nbsp;&nbsp; &nbsp;</span>&nbsp;<span style="font-size: 12pt;">由于</span><span style="font-size: 12pt; font-family: 'Times New Roman';">NDK</span><span style="font-size: 12pt;">编译代码时必须要用到</span><span style="font-size: 12pt; font-family: 'Times New Roman';">make</span><span style="font-size: 12pt;">和</span><span style="font-size: 12pt; font-family: 'Times New Roman';">gcc</span><span style="font-size: 12pt;">，所以你必须先搭建一个</span><span style="font-size: 12pt; font-family: 'Times New Roman';">linux</span><span style="font-size: 12pt;">环境，</span><span style="font-size: 12pt; font-family: 'Times New Roman';"> cygwin</span><span style="font-size: 12pt;">是一个在</span><span style="font-size: 12pt; font-family: 'Times New Roman';">windows</span><span style="font-size: 12pt;">平台上运行的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">unix</span><span style="font-size: 12pt;">模拟环境</span><span style="font-size: 12pt; font-family: 'Times New Roman';">,</span><span style="font-size: 12pt;">它对于学习</span><span style="font-size: 12pt; font-family: 'Times New Roman';">unix/linux</span><span style="font-size: 12pt;">操作环境，或者从</span><span style="font-size: 12pt; font-family: 'Times New Roman';">unix</span><span style="font-size: 12pt;">到</span><span style="font-size: 12pt; font-family: 'Times New Roman';">windows</span><span style="font-size: 12pt;">的应用程序移植，非常有用。通过它，你就可以在不安装</span><span style="font-size: 12pt; font-family: 'Times New Roman';">linux</span><span style="font-size: 12pt;">的情况下使用</span><span style="font-size: 12pt; font-family: 'Times New Roman';">NDK</span><span style="font-size: 12pt;">来编译</span><span style="font-size: 12pt; font-family: 'Times New Roman';">C</span><span style="font-size: 12pt;">、</span><span style="font-size: 12pt; font-family: 'Times New Roman';">C++</span><span style="font-size: 12pt;">代码了。下面我们一步一步的安装</span><span style="font-size: 12pt; font-family: 'Times New Roman';">cygwin</span><span style="font-size: 12pt;">吧。</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;">&nbsp;<span style="font-size: 12pt;">（安装的时候忘记截图了）</span></p>
<p style="margin: 0cm 0cm 0.0001pt; line-height: 18pt;"><span style="font-size: 12pt;">首先，你得先跑到</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';"><a href="http://www.cygwin.com/"><span style="font-size: 12pt; color: windowtext; text-decoration: none;">http://www.cygwin.com</span></a></span><span style="font-size: 12pt;">下载</span><span style="font-size: 12pt; font-family: 'Times New Roman';">setup.exe</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">1</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">然后双击运行吧，运行后你将看到安装向导界面：</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">2</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">点击下一步</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 10.5pt; font-family: 'Times New Roman';">&nbsp;&nbsp; &nbsp; </span><span style="font-size: 12pt;">此时让你选择安装方式：</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1</span><span style="font-size: 12pt;">）</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Install from Internet</span><span style="font-size: 12pt;">：直接从</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Internet</span><span style="font-size: 12pt;">上下载并立即安装（安装完成后，下载好的安装文件并不会被</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';"></span><span style="font-size: 12pt;">删除，而是仍然被保留，以便下次再安装）。</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2</span><span style="font-size: 12pt;">）</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Download Without Installing</span><span style="font-size: 12pt;">：只是将安装文件下载到本地，但暂时不安装。</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3</span><span style="font-size: 12pt;">）</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Install from Local Directory</span><span style="font-size: 12pt;">：不下载安装文件，直接从本地某个含有安装文件的目录进行安装。</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">3</span><span style="font-size: 12pt;">、选择第一项，然后点击下一步：</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">4</span><span style="font-size: 12pt;">、选择要安装的目录，注意，最好不要放到有中文和空格的目录里，似乎会造成安装出问题，其它选项不用变，</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';"> </span><span style="font-size: 12pt;">之后点下一步：</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">5</span><span style="font-size: 12pt;">、上一步是选择安装</span><span style="font-size: 12pt; font-family: 'Times New Roman';">cygwin</span><span style="font-size: 12pt;">的目录，这个是选择你下载的安装包所在的目录，默认是你运行</span><span style="font-size: 12pt; font-family: 'Times New Roman';">setup.exe</span><span style="font-size: 12pt;">的目</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';"></span><span style="font-size: 12pt;">录，直接点下一步就可以：</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">6</span><span style="font-size: 12pt;">、此时你共有三种连接方式选择：</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp;&nbsp; &nbsp; 1) Direct Connection</span><span style="font-size: 12pt;">：直接连接。</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp;&nbsp; &nbsp; 2) Use IE5 Settings</span><span style="font-size: 12pt;">：使用</span><span style="font-size: 12pt; font-family: 'Times New Roman';">IE</span><span style="font-size: 12pt;">的连接参数设置进行连接。</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp; &nbsp; &nbsp;3) Use HTTP/FTP Proxy</span><span style="font-size: 12pt;">：使用</span><span style="font-size: 12pt; font-family: 'Times New Roman';">HTTP</span><span style="font-size: 12pt;">或</span><span style="font-size: 12pt; font-family: 'Times New Roman';">FTP</span><span style="font-size: 12pt;">代理服务器进行连接（需要输入服务器地址、端口号）。</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 10.5pt; font-family: 'Times New Roman';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-size: 12pt;">用户可根据自己的网络连接的实情情况进行选择，一般正常情况下，均选择第一种，也就是直接连接方式。然后</span><span style="font-size: 12pt;">再点击</span><span style="font-size: 12pt; font-family: 'Times New Roman';">&#8220;</span><span style="font-size: 12pt;">下一步</span><span style="font-size: 12pt; font-family: 'Times New Roman';">&#8221;</span><span style="font-size: 12pt;">，</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">7</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">这是选择要下载的站点，我用的是</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';"><a href="http://mirrors.kernel.org/"><span style="font-size: 12pt; color: windowtext; text-decoration: none;">http://mirrors.kernel.org</span></a></span><span style="font-size: 12pt;">，速度感觉还挺快，选择后点下一步</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">8</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">此时会下载加载安装包列表</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">9</span><span style="font-size: 12pt;">、</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Search</span><span style="font-size: 12pt;">是可以输入你要下载的包的名称，能够快速筛选出你要下载的包。那四个单选按钮是选择下边树的样式，默认就行，不用动。</span><span style="font-size: 12pt; font-family: 'Times New Roman';">View</span><span style="font-size: 12pt;">默认是</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Category</span><span style="font-size: 12pt;">，建议改成</span><span style="font-size: 12pt; font-family: 'Times New Roman';">full</span><span style="font-size: 12pt;">显示全部包再查，省的一些包被隐藏掉。左下角那个复选框是是否隐藏过期包，默认打钩，不用管它就行，下边开始下载我们要安装的包吧，为了避免全部下载，这里列出了后面开发</span><span style="font-size: 12pt; font-family: 'Times New Roman';">NDK</span><span style="font-size: 12pt;">用得着的包：</span><span style="font-size: 12pt; font-family: 'Times New Roman';">autoconf2.1</span><span style="font-size: 12pt;">、</span><span style="font-size: 12pt; font-family: 'Times New Roman';">automake1.10</span><span style="font-size: 12pt;">、</span><span style="font-size: 12pt; font-family: 'Times New Roman';">binutils</span><span style="font-size: 12pt;">、</span><span style="font-size: 12pt; font-family: 'Times New Roman';">gcc-core</span><span style="font-size: 12pt;">、</span><span style="font-size: 12pt; font-family: 'Times New Roman';">gcc- g++</span><span style="font-size: 12pt;">、</span><span style="font-size: 12pt; font-family: 'Times New Roman';">gcc4-core</span><span style="font-size: 12pt;">、</span><span style="font-size: 12pt; font-family: 'Times New Roman';">gcc4-g++</span><span style="font-size: 12pt;">、</span><span style="font-size: 12pt; font-family: 'Times New Roman';">gdb</span><span style="font-size: 12pt;">、</span><span style="font-size: 12pt; font-family: 'Times New Roman';">pcre</span><span style="font-size: 12pt;">、</span><span style="font-size: 12pt; font-family: 'Times New Roman';">pcre-devel</span><span style="font-size: 12pt;">、</span><span style="font-size: 12pt; font-family: 'Times New Roman';">gawk</span><span style="font-size: 12pt;">、</span><span style="font-size: 12pt; font-family: 'Times New Roman';">make</span><span style="font-size: 12pt;">共</span><span style="font-size: 12pt; font-family: 'Times New Roman';">12</span><span style="font-size: 12pt;">个包</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">10</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">然后开始选择安装这些包吧，点</span><span style="font-size: 12pt; font-family: 'Times New Roman';">skip</span><span style="font-size: 12pt;">，把它变成数字版本格式，要确保</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Bin</span><span style="font-size: 12pt;">项变成叉号，而</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Src</span><span style="font-size: 12pt;">项是源码，这个就没必要选了。</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">11</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">下面测试一下</span><span style="font-size: 12pt; font-family: 'Times New Roman';">cygwin</span><span style="font-size: 12pt;">是不是已经安装好了。</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 10.5pt; font-family: 'Times New Roman';">&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="font-size: 12pt;">运行</span><span style="font-size: 12pt; font-family: 'Times New Roman';">cygwin</span><span style="font-size: 12pt;">，在弹出的命令行窗口输入：</span><span style="font-size: 12pt; font-family: 'Times New Roman';">cygcheck -c cygwin</span><span style="font-size: 12pt;">命令，会打印出当前</span><span style="font-size: 12pt; font-family: 'Times New Roman';">cygwin</span><span style="font-size: 12pt;">的版本和运行状</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';"> &nbsp; &nbsp; &nbsp; </span><span style="font-size: 12pt;">态，如果</span><span style="font-size: 12pt; font-family: 'Times New Roman';">status</span><span style="font-size: 12pt;">是</span><span style="font-size: 12pt; font-family: 'Times New Roman';">ok</span><span style="font-size: 12pt;">的话，则</span><span style="font-size: 12pt; font-family: 'Times New Roman';">cygwin</span><span style="font-size: 12pt;">运行正常。</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 10.5pt; font-family: 'Times New Roman';">&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="font-size: 12pt;">然后依次输入</span><span style="font-size: 12pt; font-family: 'Times New Roman';">gcc &#8211;version</span><span style="font-size: 12pt;">，</span><span style="font-size: 12pt; font-family: 'Times New Roman';">g++ --version</span><span style="font-size: 12pt;">，</span><span style="font-size: 12pt; font-family: 'Times New Roman';">make &#8211;version</span><span style="font-size: 12pt;">，</span><span style="font-size: 12pt; font-family: 'Times New Roman';">gdb &#8211;version</span><span style="font-size: 12pt;">进行测试，如果都打印出版本信息和一些描述信息，非常高兴的告诉你，你的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">cygwin</span><span style="font-size: 12pt;">安装完成了！</span></p><p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt;"><br /></span></p>
<h3><span style="font-size: 14pt;">4、配置NDK环境变量</span><span style="font-family: 宋体; font-size: 14pt;"></span></h3>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">1</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">首先找到</span><span style="font-size: 12pt; font-family: 'Times New Roman';">cygwin</span><span style="font-size: 12pt;">的安装目录，找到一个</span><span style="font-size: 12pt; font-family: 'Times New Roman';">home\&lt;</span><span style="font-size: 12pt;">你的用户名</span><span style="font-size: 12pt; font-family: 'Times New Roman';">&gt;\.bash_profile</span><span style="font-size: 12pt;">文件，我的是：</span><span style="font-size: 12pt; font-family: 'Times New Roman';">E:\cygwin\home\Administrator\.bash_profile</span><span style="font-size: 12pt;">，</span><span style="font-size: 12pt; font-family: 'Times New Roman';">(</span><span style="font-size: 12pt;">注意：我安装的时候我的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">home</span><span style="font-size: 12pt;">文件夹下面神马都没有，解决</span> <span style="font-size: 12pt;">的办法：首先打开环境变量，把里面的用户变量中的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">HOME</span><span style="font-size: 12pt;">变量删掉，在</span><span style="font-size: 12pt; font-family: 'Times New Roman';">E:\cygwin\home</span><span style="font-size: 12pt;">文件夹下建立名为</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Administrator</span><span style="font-size: 12pt;">的文件夹（是用户名），然后把</span><span style="font-size: 12pt; font-family: 'Times New Roman';">E:\cygwin\etc\skel\.bash_profile</span><span style="font-size: 12pt;">拷贝到该文件夹下</span><span style="font-size: 12pt; font-family: 'Times New Roman';">)</span><span style="font-size: 12pt;">。</span></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">2</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">打开</span><span style="font-size: 12pt; font-family: 'Times New Roman';">bash_profile</span><span style="font-size: 12pt;">文件，添加</span><span style="font-size: 12pt; font-family: 'Times New Roman';">NDK=/cygdrive/&lt;</span><span style="font-size: 12pt;">你的盘符</span><span style="font-size: 12pt; font-family: 'Times New Roman';">&gt;/&lt;android ndk </span><span style="font-size: 12pt;">目录</span><span style="font-size: 12pt; font-family: 'Times New Roman';">&gt; </span><span style="font-size: 12pt;">例如：</span><span style="font-size: 12pt; font-family: 'Times New Roman';">NDK=/cygdrive/e/android-ndk-r5</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">export NDK</span></p>
<p style="margin: 3.75pt 0cm; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">NDK</span><span style="font-size: 12pt;">这个名字是随便取的，为了方面以后使用方便，选个简短的名字，然后保存</span></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">3</span><span style="font-size: 12pt;">、打开</span><span style="font-size: 12pt; font-family: 'Times New Roman';">cygwin</span><span style="font-size: 12pt;">，输入</span><span style="font-size: 12pt; font-family: 'Times New Roman';">cd $NDK</span><span style="font-size: 12pt;">，如果输出上面配置的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">/cygdrive/e/android-ndk-r5</span><span style="font-size: 12pt;">信息，则表明环境变量设置成功了。</span></p><p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt;"><br /></span></p>
<h3><span style="font-size: 14pt;">5、用NDK来编译程序</span></h3>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">1</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">现在我们用安装好的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">NDK</span><span style="font-size: 12pt;">来编译一个简单的程序吧，我们选择</span><span style="font-size: 12pt; font-family: 'Times New Roman';">ndk</span><span style="font-size: 12pt;">自带的例子</span><span style="font-size: 12pt; font-family: 'Times New Roman';">hello-jni</span><span style="font-size: 12pt;">，我的位于</span><span style="font-size: 12pt; font-family: 'Times New Roman';">E:\android-ndk-r5\samples\hello-jni(</span><span style="font-size: 12pt;">根据你具体的安装位置而定</span><span style="font-size: 12pt; font-family: 'Times New Roman';">)</span><span style="font-size: 12pt;">，</span></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">2</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">运行</span><span style="font-size: 12pt; font-family: 'Times New Roman';">cygwin</span><span style="font-size: 12pt;">，输入命令</span><span style="font-size: 12pt; font-family: 'Times New Roman';">cd /cygdrive/e/android-ndk-r5/samples/hello-jni</span><span style="font-size: 12pt;">，进入到</span><span style="font-size: 12pt; font-family: 'Times New Roman';">E:\android-ndk-r5\samples\hello-jni</span><span style="font-size: 12pt;">目录。</span></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">3</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">输入</span><span style="font-size: 12pt; font-family: 'Times New Roman';">$NDK/ndk-build</span><span style="font-size: 12pt;">，执行成功后，它会自动生成一个</span><span style="font-size: 12pt; font-family: 'Times New Roman';">libs</span><span style="font-size: 12pt;">目录，把编译生成的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">.so</span><span style="font-size: 12pt;">文件放在里面。</span><span style="font-size: 12pt; font-family: 'Times New Roman';">($NDK</span><span style="font-size: 12pt;">是调用我们之前配置好的环境变量，</span><span style="font-size: 12pt; font-family: 'Times New Roman';">ndk-build</span><span style="font-size: 12pt;">是调用</span><span style="font-size: 12pt; font-family: 'Times New Roman';">ndk</span><span style="font-size: 12pt;">的编译程序</span><span style="font-size: 12pt; font-family: 'Times New Roman';">)</span></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">4</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">此时去</span><span style="font-size: 12pt; font-family: 'Times New Roman';">hello-jni</span><span style="font-size: 12pt;">的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">libs</span><span style="font-size: 12pt;">目录下看有没有生成的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">.so</span><span style="font-size: 12pt;">文件，如果有，你的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">ndk</span><span style="font-size: 12pt;">就运行正常啦！</span></p><p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt;"><br /></span></p>
<h3><span style="font-size: 14pt;">6、在Eclipse中集成C/C++开发环境</span></h3>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 10.5pt; font-family: Verdana; color: #403226;">&nbsp; </span><span style="font-size: 12pt; font-family: 'Times New Roman';">1</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">装</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Eclipse</span><span style="font-size: 12pt;">的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">C/C++</span><span style="font-size: 12pt;">环境插件：</span><span style="font-size: 12pt; font-family: 'Times New Roman';">CDT</span><span style="font-size: 12pt;">，这里选择在线安装。</span></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 10.5pt; font-family: 'Times New Roman';">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-size: 12pt;">首先登录</span><span style="font-size: 12pt; font-family: 'Times New Roman';">http://www.eclipse.org/cdt/downloads.php</span><span style="font-size: 12pt;">，找到对应你</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Eclipse</span><span style="font-size: 12pt;">版本的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">CDT</span><span style="font-size: 12pt;">插件的在线安装地址。</span></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp;&nbsp;2</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">然后点</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Help</span><span style="font-size: 12pt;">菜单，找到</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Install New Software</span><span style="font-size: 12pt;">菜单</span></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp;&nbsp;3</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">点击</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Add</span><span style="font-size: 12pt;">按钮，把取的地址填进去，出来插件列表后，选</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Select All</span><span style="font-size: 12pt;">，然后选择下一步即可完成安装</span></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp;&nbsp;4</span><span style="font-size: 12pt;">、</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">&nbsp;&nbsp;</span><span style="font-size: 12pt;">安装完成后，在</span><span style="font-size: 12pt; font-family: 'Times New Roman';">eclispe</span><span style="font-size: 12pt;">中右击新建一个项目，如果出现了</span><span style="font-size: 12pt; font-family: 'Times New Roman';">c/c++</span><span style="font-size: 12pt;">项目，则表明你的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">CDT</span><span style="font-size: 12pt;">插件安装成功啦！</span></p><p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><br style="font-size: 14pt;" /><span style="font-size: 12pt;"></span></p>
<h3><span style="font-size: 14pt;">7、配置C/C++的编译器</span><span style="font-family: 宋体; font-size: 14pt;"></span></h3>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp;&nbsp;1</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">打开</span><span style="font-size: 12pt; font-family: 'Times New Roman';">eclipse</span><span style="font-size: 12pt;">，导入</span><span style="font-size: 12pt; font-family: 'Times New Roman';">ndk</span><span style="font-size: 12pt;">自带的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">hello-jni</span><span style="font-size: 12pt;">例子，右键单击项目名称，点击</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Properties</span><span style="font-size: 12pt;">，弹出配置界面，之后再点击</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Builders</span><span style="font-size: 12pt;">，弹出项目的编译工具列表，之后点击</span><span style="font-size: 12pt; font-family: 'Times New Roman';">New</span><span style="font-size: 12pt;">，新添加一个编译器，点击后出现添加界面，选择</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Program</span><span style="font-size: 12pt;">，点</span>&nbsp;<span style="font-size: 12pt;">击</span><span style="font-size: 12pt; font-family: 'Times New Roman';">OK</span></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp; 2</span><span style="font-size: 12pt;">、出现了添加界面，首先给编译配置起个名字，如：</span><span style="font-size: 12pt; font-family: 'Times New Roman';">C_Builder</span></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 10.5pt; font-family: 'Times New Roman';">&nbsp;&nbsp;</span><span style="font-size: 12pt;">设置</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Location</span><span style="font-size: 12pt;">为</span><span style="font-size: 12pt; font-family: 'Times New Roman';">&lt;</span><span style="font-size: 12pt;">你</span><span style="font-size: 12pt; font-family: 'Times New Roman';">cygwin</span><span style="font-size: 12pt;">安装路径</span><span style="font-size: 12pt; font-family: 'Times New Roman';">&gt;\bin\bash.exe</span><span style="font-size: 12pt;">程序，例如：</span><span style="font-size: 12pt; font-family: 'Times New Roman';">E:\cygwin\bin\bash.exe</span><span style="font-size: 12pt;">，设置</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Working Directory</span><span style="font-size: 12pt;">为</span><span style="font-size: 12pt; font-family: 'Times New Roman';">&lt;</span><span style="font-size: 12pt;">你</span><span style="font-size: 12pt; font-family: 'Times New Roman';">cygwin</span><span style="font-size: 12pt;">安装路径</span><span style="font-size: 12pt; font-family: 'Times New Roman';">&gt;\bin</span><span style="font-size: 12pt;">目录，例如：</span><span style="font-size: 12pt; font-family: 'Times New Roman';">E:\cygwin\bin</span></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 10.5pt; font-family: 'Times New Roman';">&nbsp;&nbsp;</span><span style="font-size: 12pt;">设置</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Arguments</span><span style="font-size: 12pt;">为</span></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp;&nbsp;--login -c "cd /cygdrive/I/JavaWorkSpace/Blog/NDK_02 &amp;&amp; $NDK/ndk-build"</span></p>
<p><img src="http://pic002.cnblogs.com/images/2011/154043/2011081310412218.png" alt="" style="display: block; margin-left: auto; margin-right: auto;" /></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;">&nbsp;<span style="font-size: 12pt;">上面的配置中</span><span style="font-size: 12pt; font-family: 'Times New Roman';"> /cygdrive/I/JavaWorkSpace/Blog/NDK_02</span><span style="font-size: 12pt;">是你当前要编译的程序的目录，</span><span style="font-size: 12pt; font-family: 'Times New Roman';">$NDK</span><span style="font-size: 12pt;">是之前配置</span>&nbsp;<span style="font-size: 12pt;">的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">ndk</span><span style="font-size: 12pt;">的环境变量，这两个根据你具体的安装目录进行配置，其他的不用变，</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Arguments</span><span style="font-size: 12pt;">这串参数实际是</span>&nbsp;<span style="font-size: 12pt;">给</span><span style="font-size: 12pt; font-family: 'Times New Roman';">bash.exe</span><span style="font-size: 12pt;">命令行程序传参数，进入要编译的程序目录，然后运行</span><span style="font-size: 12pt; font-family: 'Times New Roman';">ndk-build</span><span style="font-size: 12pt;">编译程序</span></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">3</span><span style="font-size: 12pt;">、接着切换到</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Refresh</span><span style="font-size: 12pt;">选项卡，给</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Refresh resources upon completion</span><span style="font-size: 12pt;">打上钩</span></p>
<p><img src="http://pic002.cnblogs.com/images/2011/154043/2011081310413278.png" alt="" style="display: block; margin-left: auto; margin-right: auto;" /></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">4</span><span style="font-size: 12pt;">、然后切换到</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Build Options</span><span style="font-size: 12pt;">选项卡，勾选上最后三项</span></p>
<p><img src="http://pic002.cnblogs.com/images/2011/154043/2011081310414128.png" alt="" style="display: block; margin-left: auto; margin-right: auto;" /></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">5</span><span style="font-size: 12pt;">、之后点击</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Specify Resources</span><span style="font-size: 12pt;">按钮，选择资源目录，勾选你的项目目录即可</span></p>
<p><img src="http://pic002.cnblogs.com/images/2011/154043/2011081310415084.png" alt="" style="display: block; margin-left: auto; margin-right: auto;" /></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp;6</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">最后点击</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Finish</span><span style="font-size: 12pt;">，点击</span><span style="font-size: 12pt; font-family: 'Times New Roman';">OK</span><span style="font-size: 12pt;">一路把刚才的配置都保存下来，注意：如果你配置的编译器在其它编译器下边，记得一定要点</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Up</span><span style="font-size: 12pt;">按钮，把它排到第一位，否则</span><span style="font-size: 12pt; font-family: 'Times New Roman';">C</span><span style="font-size: 12pt;">代码的编译晚于</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Java</span><span style="font-size: 12pt;">代码的编译，会造成你的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">C</span><span style="font-size: 12pt;">代码要编译两次才能看到最新的修改</span></p>
<p style="margin: 3.75pt 0cm; text-indent: 21pt; line-height: 18pt;"><span style="font-size: 12pt; font-family: 'Times New Roman';">&nbsp;7</span><span style="font-size: 12pt;">、</span>&nbsp;<span style="font-size: 12pt;">这一路下来肯定很累了吧，现在再次恭喜你，编译配置也配置完成啦，现在来测试一下是否可以自动编译呢，打开项目</span><span style="font-size: 12pt; font-family: 'Times New Roman';">jni</span><span style="font-size: 12pt;">目录里的</span><span style="font-size: 12pt; font-family: 'Times New Roman';">hello-jni.c</span><span style="font-size: 12pt;">文件把提示</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Hello from JNI!</span><span style="font-size: 12pt;">改成其他的文字：如：</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Hello</span><span style="font-size: 12pt;">，</span><span style="font-size: 12pt; font-family: 'Times New Roman';">My name is alex.</span><span style="font-size: 12pt;">，然后再模拟器中运行你的程序，如果模拟器中显示了你最新修改的文字，那么</span><span style="font-size: 12pt; font-family: 'Times New Roman';">Congratulations</span><span style="font-size: 12pt;">！你已经全部配置成功啦！</span></p>
<p>&nbsp;</p>
<p><span style="font-family: 宋体; font-size: 12pt;">　　文章参考</span> <a href="http://yueguc.iteye.com/blog/946724"><span style="color: windowtext; text-decoration: none; font-size: 12pt;">http://yueguc.iteye.com/blog/946724</span></a></p>
<p><a href="http://yueguc.iteye.com/blog/946724"><span style="color: windowtext; text-decoration: none;"><br />
</span></a></p>
<p><span style="font-size: 12pt;">本文转自</span><a href="http://www.cnblogs.com/luxiaofeng54/archive/2011/08/13/2136982.html"><span style="font-size: 12pt;">http://www.cnblogs.com/luxiaofeng54/archive/2011/08/13/2136982.html</span></a><br />
<a href="http://yueguc.iteye.com/blog/946724"><span style="color: windowtext; text-decoration: none;"></span></a></p><img src ="http://www.cppblog.com/finehai/aggbug/172469.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/finehai/" target="_blank">Bluesea</a> 2012-04-23 17:05 <a href="http://www.cppblog.com/finehai/archive/2012/04/23/172469.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ubuntu中 JDK的安装和卸载</title><link>http://www.cppblog.com/finehai/archive/2012/04/17/171759.html</link><dc:creator>Bluesea</dc:creator><author>Bluesea</author><pubDate>Tue, 17 Apr 2012 08:01:00 GMT</pubDate><guid>http://www.cppblog.com/finehai/archive/2012/04/17/171759.html</guid><wfw:comment>http://www.cppblog.com/finehai/comments/171759.html</wfw:comment><comments>http://www.cppblog.com/finehai/archive/2012/04/17/171759.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/finehai/comments/commentRss/171759.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/finehai/services/trackbacks/171759.html</trackback:ping><description><![CDATA[<span style="font-size: 12pt;"> </span><div><p><strong style="font-size: 12pt;">1）安装Java JDK</strong></p><p><strong style="font-size: 12pt;">系统：Ubuntu 10.04</strong></p><p><strong style="font-size: 12pt;">JDK：jdk-6u21-linux-i586.bin</strong></p><p><strong style="font-size: 12pt;">下载好必要的jdk，</strong></p><p><strong style="font-size: 12pt;">一.安装JDK</strong></p><p><strong style="font-size: 12pt;">1.安装JDK</strong></p><div><p><strong style="font-size: 12pt;">1. sudo&nbsp;chmod&nbsp;u+x&nbsp;jdk-6u16-linux-i586.bin</strong></p><p><strong style="font-size: 12pt;">2. sudo&nbsp;cp&nbsp;-a&nbsp;jdk-6u21-linux-i586.bin&nbsp;/opt</strong></p><p><strong style="font-size: 12pt;">3. sudo&nbsp;/opt/jdk-6u21-linux-i586.bin</strong></p><p><strong style="font-size: 12pt;">4. sudo&nbsp;rm&nbsp;-f&nbsp;/opt/jdk-6u21-linux-i586.bin</strong></p></div><p><strong style="font-size: 12pt;">2.设置JDK环境变量</strong></p><div><p><strong style="font-size: 12pt;">sudo&nbsp;gedit&nbsp;/etc/profile</strong></p><p><strong style="font-size: 12pt;">添加代码:</strong></p><p><strong style="font-size: 12pt;">#set&nbsp;java&nbsp;environment</strong></p><p><strong style="font-size: 12pt;">export&nbsp;JAVA_HOME=/opt/jdk1.6.0_21</strong></p><p><strong style="font-size: 12pt;">export&nbsp;JRE_HOME=$JAVA_HOME/jreexport</strong></p><p><strong style="font-size: 12pt;">CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib</strong></p><p><strong style="font-size: 12pt;">export&nbsp;PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin</strong></p><p><strong style="font-size: 12pt;">保存退出。</strong></p><p><strong><br /></strong></p></div><p><strong style="font-size: 12pt;">3.重启系统</strong></p><p><strong><br /></strong></p><p><strong style="font-size: 12pt;">4.测试是否安装成功</strong></p><div><p><strong style="font-size: 12pt;">java&nbsp;-version</strong></p><p><strong style="font-size: 12pt;">如果显示</strong></p><p><strong style="font-size: 12pt;">java version &#8220;1.6.0_21&#8243;</strong></p><p><strong style="font-size: 12pt;">Java(TM) SE Runtime Environment (build 1.6.0_21-b06)</strong></p><p><strong style="font-size: 12pt;">Java HotSpot(TM) Server VM (build 17.0-b16, mixed mode)</strong></p><p><strong style="font-size: 12pt;">则安装成功。</strong></p><p><strong><br /></strong></p></div><p><strong style="font-size: 12pt;">二.卸载JDK</strong></p><p><strong><br /></strong></p><p><strong style="font-size: 12pt;">1.删除JDK目录</strong></p><div><strong style="font-size: 12pt;">sudo&nbsp;rm&nbsp;-rf&nbsp;/opt/jdk1.6.0_21</strong></div><p><strong style="font-size: 12pt;">2.删除JDK环境变量</strong></p><div><p><strong style="font-size: 12pt;">sudo&nbsp;gedit&nbsp;/etc/profile</strong></p><p><strong style="font-size: 12pt;">删除代码:</strong></p><p><strong style="font-size: 12pt;">#set java environment</strong></p><p><strong style="font-size: 12pt;">export JAVA_HOME=/opt/jdk1.6.0_21</strong></p><p><strong style="font-size: 12pt;">export JRE_HOME=$JAVA_HOME/jre</strong></p><p><strong style="font-size: 12pt;">export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib</strong></p><p><strong style="font-size: 12pt;">export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin保</strong></p><p><strong style="font-size: 12pt;">存退出。</strong></p></div></div><img src ="http://www.cppblog.com/finehai/aggbug/171759.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/finehai/" target="_blank">Bluesea</a> 2012-04-17 16:01 <a href="http://www.cppblog.com/finehai/archive/2012/04/17/171759.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android的系统架构</title><link>http://www.cppblog.com/finehai/archive/2012/04/17/171724.html</link><dc:creator>Bluesea</dc:creator><author>Bluesea</author><pubDate>Tue, 17 Apr 2012 02:59:00 GMT</pubDate><guid>http://www.cppblog.com/finehai/archive/2012/04/17/171724.html</guid><wfw:comment>http://www.cppblog.com/finehai/comments/171724.html</wfw:comment><comments>http://www.cppblog.com/finehai/archive/2012/04/17/171724.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/finehai/comments/commentRss/171724.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/finehai/services/trackbacks/171724.html</trackback:ping><description><![CDATA[<span style="font-size: 12pt;"> </span><div>&nbsp;&nbsp; &nbsp;&nbsp; <span style="font-size: 12pt;">Android的系统架构和其操作系统一样，采用了分层的架构。从架构图看，android分为四个层，从高层到低层分别是应用程序层、应用程序框架层、系统运行库层和linux核心层。</span><br /><br /> <span style="color: #3333ff; font-size: 12pt;">1.应用程序<br /><br /> </span><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; Android会同一系列核心应用程序包一起发布，该应用程序包包括email客户端，SMS短消息程序，日历，地图，浏览器，联系人管理程序等。所有的应用程序都是使用JAVA语言编写的。</span><br /><br /> <span style="color: #3333ff; font-size: 12pt;">2.应用程序框架<br /><br /> &nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 12pt;">  开发人员也可以完全访问核心应用程序所使用的API框架。该应用程序的架构设计简化了组件的重用;任何一个应用程序都可以发布它的功能块并且任何其它的  应用程序都可以使用其所发布的功能块(不过得遵循框架的安全性限制)。同样，该应用程序重用机制也使用户可以方便的替换程序组件。</span><br /><span style="font-size: 12pt;"> 隐藏在每个应用后面的是一系列的服务和系统, 其中包括;</span><br /><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; * 丰富而又可扩展的视图(Views)，可以用来构建应用程序， 它包括列表(lists)，网格(grids)，文本框(text boxes)，按钮(buttons)， 甚至可嵌入的web浏览器。</span><br /><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; * 内容提供器(Content Providers)使得应用程序可以访问另一个应用程序的数据(如联系人数据库)， 或者共享它们自己的数据</span><br /><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; * 资源管理器(Resource Manager)提供 非代码资源的访问，如本地字符串，图形，和布局文件( layout files )。</span><br /><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; * 通知管理器 (Notification Manager) 使得应用程序可以在状态栏中显示自定义的提示信息。</span><br /><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; * 活动管理器( Activity Manager) 用来管理应用程序生命周期并提供常用的导航回退功能。</span><br /><span style="font-size: 12pt;"> 有关更多的细节和怎样从头写一个应用程序，请参考 如何编写一个 Android 应用程序.</span><br /><br /> <span style="color: #3333ff; font-size: 12pt;">3.系统运行库<br /><br /> </span><span style="font-size: 12pt;"> 1)程序库</span><br /><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; Android 包含一些C/C 库，这些库能被Android系统中不同的组件使用。它们通过 Android 应用程序框架为开发者提供服务。以下是一些核心库：</span><br /><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; * 系统 C 库 - 一个从 BSD 继承来的标准 C 系统函数库( libc )， 它是专门为基于 embedded linux 的设备定制的。</span><br /><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; * 媒体库 - 基于 PacketVideo OpenCORE;该库支持多种常用的音频、视频格式回放和录制，同时支持静态图像文件。编码格式包括MPEG4, H.264, MP3, AAC, AMR, JPG, PNG 。</span><br /><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; * Surface Manager - 对显示子系统的管理，并且为多个应用程序提 供了2D和3D图层的无缝融合。</span><br /><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; * LibWebCore - 一个最新的web浏览器引擎用，支持Android浏览器和一个可嵌入的web视图。</span><br /><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; * SGL - 底层的2D图形引擎</span><br /><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; * 3D libraries - 基于OpenGL ES 1.0 APIs实现;该库可以使用硬件 3D加速(如果可用)或者使用高度优化的3D软加速。</span><br /><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; * FreeType -位图(bitmap)和矢量(vector)字体显示。   </span><p><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp;&nbsp; * SQLite - 一个对于所有应用程序可用，功能强劲的轻型关系型数据库引擎。</span><br /><span style="font-size: 12pt;"> 2)Android 运行库</span><br /><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; Android 包括了一个核心库，该核心库提供了JAVA编程语言核心库的大多数功能。</span><br /><span style="font-size: 12pt;">  每一个Android应用程序都在它自己的进程中运行，都拥有一个独立的Dalvik虚拟机实例。Dalvik被设计成一个设备可以同时高效地运行多个  虚拟系统。  Dalvik虚拟机执行(.dex)的Dalvik可执行文件，该格式文件针对小内存使用做了优化。同时虚拟机是基于寄存器的，所有的类都经由JAVA编  译器编译，然后通过SDK中 的 &#8220;dx&#8221; 工具转化成.dex格式由虚拟机执行。</span><br /><span style="font-size: 12pt;"> &nbsp;&nbsp;&nbsp;&nbsp; Dalvik虚拟机依赖于linux内核的一些功能，比如线程机制和底层内存管理机制。</span></p><p><br /> <span style="color: #3333ff; font-size: 12pt;">4.Linux 内核</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 12pt;"><br /></span></p><p>&nbsp;&nbsp; &nbsp;&nbsp; <span style="font-size: 12pt;">Android 的核心系统服务依赖于 Linux 2.6 内核，如安全性，内存管理，进程管理， 网络协议栈和驱动模型。 Linux 内核也同时作为硬件和软件栈之间的抽象层。</span></p></div><img src ="http://www.cppblog.com/finehai/aggbug/171724.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/finehai/" target="_blank">Bluesea</a> 2012-04-17 10:59 <a href="http://www.cppblog.com/finehai/archive/2012/04/17/171724.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】Ubuntu下安装Android模拟器</title><link>http://www.cppblog.com/finehai/archive/2012/04/11/170876.html</link><dc:creator>Bluesea</dc:creator><author>Bluesea</author><pubDate>Wed, 11 Apr 2012 02:59:00 GMT</pubDate><guid>http://www.cppblog.com/finehai/archive/2012/04/11/170876.html</guid><wfw:comment>http://www.cppblog.com/finehai/comments/170876.html</wfw:comment><comments>http://www.cppblog.com/finehai/archive/2012/04/11/170876.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/finehai/comments/commentRss/170876.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/finehai/services/trackbacks/170876.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 如果你想在自己的PC机上玩玩Adroid，不妨按下列步骤试一试：<br><br>前提：已安装Java平台。&nbsp;&nbsp;<a href='http://www.cppblog.com/finehai/archive/2012/04/11/170876.html'>阅读全文</a><img src ="http://www.cppblog.com/finehai/aggbug/170876.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/finehai/" target="_blank">Bluesea</a> 2012-04-11 10:59 <a href="http://www.cppblog.com/finehai/archive/2012/04/11/170876.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】HelloWorld及Android项目结构介绍-JavaGG</title><link>http://www.cppblog.com/finehai/archive/2012/04/11/170870.html</link><dc:creator>Bluesea</dc:creator><author>Bluesea</author><pubDate>Wed, 11 Apr 2012 02:48:00 GMT</pubDate><guid>http://www.cppblog.com/finehai/archive/2012/04/11/170870.html</guid><wfw:comment>http://www.cppblog.com/finehai/comments/170870.html</wfw:comment><comments>http://www.cppblog.com/finehai/archive/2012/04/11/170870.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/finehai/comments/commentRss/170870.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/finehai/services/trackbacks/170870.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Android下搭建环境之后使用Eclipse开发第一个helloworld程序！&nbsp;&nbsp;<a href='http://www.cppblog.com/finehai/archive/2012/04/11/170870.html'>阅读全文</a><img src ="http://www.cppblog.com/finehai/aggbug/170870.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/finehai/" target="_blank">Bluesea</a> 2012-04-11 10:48 <a href="http://www.cppblog.com/finehai/archive/2012/04/11/170870.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>