<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>朱文昊 Albert Zhu &#187; 自由软件社区</title>
	<atom:link href="http://zhuwenhao.com/category/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/feed/" rel="self" type="application/rss+xml" />
	<link>http://zhuwenhao.com</link>
	<description>朱文昊的中文博客－－专注技术，向往自由</description>
	<lastBuildDate>Sun, 22 Jan 2012 13:47:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>提供最新，最完整的Android源代码压缩包下载</title>
		<link>http://zhuwenhao.com/950/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/%e6%8f%90%e4%be%9b%e6%9c%80%e6%96%b0%ef%bc%8c%e6%9c%80%e5%ae%8c%e6%95%b4%e7%9a%84android%e6%ba%90%e4%bb%a3%e7%a0%81%e5%8e%8b%e7%bc%a9%e5%8c%85%e4%b8%8b%e8%bd%bd/</link>
		<comments>http://zhuwenhao.com/950/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/%e6%8f%90%e4%be%9b%e6%9c%80%e6%96%b0%ef%bc%8c%e6%9c%80%e5%ae%8c%e6%95%b4%e7%9a%84android%e6%ba%90%e4%bb%a3%e7%a0%81%e5%8e%8b%e7%bc%a9%e5%8c%85%e4%b8%8b%e8%bd%bd/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 17:02:22 +0000</pubDate>
		<dc:creator>朱文昊 Albert Zhu</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://zhuwenhao.com/?p=950</guid>
		<description><![CDATA[我的Blog里，提供了几种Android源码下载的文章是最受欢迎的了。看来真的又很多人需要打包好的Android源码。
所以我会把自己一个服务器300G的硬盘空间中的大部分拿出来存储和分享Android源代码。如果你需要Android源代码，你可以去看看http://d.zhu.im/android/
如果你要链接到我的文件，最好能再页面上放置友情链接、说句谢谢之类的，我就很开心了。
除了再2011年10月24日以前生成的文件，是我手动产生的，所以会长期保留之外，建议你不要静态链接到源码压缩包，因为硬盘空间不够的时候，旧文件会被删除。我提供了符号链接，你查找名字类似  [...]]]></description>
			<content:encoded><![CDATA[<p>我的Blog里，提供了几种Android源码下载的文章是最受欢迎的了。看来真的又很多人需要打包好的Android源码。<br />
所以我会把自己一个服务器300G的硬盘空间中的大部分拿出来存储和分享Android源代码。如果你需要Android源代码，你可以去看看<a href="http://d.zhu.im/android/" target="_blank">http://d.zhu.im/android/</a><br />
如果你要链接到我的文件，最好能再页面上放置友情链接、说句谢谢之类的，我就很开心了。<br />
除了再2011年10月24日以前生成的文件，是我手动产生的，所以会长期保留之外，建议你不要静态链接到源码压缩包，因为硬盘空间不够的时候，旧文件会被删除。我提供了符号链接，你查找名字类似 “latest-android-&#8217;$VERSION-ID&#8217;.tar.gz”这样的文件，链接到他，可以指向最新同步好的文件。<br />
目前提供三个版本的源码包。<br />
如果你需要其他版本，请提供版本号。如何提供版本号？请先读一下我的自动更新脚本。<br />
我的300G服务器是CentOS的，没法容易地repo sync.所以我写了一个脚本运行在一个Ubuntu机器上。现在地想法是每周运行一次。这个周期是否需要调整，也看各位的反馈了。<br />
脚本如下：<br />
<span id="more-950"></span></p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p950code2'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9502"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
</pre></td><td class="code" id="p950code2"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">LOG_FILE</span>=tmp.output.log
<span style="color: #007800;">SVR_LOG</span>=~<span style="color: #000000; font-weight: bold;">/</span>log.reposync.log
<span style="color: #007800;">SYNC_DATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%Y%m%d&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#rm -rf android-*</span>
make_latest_link <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #007800;">VER</span>=$<span style="color: #000000; font-weight: bold;">@</span>
        <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-sf</span> android-<span style="color: #007800;">$SYNC_DATE</span>-<span style="color: #007800;">$VER</span>.tar.bz2 latest-android-<span style="color: #007800;">$VER</span>.tar.bz2
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ln -sf android-<span style="color: #007800;">$SYNC_DATE</span>-<span style="color: #007800;">$VER</span>.tar.bz2 latest-android-<span style="color: #007800;">$VER</span>.tar.bz2&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        rsync <span style="color: #660033;">-l</span> latest-android-<span style="color: #007800;">$VER</span>.tar.bz2 d.zhu.im:<span style="color: #000000; font-weight: bold;">/</span>d<span style="color: #000000; font-weight: bold;">/</span>android<span style="color: #000000; font-weight: bold;">/</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;uploaded latest symbol link by rsync&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
f_check_log_err <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #007800;">ERR_NUM</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'error'</span> <span style="color: #007800;">$LOG_FILE</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ERR_NUM</span>&quot;</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>;
        <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Some Error occurred ERR_NUM=<span style="color: #007800;">$ERR_NUM</span>.&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
                <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-10</span> tmp.output.log <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;rm current folder&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
                <span style="color: #7a0874; font-weight: bold;">cd</span> ..
                <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #007800;">$FOLDER_NAME</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;quit in false&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
                <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
        <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;check tmp log PASS&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
upload_new_android <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #007800;">VERSION</span>=$<span style="color: #000000; font-weight: bold;">@</span>
        <span style="color: #007800;">FOLDER_NAME</span>=android-<span style="color: #007800;">$SYNC_DATE</span>-<span style="color: #007800;">$VERSION</span>
        <span style="color: #007800;">RUN_SH_DATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%Y%m%d%H%M%S&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Sync start date and time: <span style="color: #007800;">$RUN_SH_DATE</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Working Repo version is <span style="color: #007800;">$VERSION</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$FOLDER_NAME</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;mkdir <span style="color: #007800;">$FOLDER_NAME</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$FOLDER_NAME</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;repo init start&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        repo init <span style="color: #660033;">-u</span> https:<span style="color: #000000; font-weight: bold;">//</span>android.googlesource.com<span style="color: #000000; font-weight: bold;">/</span>platform<span style="color: #000000; font-weight: bold;">/</span>manifest <span style="color: #660033;">-b</span> android-<span style="color: #007800;">$VERSION</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LOG_FILE</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        f_check_log_err <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;repo sync start&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        repo <span style="color: #c20cb9; font-weight: bold;">sync</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LOG_FILE</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        f_check_log_err <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        <span style="color: #7a0874; font-weight: bold;">cd</span> ..
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;tar start&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        <span style="color: #c20cb9; font-weight: bold;">tar</span> cjf <span style="color: #007800;">$FOLDER_NAME</span>.tar.bz2 <span style="color: #007800;">$FOLDER_NAME</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;md5sum start&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        md5sum <span style="color: #007800;">$FOLDER_NAME</span>.tar.bz2 <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$FOLDER_NAME</span>.tar.bz2.md5.txt
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;sha1sum start&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        sha1sum <span style="color: #007800;">$FOLDER_NAME</span>.tar.bz2 <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$FOLDER_NAME</span>.tar.bz2.sha1.txt
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;upload start&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        <span style="color: #c20cb9; font-weight: bold;">scp</span> <span style="color: #007800;">$FOLDER_NAME</span>.tar.bz2<span style="color: #000000; font-weight: bold;">*</span> d.zhu.im:<span style="color: #000000; font-weight: bold;">/</span>d<span style="color: #000000; font-weight: bold;">/</span>android<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        <span style="color: #666666; font-style: italic;">#make latest symbol link and upload by rsync -l</span>
        make_latest_link <span style="color: #007800;">$VERSION</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;rm -rf <span style="color: #007800;">$FOLDER_NAME</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
        <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #007800;">$FOLDER_NAME</span><span style="color: #000000; font-weight: bold;">*</span>
        <span style="color: #007800;">RUN_SH_DATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%Y%m%d%H%M%S&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;finished ALL at time: <span style="color: #007800;">$RUN_SH_DATE</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$SVR_LOG</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
upload_new_android 2.2.2_r1
upload_new_android <span style="color: #000000;">2.3</span>_r1
upload_new_android 2.3.7_r1</pre></td></tr></table></div>

<p>大家看到这里，应该知道版本号是什么意思了。如果你需要什么，请告诉我。</p>
]]></content:encoded>
			<wfw:commentRss>http://zhuwenhao.com/950/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/%e6%8f%90%e4%be%9b%e6%9c%80%e6%96%b0%ef%bc%8c%e6%9c%80%e5%ae%8c%e6%95%b4%e7%9a%84android%e6%ba%90%e4%bb%a3%e7%a0%81%e5%8e%8b%e7%bc%a9%e5%8c%85%e4%b8%8b%e8%bd%bd/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Android 2.3 Gingerbread 原版源代码压缩包下载</title>
		<link>http://zhuwenhao.com/831/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android-2-3-gingerbread-%e5%8e%9f%e7%89%88%e6%ba%90%e4%bb%a3%e7%a0%81%e5%8e%8b%e7%bc%a9%e5%8c%85%e4%b8%8b%e8%bd%bd/</link>
		<comments>http://zhuwenhao.com/831/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android-2-3-gingerbread-%e5%8e%9f%e7%89%88%e6%ba%90%e4%bb%a3%e7%a0%81%e5%8e%8b%e7%bc%a9%e5%8c%85%e4%b8%8b%e8%bd%bd/#comments</comments>
		<pubDate>Wed, 11 May 2011 08:48:45 +0000</pubDate>
		<dc:creator>朱文昊 Albert Zhu</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://zhuwenhao.com/?p=831</guid>
		<description><![CDATA[此前已经发布过Android在PC平台上的源码压缩包下载（Android-x86-2.2, Android-x86-2.3），原因一样，repo sync的过程是痛苦而漫长的，甚至根本下不完整。我在美国的服务器上获取完整源代码后，压缩为gzip包，这样您就可以用下载工具下载了，可以多线程，可以断点续传，哦耶。
Android 2.3 Gingerbread 源代码 gzip压缩包
大小：3423434541  [...]]]></description>
			<content:encoded><![CDATA[<p>此前已经发布过Android在PC平台上的源码压缩包下载（<a href="http://zhuwenhao.com/718/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android-x86-%e5%9f%ba%e4%ba%8e2-2%e7%89%88%e6%9c%ac%e7%9a%84froyo-x86%e6%89%93%e5%8c%85%e4%b8%8b%e8%bd%bdzip/" target="_blank">Android-x86-2.2</a>, <a href="http://zhuwenhao.com/760/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android-x86%e5%9f%ba%e4%ba%8e2-3%e7%89%88%e6%9c%ac%e7%9a%84gingerbread-x86%e6%89%93%e5%8c%85%e4%b8%8b%e8%bd%bd/" target="_blank">Android-x86-2.3</a>），原因一样，repo sync的过程是痛苦而漫长的，甚至根本下不完整。我在美国的服务器上获取完整源代码后，压缩为gzip包，这样您就可以用下载工具下载了，可以多线程，可以断点续传，哦耶。</p>
<p><a href="http://zhuwenhao.com/download/android/android-2.3-20110510.tar.gz" target="_blank">Android 2.3 Gingerbread 源代码 gzip压缩包</a></p>
<p>大小：3423434541 字节</p>
<p><a href="http://zhuwenhao.com/download/android/android-2.3-20110510.tar.gz.md5" target="_blank">MD5校验</a>：96c359467e9f19ad0f2bcd5a4f218163</p>
<p><a href="http://zhuwenhao.com/download/android/android-2.3-20110510.tar.gz.sha1" target="_blank">SHA1校验</a>：1a3d1af403c02698d540e2204df095bd27b92199</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://zhuwenhao.com/831/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android-2-3-gingerbread-%e5%8e%9f%e7%89%88%e6%ba%90%e4%bb%a3%e7%a0%81%e5%8e%8b%e7%bc%a9%e5%8c%85%e4%b8%8b%e8%bd%bd/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Android编译加入第三方动态链接库文件的方法</title>
		<link>http://zhuwenhao.com/824/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android%e7%bc%96%e8%af%91%e5%8a%a0%e5%85%a5%e7%ac%ac%e4%b8%89%e6%96%b9%e5%8a%a8%e6%80%81%e9%93%be%e6%8e%a5%e5%ba%93%e6%96%87%e4%bb%b6%e7%9a%84%e6%96%b9%e6%b3%95/</link>
		<comments>http://zhuwenhao.com/824/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android%e7%bc%96%e8%af%91%e5%8a%a0%e5%85%a5%e7%ac%ac%e4%b8%89%e6%96%b9%e5%8a%a8%e6%80%81%e9%93%be%e6%8e%a5%e5%ba%93%e6%96%87%e4%bb%b6%e7%9a%84%e6%96%b9%e6%b3%95/#comments</comments>
		<pubDate>Fri, 06 May 2011 08:46:55 +0000</pubDate>
		<dc:creator>朱文昊 Albert Zhu</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://zhuwenhao.com/?p=824</guid>
		<description><![CDATA[如果你的代码不想随Android开源发布，或者你的代码用到了闭源的第三方库文件，你可以把需要的库动态链接到自己的程序中，修改Android.mk文件，让Android在打包二进制文件时把指定的.so文件放入系统目录下，以供dlopen使用。
下面是一个通用的示例文件，说明了修改Android.mk的方法。增加

View Code MAKEFILE1
MY_LOCAL_PATH := $(LOCAL_PATH)

的原因是

View Code MAKEFILE1
LOCAL_PATH := $(call  [...]]]></description>
			<content:encoded><![CDATA[<p>如果你的代码不想随Android开源发布，或者你的代码用到了闭源的第三方库文件，你可以把需要的库动态链接到自己的程序中，修改Android.mk文件，让Android在打包二进制文件时把指定的.so文件放入系统目录下，以供dlopen使用。</p>
<p>下面是一个通用的示例文件，说明了修改Android.mk的方法。增加</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p824code6'); return false;">View Code</a> MAKEFILE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8246"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p824code6"><pre class="makefile" style="font-family:monospace;">MY_LOCAL_PATH := $(LOCAL_PATH)</pre></td></tr></table></div>

<p>的原因是</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p824code7'); return false;">View Code</a> MAKEFILE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8247"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p824code7"><pre class="makefile" style="font-family:monospace;">LOCAL_PATH := $(call my-dir)</pre></td></tr></table></div>

<p>在一个.mk文件里只能出现一次。</p>
<p>示例文件在编译时，应该把libabc.so放到.mk同一个目录下。</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p824code8'); return false;">View Code</a> MAKEFILE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8248"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code" id="p824code8"><pre class="makefile" style="font-family:monospace;">LOCAL_PATH := $(call my-dir)
MY_LOCAL_PATH := $(LOCAL_PATH)
include $(CLEAR_VARS)
&nbsp;
LOCAL_PREBUILT_LIBS := libabc.so
&nbsp;
include $(BUILD_MULTI_PREBUILT)
&nbsp;
LOCAL_PATH := $(MY_LOCAL_PATH)
include $(CLEAR_VARS)
&nbsp;
LOCAL_SRC_FILES := main.cpp
LOCAL_MODULE := mytest
LOCAL_SHARED_LIBRARIES := libabc
&nbsp;
include $(BUILD_EXECUTABLE)</pre></td></tr></table></div>

<p>感谢rktb，参考<a href="http://www.mail-archive.com/android-framework@googlegroups.com/msg00990.html" target="_blank">原文地址</a></p>
]]></content:encoded>
			<wfw:commentRss>http://zhuwenhao.com/824/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android%e7%bc%96%e8%af%91%e5%8a%a0%e5%85%a5%e7%ac%ac%e4%b8%89%e6%96%b9%e5%8a%a8%e6%80%81%e9%93%be%e6%8e%a5%e5%ba%93%e6%96%87%e4%bb%b6%e7%9a%84%e6%96%b9%e6%b3%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android-x86基于2.3版本的Gingerbread x86打包下载</title>
		<link>http://zhuwenhao.com/760/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android-x86%e5%9f%ba%e4%ba%8e2-3%e7%89%88%e6%9c%ac%e7%9a%84gingerbread-x86%e6%89%93%e5%8c%85%e4%b8%8b%e8%bd%bd/</link>
		<comments>http://zhuwenhao.com/760/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android-x86%e5%9f%ba%e4%ba%8e2-3%e7%89%88%e6%9c%ac%e7%9a%84gingerbread-x86%e6%89%93%e5%8c%85%e4%b8%8b%e8%bd%bd/#comments</comments>
		<pubDate>Fri, 08 Apr 2011 05:58:44 +0000</pubDate>
		<dc:creator>朱文昊 Albert Zhu</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://zhuwenhao.com/?p=760</guid>
		<description><![CDATA[几个月前的我发布了一个打包的Android Froyo版本,大受欢迎,有很多留言和访问. 参考该博文链接.
现在我发布一下打包好的Android 2.3 Gingerbread 版本的文件, 使用 tar -czf 参数打包. 可能依然无法在你的机器上 sync, 有需要更新版本的,请留言给我.
下载链接是:
Android 2.3  [...]]]></description>
			<content:encoded><![CDATA[<p>几个月前的我发布了一个打包的Android Froyo版本,大受欢迎,有很多留言和访问. 参考<a href="http://zhuwenhao.com/718/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android-x86-%e5%9f%ba%e4%ba%8e2-2%e7%89%88%e6%9c%ac%e7%9a%84froyo-x86%e6%89%93%e5%8c%85%e4%b8%8b%e8%bd%bdzip/">该博文链接</a>.<br />
现在我发布一下打包好的Android 2.3 Gingerbread 版本的文件, 使用 tar -czf 参数打包. 可能依然无法在你的机器上 sync, 有需要更新版本的,请留言给我.<br />
下载链接是:<br />
Android 2.3 Gingerbread<br />
<a href="http://zhuwenhao.com/download/android-gingerbread-20110408.tar.gz">文件名android-gingerbread-20110408.tar.gz</a><br />
size:3446063892字节<br />
MD5:<a href="http://zhuwenhao.com/download/android-gingerbread-20110408.tar.gz.md5">fc225ab4dd1d3ef43849b0d5a5d45c54</a><br />
SHA1:<a href="http://zhuwenhao.com/download/android-gingerbread-20110408.tar.gz.sha1">4326d716bba5cb6c68e3969d20cca242b575deed</a></p>
<p>&nbsp;</p>
<p>提示：这个版本必须要在64位编译环境下编译，而目标版本是32位的时候，就要用交叉编译环境了，如果看到什么库不对的提示，请先检查64位系统下的32位编译器和链接库都是不是安装好了。</p>
]]></content:encoded>
			<wfw:commentRss>http://zhuwenhao.com/760/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android-x86%e5%9f%ba%e4%ba%8e2-3%e7%89%88%e6%9c%ac%e7%9a%84gingerbread-x86%e6%89%93%e5%8c%85%e4%b8%8b%e8%bd%bd/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>解决Android-x86 Froyo版本鼠标移动过慢的方法 Fix Mouse Move Slow Issue in Froyo-x86</title>
		<link>http://zhuwenhao.com/731/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/%e8%a7%a3%e5%86%b3android-x86-froyo%e7%89%88%e6%9c%ac%e9%bc%a0%e6%a0%87%e7%a7%bb%e5%8a%a8%e8%bf%87%e6%85%a2%e7%9a%84%e6%96%b9%e6%b3%95-fix-mouse-move-slow-issue-in-froyo-x86/</link>
		<comments>http://zhuwenhao.com/731/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/%e8%a7%a3%e5%86%b3android-x86-froyo%e7%89%88%e6%9c%ac%e9%bc%a0%e6%a0%87%e7%a7%bb%e5%8a%a8%e8%bf%87%e6%85%a2%e7%9a%84%e6%96%b9%e6%b3%95-fix-mouse-move-slow-issue-in-froyo-x86/#comments</comments>
		<pubDate>Fri, 17 Dec 2010 01:33:25 +0000</pubDate>
		<dc:creator>朱文昊 Albert Zhu</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://zhuwenhao.com/?p=731</guid>
		<description><![CDATA[解决办法，编译的时候使用如下参数开启3D硬件加速，完美解决鼠标移动慢的问题，响应速度快了很多。
需要增加的参数： BOARD_USES_I915= BOARD_USES_I915C=true
编译命令： make usb_img BOARD_USES_I915= BOARD_USES_I915C=true TARGET_PRODUCT=eeepc
或：           make iso_img BOARD_USES_I915= BOARD_USES_I915C=true TARGET_PRODUCT=eeepc
Solving mouse move too slow problem in  [...]]]></description>
			<content:encoded><![CDATA[<p>解决办法，编译的时候使用如下参数开启3D硬件加速，完美解决鼠标移动慢的问题，响应速度快了很多。</p>
<p>需要增加的参数： BOARD_USES_I915= BOARD_USES_I915C=true</p>
<p>编译命令： make usb_img BOARD_USES_I915= BOARD_USES_I915C=true TARGET_PRODUCT=eeepc</p>
<p>或：           make iso_img BOARD_USES_I915= BOARD_USES_I915C=true TARGET_PRODUCT=eeepc</p>
<p>Solving mouse move too slow problem in froyo-x86 version of Android-x86. Append these parameters to enable 3D hardware acceleration in &#8216;make&#8217; command. System speed is busted!</p>
<p>Parameters add : BOARD_USES_I915= BOARD_USES_I915C=true</p>
<p>make command of usb image : make usb_img BOARD_USES_I915= BOARD_USES_I915C=true TARGET_PRODUCT=eeepc</p>
<p>make command of iso image  : make iso_img BOARD_USES_I915= BOARD_USES_I915C=true TARGET_PRODUCT=eeepc</p>
]]></content:encoded>
			<wfw:commentRss>http://zhuwenhao.com/731/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/%e8%a7%a3%e5%86%b3android-x86-froyo%e7%89%88%e6%9c%ac%e9%bc%a0%e6%a0%87%e7%a7%bb%e5%8a%a8%e8%bf%87%e6%85%a2%e7%9a%84%e6%96%b9%e6%b3%95-fix-mouse-move-slow-issue-in-froyo-x86/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android-x86 基于2.2版本的froyo x86打包下载zip</title>
		<link>http://zhuwenhao.com/718/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android-x86-%e5%9f%ba%e4%ba%8e2-2%e7%89%88%e6%9c%ac%e7%9a%84froyo-x86%e6%89%93%e5%8c%85%e4%b8%8b%e8%bd%bdzip/</link>
		<comments>http://zhuwenhao.com/718/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android-x86-%e5%9f%ba%e4%ba%8e2-2%e7%89%88%e6%9c%ac%e7%9a%84froyo-x86%e6%89%93%e5%8c%85%e4%b8%8b%e8%bd%bdzip/#comments</comments>
		<pubDate>Tue, 30 Nov 2010 00:59:16 +0000</pubDate>
		<dc:creator>朱文昊 Albert Zhu</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://zhuwenhao.com/?p=718</guid>
		<description><![CDATA[Android-x86 使用repo sync直接从服务器建立和更新git库非常的不稳定，链接经常中断，搞了一星期也没有下载好。后来在服务器上直接下载，很快就同步好了，可见主要问题还是网络的国际出口不稳定造成的。然后在服务器端打成zip包下载，就快多了。
由于Android-x86.org组织不提供类似的下载，我就共享一下我制作好的zip包，sync日期是2010年11月28日。
下载包5G左右。
地址 ： http://zhuwenhao.com/download/android-froyo.zip
由于服务器资源有限，本下载不保证长期提供。
 Update:  [...]]]></description>
			<content:encoded><![CDATA[<p>Android-x86 使用repo sync直接从服务器建立和更新git库非常的不稳定，链接经常中断，搞了一星期也没有下载好。后来在服务器上直接下载，很快就同步好了，可见主要问题还是网络的国际出口不稳定造成的。然后在服务器端打成zip包下载，就快多了。</p>
<p>由于Android-x86.org组织不提供类似的下载，我就共享一下我制作好的zip包，sync日期是2010年11月28日。</p>
<p>下载包5G左右。</p>
<p><del datetime="2011-04-08T08:51:20+00:00">地址 ： http://zhuwenhao.com/download/android-froyo.zip</del></p>
<p>由于服务器资源有限，本下载不保证长期提供。</p>
<ul> <ins datetime="2011-04-08T09:04:45+00:00"><strong>Update: 本文件已删除,请下载下面的较新链接,硬盘没空间了,欢迎赞助 <img src='http://zhuwenhao.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </strong> </ins></ul>
<p>另请注意，以下文件有问题，会编译不通过。</p>
<p>frameworks/base/opengl/tests/gl_jni/jni/gl_code.cpp</p>
<p>解决的办法是在该文件的末尾加一个空行。如果先修改一下，就免得编译两遍了。</p>
<p>！更新！</p>
<p>2011年1月4日 repo sync 操作，重新打包。下载：</p>
<p><a title="android-froyo-2011-01-04.zip" href="http://zhuwenhao.com/download/android-froyo-2011-01-04.zip">android-froyo-2011-01-04.zip</a></p>
<p>这个版本我没有编译测试过，有问题请留言告知大家，谢谢。</p>
]]></content:encoded>
			<wfw:commentRss>http://zhuwenhao.com/718/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android-x86-%e5%9f%ba%e4%ba%8e2-2%e7%89%88%e6%9c%ac%e7%9a%84froyo-x86%e6%89%93%e5%8c%85%e4%b8%8b%e8%bd%bdzip/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Android编译C代码时链接其他库文件的方法(附make file详解手册)</title>
		<link>http://zhuwenhao.com/709/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android%e7%bc%96%e8%af%91c%e4%bb%a3%e7%a0%81%e6%97%b6%e9%93%be%e6%8e%a5%e5%85%b6%e4%bb%96%e5%ba%93%e6%96%87%e4%bb%b6%e7%9a%84%e6%96%b9%e6%b3%95%e9%99%84make-file%e8%af%a6%e8%a7%a3%e6%89%8b%e5%86%8c/</link>
		<comments>http://zhuwenhao.com/709/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android%e7%bc%96%e8%af%91c%e4%bb%a3%e7%a0%81%e6%97%b6%e9%93%be%e6%8e%a5%e5%85%b6%e4%bb%96%e5%ba%93%e6%96%87%e4%bb%b6%e7%9a%84%e6%96%b9%e6%b3%95%e9%99%84make-file%e8%af%a6%e8%a7%a3%e6%89%8b%e5%86%8c/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 16:13:47 +0000</pubDate>
		<dc:creator>朱文昊 Albert Zhu</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://zhuwenhao.com/?p=709</guid>
		<description><![CDATA[Android的内核基本就是Linux。在Android-x86的代码基础上，可以编译自己的Android系统。
常常需要在自己的C代码里链接第三方提供的库文件，例如以.a文件提供。此时需要修改Android.mk文件来加进需要连接的库。LOCAL_LDLIBS不是做这个的，一个可行的方法是使用LOCAL_LDFLAGS通知编译器。例如
LOCAL_LDFLAGS -L$(LOCAL_PATH)  [...]]]></description>
			<content:encoded><![CDATA[<p>Android的内核基本就是Linux。在Android-x86的代码基础上，可以编译自己的Android系统。</p>
<p>常常需要在自己的C代码里链接第三方提供的库文件，例如以.a文件提供。此时需要修改Android.mk文件来加进需要连接的库。LOCAL_LDLIBS不是做这个的，一个可行的方法是使用LOCAL_LDFLAGS通知编译器。例如</p>
<blockquote><p>LOCAL_LDFLAGS -L$(LOCAL_PATH) -lxxxx</p></blockquote>
<p>其中xxxx是被链接模块的名字，不含后缀和前缀lib</p>
<p>注意-L后面使用相对路径似乎不行。</p>
<p>后面附上来自http://android.git.kernel.org/?p=platform/build.git;a=blob_plain;f=core/build-system.html</p>
<p>的Android系统makefile的文档，因为很难准确google到，转载记录一下。Android的资料水都太大了。</p>
<p><span id="more-709"></span>全文转载，as is.</p>
<h1><a name="My_Project_">Android Build System</a></h1>
<p><!-- Status is one of: Draft, Current, Needs Update, Obsolete --><a name="My_Project_"> <strong>Status:</strong> <em>Draft </em> <small>(as of May 18, 2006)</small> </a></p>
<p><a name="My_Project_"><strong>Contents</strong></a></p>
<p><!-- this div expands out to a list of contents based on the H2 and H3 headings. Believe it! --><a name="My_Project_"> </a></p>
<h2><a name="My_Project_">Objective</a></h2>
<p><a name="My_Project_">The primary goals of reworking the build system are (1) to make dependencies work more reliably, so that when files need to rebuilt, they are, and (2) to improve performance of the build system so that unnecessary modules are not rebuilt, and so doing a top-level build when little or nothing needs to be done for a build takes as little time as possible.</a></p>
<h2><a name="My_Project_">Principles and Use Cases and Policy</a></h2>
<p><a name="My_Project_">Given the above objective, these are the overall principles and use cases that we will support.  This is not an exhaustive list.</a></p>
<h3><a name="My_Project_">Multiple Targets</a></h3>
<p><a name="My_Project_">It needs to be possible to build the Android platform for multiple targets. This means:</a></p>
<ul><a name="My_Project_"> </a></p>
<li><a name="My_Project_">The build system will support building tools for the host platform,     both ones that are used in the build process itself, and developer tools     like the simulator.</a></li>
<p><a name="My_Project_"> </a></p>
<li><a name="My_Project_">The build system will need to be able to build tools on Linux     (definitely Goobuntu and maybe Grhat), MacOS, and to some degree on     Windows.</a></li>
<p><a name="My_Project_"> </a></p>
<li><a name="My_Project_">The build system will need to be able to build the OS on Linux, and in     the short-term, MacOS.  Note that this is a conscious decision to stop     building the OS on Windows.  We are going to rely on the emulator there     and not attempt to use the simulator.  This is a requirement change now     that the emulator story is looking brighter.</a></li>
</ul>
<h3><a name="My_Project_">Non-Recursive Make</a></h3>
<p><a name="My_Project_">To achieve the objectives, the build system will be rewritten to use make non-recursively.  For more background on this, read </a><a href="http://aegis.sourceforge.net/auug97.pdf">Recursive Make Considered Harmful</a>.  For those that don&#8217;t want PDF, here is the <a href="http://72.14.203.104/search?q=cache:HwuX7YF2uBIJ:aegis.sourceforge.net/auug97.pdf&amp;hl=en&amp;gl=us&amp;ct=clnk&amp;cd=2&amp;client=firefox">Google translated version</a>.</p>
<h3>Rapid Compile-Test Cycles</h3>
<p>When developing a component, for example a C++ shared library, it must be possible to easily rebuild just that component, and not have to wait more than a couple seconds for dependency checks, and not have to wait for unneeded components to be built.</p>
<h3>Both Environment and Config File Based Settings</h3>
<p>To set the target, and other options, some people on the team like to have a configuration file in a directory so they do not have an environment setup script to run, and others want an environment setup script to run so they can run builds in different terminals on the same tree, or switch back and forth in one terminal.  We will support both.</p>
<h3>Object File Directory / make clean</h3>
<p>Object files and other intermediate files will be generated into a directory that is separate from the source tree.  The goal is to have make clean be “rm -rf ” in the tree root directory.  The primary goals of this are to simplify searching the source tree, and to make “make clean” more reliable.</p>
<h3>SDK</h3>
<p>The SDK will be a tarball that will allow non-OS-developers to write apps. The apps will actually be built by first building the SDK, and then building the apps against that SDK.  This will hopefully (1) make writing apps easier for us, because we won&#8217;t have to rebuild the OS as much, and we can use the standard java-app development tools, and (2) allow us to dog-food the SDK, to help ensure its quality.  Cedric has suggested (and I agree) that apps built from the SDK should be built with ant.  Stay tuned for more details as we figure out exactly how this will work.</p>
<h3>Dependecies</h3>
<p>Dependencies should all be automatic.  Unless there is a custom tool involved (e.g. the webkit has several), the dependencies for shared and static libraries, .c, .cpp, .h, .java, java libraries, etc., should all work without intervention in the Android.mk file.</p>
<h3>Hiding command lines</h3>
<p>The default of the build system will be to hide the command lines being executed for make steps.  It will be possible to override this by specifying the showcommands pseudo-target, and possibly by setting an environment variable.</p>
<h3>Wildcard source files</h3>
<p>Wildcarding source file will be discouraged.  It may be useful in some scenarios.  The default <code>$(wildcard *)</code> will not work due to the current directory being set to the root of the build tree.</p>
<h3>Multiple targets in one directory</h3>
<p>It will be possible to generate more than one target from a given subdirectory.  For example, libutils generates a shared library for the target and a static library for the host.</p>
<h3>Makefile fragments for modules</h3>
<p><strong>Android.mk</strong> is the standard name for the makefile fragments that control the building of a given module.  Only the top directory should have a file named “Makefile”.</p>
<h3>Use shared libraries</h3>
<p>Currently, the simulator is not built to use shared libraries.  This should be fixed, and now is a good time to do it.  This implies getting shared libraries to work on Mac OS.</p>
<h2>Nice to Have</h2>
<p>These things would be nice to have, and this is a good place to record them, however these are not promises.</p>
<h3>Simultaneous Builds</h3>
<p>The hope is to be able to do two builds for different combos in the same tree at the same time, but this is a stretch goal, not a requirement. Doing two builds in the same tree, not at the same time must work.  (update: it&#8217;s looking like we&#8217;ll get the two builds at the same time working)</p>
<h3>Deleting headers (or other dependecies)</h3>
<p>Problems can arise if you delete a header file that is referenced in “.d” files.  The easy way to deal with this is “make clean”.  There should be a better way to handle it. (from fadden)</p>
<p>One way of solving this is introducing a dependency on the directory.  The problem is that this can create extra dependecies and slow down the build. It&#8217;s a tradeoff.</p>
<h3>Multiple builds</h3>
<p>General way to perform builds across the set of known platforms.  This would make it easy to perform multiple platform builds when testing a change, and allow a wide-scale “make clean”.  Right now the buildspec.mk or environment variables need to be updated before each build. (from fadden)</p>
<h3>Aftermarket Locales and Carrier</h3>
<p>We will eventually need to add support for creating locales and carrier customizations to the SDK, but that will not be addressed right now.</p>
<h2><a id="usage">Usage</a></h2>
<p><a id="usage">You&#8217;ve read (or scrolled past) all of the motivations for this build system, and you want to know how to use it.  This is the place.</a></p>
<h3><a id="usage">Your first build</a></h3>
<p><a id="usage">The </a><a href="http://android.git.kernel.org/building.html">Building</a> document describes how do do builds.</p>
<h3>build/envsetup.sh functions</h3>
<p>If you source the file build/envsetup.sh into your bash environment, <code>. build/envsetup.sh</code>you&#8217;ll get a few helpful shell functions:</p>
<ul>
<li><strong>printconfig</strong> &#8211; Prints the current configuration as set by the lunch and choosecombo commands.</li>
<li><strong>m</strong> &#8211; Runs <code>make</code> from the top of the tree.  This is useful because you can run make from within subdirectories.  If you have the <code>TOP</code> environment variable set, it uses that.  If you don&#8217;t, it looks up the tree from the current directory, trying to find the top of the tree.</li>
<li><strong>croot</strong> &#8211; <code>cd</code> to the top of the tree.</li>
<li><strong>sgrep</strong> &#8211; grep for the regex you provide in all .c, .cpp, .h, .java, and .xml files below the current directory.</li>
</ul>
<h3>Build flavors/types</h3>
<p>When building for a particular product, it&#8217;s often useful to have minor variations on what is ultimately the final release build.  These are the currently-defined “flavors” or “types” (we need to settle on a real name for these).</p>
<table border="1">
<tbody>
<tr>
<td><code>eng<code> </code></code></td>
<td>This is the default flavor. A plain “<code>make</code>” is the         same as “<code>make eng</code>“.  <code>droid</code> is an alias         for <code>eng</code>.</p>
<ul>
<li>Installs modules tagged with: <code>eng</code>, <code>debug</code>,             <code>shell_</code>$(TARGET_SHELL),             <code>user</code>, and/or <code>development</code>.</li>
<li>Installs non-APK modules that have no tags specified.</li>
<li>Installs APKs according to the product definition files, in             addition to tagged APKs.</li>
<li><code>ro.secure=0</code></li>
<li><code>ro.debuggable=1</code></li>
<li><code>ro.kernel.android.checkjni=1</code></li>
<li><code>adb</code> is enabled by default.</li>
</ul>
</td>
</tr>
<tr>
<td><code>user<code> </code></code></td>
<td>“<code>make user</code>“This is the flavor intended to be the final release bits.</p>
<ul>
<li>Installs modules tagged with <code>shell_</code>$(TARGET_SHELL) and <code>user</code>.</li>
<li>Installs non-APK modules that have no tags specified.</li>
<li>Installs APKs according to the product definition files; tags             are ignored for APK modules.</li>
<li><code>ro.secure=1</code></li>
<li><code>ro.debuggable=0</code></li>
<li><code>adb</code> is disabled by default.</li>
</ul>
</td>
</tr>
<tr>
<td><code>userdebug<code> </code></code></td>
<td>“<code>make userdebug</code>“The same as <code>user</code>, except:</p>
<ul>
<li>Also installs modules tagged with <code>debug</code>.</li>
<li><code>ro.debuggable=1</code></li>
<li><code>adb</code> is enabled by default.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>If you build one flavor and then want to build another, you should run “<code>make installclean</code>” between the two makes to guarantee that you don&#8217;t pick up files installed by the previous flavor.  “<code>make clean</code>” will also suffice, but it takes a lot longer.</p>
<h3>More pseudotargets</h3>
<p>Sometimes you want to just build one thing.  The following pseudotargets are there for your convenience:</p>
<ul>
<li><strong>droid</strong> &#8211; <code>make droid</code> is the normal build.  This target is here because the default target has to have a name.</li>
<li><strong>all</strong> &#8211; <code>make all</code> builds everything <code>make droid</code> does, plus everything whose <code>LOCAL_MODULE_TAGS</code> do not include the “droid” tag.  The build server runs this to make sure that everything that is in the tree and has an Android.mk builds.</li>
<li><strong>clean-$(LOCAL_MODULE)</strong> and <strong>clean-$(LOCAL_PACKAGE_NAME)</strong> &#8211;  Let you selectively clean one target.  For example, you can type <code>make clean-libutils</code> and it will delete libutils.so and all of the intermediate files, or you can type <code>make clean-Home</code> and it will clean just the Home app.</li>
<li><strong>clean</strong> &#8211; <code>make clean</code> deletes all of the output and intermediate files for this configuration.  This is the same as <code>rm -rf out/&lt;configuration&gt;/</code></li>
<li><strong>clobber</strong> &#8211; <code>make clobber</code> deletes all of the output and intermediate files for all configurations.  This is the same as <code>rm -rf out/</code>.</li>
<li><strong>dataclean</strong> &#8211; <code>make dataclean</code> deletes contents of the data  directory inside the current combo directory.  This is especially useful on the simulator and emulator, where the persistent data remains present between  builds.</li>
<li><strong>showcommands</strong> &#8211; <code>showcommands</code> is a modifier target which causes the build system to show the actual command lines for the build steps, instead of the brief descriptions.  Most people don&#8217;t like seeing the actual commands, because they&#8217;re quite long and hard to read, but if you need to for debugging purposes, you can add <code>showcommands</code> to the list of targets you build.  For example <code>make showcommands</code> will build the default android configuration, and <code>make runtime showcommands</code> will build just the runtime, and targets that it depends on, while displaying the full command lines.  Please note that there are a couple places where the commands aren&#8217;t shown here.  These are considered bugs, and should be fixed, but they&#8217;re often hard to track down.  Please let <a href="mailto:android-build-team">android-build-team</a> know if you find any.</li>
<li><strong>LOCAL_MODULE</strong> &#8211; Anything you specify as a <code>LOCAL_MODULE</code> in an Android.mk is made into a pseudotarget.  For example, <code>make runtime</code> might be shorthand for <code>make out/linux-x86-debug/system/bin/runtime</code> (which would work), and <code>make libkjs</code> might be shorthand for <code>make out/linux-x86-debug/system/lib/libkjs.so</code> (which would also work).</li>
<li><strong>targets</strong> &#8211; <code>make targets</code> will print a list of all of the LOCAL_MODULE names you can make.</li>
</ul>
<h3><a name="templates">How to add another component to the build &#8211; Android.mk templates</a></h3>
<p><a name="templates">You have a new library, a new app, or a new executable.  For each of the common types of modules, there is a corresponding file in the templates directory.  It will usually be enough to copy one of these, and fill in your own values.  Some of the more esoteric values are not included in the templates, but are instead just documented here, as is the documentation on using custom tools to generate files.</a></p>
<p><a name="templates">Mostly, you can just look for the TODO comments in the templates and do what it says.  Please remember to delete the TODO comments when you&#8217;re done to keep the files clean.  The templates have minimal documentation in them, because they&#8217;re going to be copied, and when that gets stale, the copies just won&#8217;t get updated.  So read on&#8230;</a></p>
<h4><a name="templates">Apps</a></h4>
<p><a name="templates">Use the <code>templates/apps</code> file.</a></p>
<p><a name="templates">This template is pretty self-explanitory.  See the variables below for more details.</a></p>
<h4><a name="templates">Java Libraries</a></h4>
<p><a name="templates">Use the <code>templates/java_library</code> file.</a></p>
<p><a name="templates">The interesting thing here is the value of LOCAL_MODULE, which becomes the name of the jar file.  (Actually right now, we&#8217;re not making jar files yet, just directories of .class files,  but the directory is named according to what you put in LOCAL_MODULE).  This name will be what goes in the  LOCAL_JAVA_LIBRARIES variable in modules that depend on your java library.</a></p>
<h4><a name="templates">C/C++ Executables</a></h4>
<p><a name="templates">Use the <code>templates/executable</code> file, or the <code>templates/executable_host</code> file.</a></p>
<p><a name="templates">This template has a couple extra options that you usually don&#8217;t need. Please delete the ones you don&#8217;t need, and remove the TODO comments.  It makes the rest of them easier to read, and you can always refer back to the templates if you need them again later.</a></p>
<p><a name="templates">By default, on the target these are built into /system/bin, and on the host, they&#8217;re built into /host/bin.  These can be overridden by setting <code>LOCAL_MODULE_PATH</code>.  See </a><a href="http://android.git.kernel.org/?p=platform/build.git;a=blob_plain;f=core/build-system.html#moving-targets">Putting targets elsewhere</a> for more.</p>
<h4>Shared Libraries</h4>
<p>Use the <code>templates/shared_library</code> file, or the <code>templates/shared_library_host</code> file.</p>
<p>Remember that on the target, we use shared libraries, and on the host, we use static libraries, since executable size isn&#8217;t as big an issue, and it simplifies distribution in the SDK.</p>
<h4>Static Libraries</h4>
<p>Use the <code>templates/static_library</code> file, or the <code>templates/static_library_host</code> file.</p>
<p>Remember that on the target, we use shared libraries, and on the host, we use static libraries, since executable size isn&#8217;t as big an issue, and it simplifies distribution in the SDK.</p>
<h4><a name="custom-tools">Using Custom Tools</a></h4>
<p><a name="custom-tools">If you have a tool that generates source files for you, it&#8217;s possible to have the build system get the dependencies correct for it.  Here are a couple of examples.  <code>$@</code> is the make built-in variable for “the current target.” The <span style="color: red;">red</span> parts are the parts you&#8217;ll need to change.</a></p>
<p><a name="custom-tools">You need to put this after you have declared <code>LOCAL_PATH</code> and <code>LOCAL_MODULE</code>, because the <code>$(local-intermediates-dir)</code> and <code>$(local-host-intermediates-dir)</code> macros use these variables to determine where to put the files. </a></p>
<h5><a name="custom-tools">Example 1</a></h5>
<p><a name="custom-tools">Here, there is one generated file, called chartables.c, which doesn&#8217;t depend on anything.  And is built by the tool built to $(HOST_OUT_EXECUTABLES)/dftables.  Note on the second to last line that a dependency is created on the tool.</a></p>
<pre><a name="custom-tools">intermediates:= $(local-intermediates-dir)
GEN := $(intermediates)/<span style="color: red;">chartables.c</span>
$(GEN): PRIVATE_CUSTOM_TOOL = <span style="color: red;">$(HOST_OUT_EXECUTABLES)/dftables $@</span>
$(GEN): <span style="color: red;">$(HOST_OUT_EXECUTABLES)/dftables</span>
	$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
</a></pre>
<h5><a name="custom-tools">Example 2</a></h5>
<p><a name="custom-tools">Here as a hypothetical example, we use use cat as if it were to transform a file.  Pretend that it does something useful.  Note how we use a target-specific variable called PRIVATE_INPUT_FILE to store the name of the input file.</a></p>
<pre><a name="custom-tools">intermediates:= $(local-intermediates-dir)
GEN := $(intermediates)/<span style="color: red;">file.c</span>
$(GEN): PRIVATE_INPUT_FILE := $(LOCAL_PATH)/<span style="color: red;">input.file</span>
$(GEN): PRIVATE_CUSTOM_TOOL = <span style="color: red;">cat $(PRIVATE_INPUT_FILE) &gt; $@</span>
$(GEN): <span style="color: red;">$(LOCAL_PATH)/file.c</span>
	$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
</a></pre>
<h5><a name="custom-tools">Example 3</a></h5>
<p><a name="custom-tools">If you have several files that are all similar in name, and use the same tool, you can combine them.  (here the *.lut.h files are the generated ones, and the *.cpp files are the input files)</a></p>
<pre><a name="custom-tools">intermediates:= $(local-intermediates-dir)
GEN := $(addprefix $(intermediates)<span style="color: red;">/kjs/, \
            array_object.lut.h \
            bool_object.lut.h \</span>
        )
$(GEN): PRIVATE_CUSTOM_TOOL = <span style="color: red;">perl libs/WebKitLib/WebKit/JavaScriptCore/kjs/create_hash_table $&lt; -i &gt; $@</span>
$(GEN): $(intermediates)/<span style="color: red;">%.lut.h</span> : $(LOCAL_PATH)/<span style="color: red;">%.cpp</span>
	$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
</a></pre>
<h3><a name="platform-specific">Platform specific conditionals</a></h3>
<p><a name="platform-specific">Sometimes you need to set flags specifically for different platforms.  Here is a list of which values the different build-system defined variables will be set to and some examples.</a></p>
<p><a name="platform-specific">For a device build, <code>TARGET_OS</code> is <code>linux</code> (we&#8217;re using linux!), and <code>TARGET_ARCH</code> is <code>arm</code>.</a></p>
<p><a name="platform-specific">For a simulator build, <code>TARGET_OS</code> and <code>TARGET_ARCH</code> are set to the same as <code>HOST_OS</code> and <code>HOST_ARCH</code> are on your platform.  <code>TARGET_PRODUCT</code> is the name of the target hardware/product you are building for.  The value <code>sim</code> is used for the simulator.  We haven&#8217;t thought through the full extent of customization that will happen here, but likely there will be additional UI configurations specified here as well.</a></p>
<table cellspacing="25">
<tbody>
<tr>
<td align="center" valign="top"><strong>HOST_OS</strong><br />
linux<br />
darwin<br />
(cygwin)</td>
<td align="center" valign="top"><strong>HOST_ARCH</strong><br />
x86</td>
<td align="center" valign="top"><strong>HOST_BUILD_TYPE</strong><br />
release<br />
debug</td>
</tr>
<tr>
<td align="center" valign="top"><strong>TARGET_OS</strong><br />
linux<br />
darwin<br />
(cygwin)</td>
<td align="center" valign="top"><strong>TARGET_ARCH</strong><br />
arm<br />
x86</td>
<td align="center" valign="top"><strong>TARGET_BUILD_TYPE</strong><br />
release<br />
debug</td>
<td align="center" valign="top"><strong>TARGET_PRODUCT</strong><br />
sim<br />
dream<br />
sooner</td>
</tr>
</tbody>
</table>
<h4><a name="platform-specific">TARGET_SIMULATOR</a></h4>
<p><a name="platform-specific">If we&#8217;re building the simulator, as opposed to the arm or emulator builds, <code>TARGET_SIMULATOR</code> will be set to <code>true</code>. </a></p>
<h4><a name="platform-specific">Some Examples</a></h4>
<pre><a name="platform-specific">ifeq ($(TARGET_SIMULATOR),true)
LOCAL_CFLAGS += -DSIMULATOR
endif

ifeq ($(TARGET_BUILD_TYPE),release)
LOCAL_CFLAGS += -DNDEBUG=1
endif

# from libutils
ifeq ($(TARGET_OS),linux)
# Use the futex based mutex and condition variable
# implementation from android-arm because it's shared mem safe
LOCAL_SRC_FILES += futex_synchro.c
LOCAL_LDLIBS += -lrt -ldl
endif

</a></pre>
<h3><a name="moving-modules">Putting modules elsewhere</a></h3>
<p><a name="moving-modules">If you have modules that normally go somewhere, and you need to have them build somewhere else, read this.  One use of this is putting files on the root filesystem instead of where they normally go in /system. Add these lines to your Android.mk:</a></p>
<pre><a name="moving-modules">LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN)
LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED)
</a></pre>
<p><a name="moving-modules">For executables and libraries, you need to also specify a <code>LOCAL_UNSTRIPPED_PATH</code> location, because on target builds, we keep the unstripped executables so GDB can find the symbols. </a></p>
<p><a name="moving-modules">Look in <code>config/envsetup.make</code> for all of the variables defining places to build things.</a></p>
<p><a name="moving-modules">FYI: If you&#8217;re installing an executable to /sbin, you probably also want to set <code>LOCAL_FORCE_STATIC_EXCUTABLE := true</code> in your Android.mk, which will force the linker to only accept static libraries.</a></p>
<h3><a name="moving-modules">Android.mk variables</a></h3>
<p><a name="moving-modules">These are the variables that you&#8217;ll commonly see in Android.mk files, listed alphabetically.</a></p>
<p><a name="moving-modules">But first, a note on variable naming: </a></p>
<ul><a name="moving-modules"> </a></p>
<li><a name="moving-modules"><strong>LOCAL_</strong> &#8211; These variables are set per-module.  They are cleared     by the <code>include $(CLEAR_VARS)</code> line, so you can rely on them     being empty after including that file.  Most of the variables you&#8217;ll use     in most modules are LOCAL_ variables.</a></li>
<p><a name="moving-modules"> </a></p>
<li><a name="moving-modules"><strong>PRIVATE_</strong> &#8211; These variables are make-target-specific variables.  That     means they&#8217;re only usable within the commands for that module.  It also     means that they&#8217;re unlikely to change behind your back from modules that     are included after yours.  This </a><a href="http://www.gnu.org/software/make/manual/make.html#Target_002dspecific">link to the make documentation</a> describes more about target-specific variables.  Please note that there     are a couple of these laying around the tree that aren&#8217;t prefixed with     PRIVATE_.  It is safe, and they will be fixed as they are discovered.     Sorry for the confusion.</li>
<li><strong>INTERNAL_</strong> &#8211; These variables are critical to functioning of     the build system, so you shouldn&#8217;t create variables named like this, and     you probably shouldn&#8217;t be messing with these variables in your makefiles.</li>
<li><strong>HOST_</strong> and <strong>TARGET_</strong> &#8211; These contain the directories     and definitions that are specific to either the host or the target builds.     Do not set variables that start with HOST_ or TARGET_ in your makefiles.</li>
<li><strong>BUILD_</strong> and <strong>CLEAR_VARS</strong> &#8211; These contain the names of     well-defined template makefiles to include.  Some examples are CLEAR_VARS     and BUILD_HOST_PACKAGE.</li>
<li>Any other name is fair-game for you to use in your Android.mk.  However,     remember that this is a non-recursive build system, so it is possible that     your variable will be changed by another Android.mk included later, and be     different when the commands for your rule / module are executed.</li>
</ul>
<h4>LOCAL_ASSET_FILES</h4>
<p>In Android.mk files that <code>include $(BUILD_PACKAGE)</code> set this to the set of files you want built into your app.  Usually:</p>
<p><code>LOCAL_ASSET_FILES += $(call find-subdir-assets)</code></p>
<p>This will probably change when we switch to ant for the apps&#8217; build system.</p>
<h4>LOCAL_CC</h4>
<p>If you want to use a different C compiler for this module, set LOCAL_CC to the path to the compiler.  If LOCAL_CC is blank, the appropriate default compiler is used.</p>
<h4>LOCAL_CXX</h4>
<p>If you want to use a different C++ compiler for this module, set LOCAL_CXX to the path to the compiler.  If LOCAL_CXX is blank, the appropriate default compiler is used.</p>
<h4>LOCAL_CFLAGS</h4>
<p>If you have additional flags to pass into the C or C++ compiler, add them here.  For example:</p>
<p><code>LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1</code></p>
<h4>LOCAL_CPPFLAGS</h4>
<p>If you have additional flags to pass into <em>only</em> the C++ compiler, add them here.  For example:</p>
<p><code>LOCAL_CPPFLAGS += -ffriend-injection</code></p>
<p><code>LOCAL_CPPFLAGS</code> is guaranteed to be after <code>LOCAL_CFLAGS</code> on the compile line, so you can use it to override flags listed in <code>LOCAL_CFLAGS</code>.</p>
<h4>LOCAL_CPP_EXTENSION</h4>
<p>If your C++ files end in something other than “<code>.cpp</code>“, you can specify the custom extension here.  For example:</p>
<p><code>LOCAL_CPP_EXTENSION := .cc</code></p>
<p>Note that all C++ files for a given module must have the same extension; it is not currently possible to mix different extensions.</p>
<h4>LOCAL_NO_DEFAULT_COMPILER_FLAGS</h4>
<p>Normally, the compile line for C and C++ files includes global include paths and global cflags.  If <code>LOCAL_NO_DEFAULT_COMPILER_FLAGS</code> is non-empty, none of the default includes or flags will be used when compiling C and C++ files in this module. <code>LOCAL_C_INCLUDES</code>, <code>LOCAL_CFLAGS</code>, and <code>LOCAL_CPPFLAGS</code> will still be used in this case, as will any <code>DEBUG_CFLAGS</code> that are defined for the module.</p>
<h4>LOCAL_COPY_HEADERS</h4>
<p>This will be going away.</p>
<p>The set of files to copy to the install include tree.  You must also supply <code>LOCAL_COPY_HEADERS_TO</code>.</p>
<p>This is going away because copying headers messes up the error messages, and may lead to people editing those headers instead of the correct ones.  It also makes it easier to do bad layering in the system, which we want to avoid.  We also aren&#8217;t doing a C/C++ SDK, so there is no ultimate requirement to copy any headers.</p>
<h4>LOCAL_COPY_HEADERS_TO</h4>
<p>This will be going away.</p>
<p>The directory within “include” to copy the headers listed in <code>LOCAL_COPY_HEADERS</code> to.</p>
<p>This is going away because copying headers messes up the error messages, and may lead to people editing those headers instead of the correct ones.  It also makes it easier to do bad layering in the system, which we want to avoid.  We also aren&#8217;t doing a C/C++ SDK, so there is no ultimate requirement to copy any headers.</p>
<h4>LOCAL_C_INCLUDES</h4>
<p>Additional directories to instruct the C/C++ compilers to look for header files in.  These paths are rooted at the top of the tree.  Use <code>LOCAL_PATH</code> if you have subdirectories of your own that you want in the include paths.  For example:</p>
<p><code> LOCAL_C_INCLUDES += extlibs/zlib-1.2.3<br />
LOCAL_C_INCLUDES += $(LOCAL_PATH)/src </code></p>
<p>You should not add subdirectories of include to <code>LOCAL_C_INCLUDES</code>, instead you should reference those files in the <code>#include</code> statement with their subdirectories.  For example:</p>
<p><code>#include &lt;utils/KeyedVector.h&gt;</code><br />
not <code>#include &lt;KeyedVector.h&gt;</code></p>
<p>There are some components that are doing this wrong, and should be cleaned up.</p>
<h4>LOCAL_MODULE_TAGS</h4>
<p>Set <code>LOCAL_MODULE_TAGS</code> to any number of whitespace-separated tags.  If the tag list is empty or contains <code>droid</code>, the module will get installed as part of a <code>make droid</code>.  Modules with the tag <code>shell_</code>$(TARGET_SHELL) will also be installed. Otherwise, it will only get installed by running <code>make &lt;your-module&gt;</code> or with the <code>make all</code> pseudotarget.</p>
<h4>LOCAL_REQUIRED_MODULES</h4>
<p>Set <code>LOCAL_REQUIRED_MODULES</code> to any number of whitespace-separated module names, like “libblah” or “Email”.  If this module is installed, all of the modules that it requires will be installed as well.  This can be used to, e.g., ensure that necessary shared libraries or providers are installed when a given app is installed.</p>
<h4>LOCAL_FORCE_STATIC_EXECUTABLE</h4>
<p>If your executable should be linked statically, set  <code>LOCAL_FORCE_STATIC_EXECUTABLE:=true</code>.  There is a very short list of libraries that we have in static form (currently only libc).  This is really only used for executables in /sbin on the root filesystem.</p>
<h4>LOCAL_GENERATED_SOURCES</h4>
<p>Files that you add to <code>LOCAL_GENERATED_SOURCES</code> will be automatically generated and then linked in when your module is built. See the <a href="http://android.git.kernel.org/?p=platform/build.git;a=blob_plain;f=core/build-system.html#custom-tools">Custom Tools</a> template makefile for an example.</p>
<h4>LOCAL_JAVACFLAGS</h4>
<p>If you have additional flags to pass into the javac compiler, add them here.  For example:</p>
<p><code>LOCAL_JAVACFLAGS += -Xlint:deprecation</code></p>
<h4>LOCAL_JAVA_LIBRARIES</h4>
<p>When linking Java apps and libraries, <code>LOCAL_JAVA_LIBRARIES</code> specifies which sets of java classes to include.  Currently there are two of these: <code>core</code> and <code>framework</code>. In most cases, it will look like this:</p>
<p><code>LOCAL_JAVA_LIBRARIES := core framework</code></p>
<p>Note that setting <code>LOCAL_JAVA_LIBRARIES</code> is not necessary (and is not allowed) when building an APK with “<code>include $(BUILD_PACKAGE)</code>“.  The appropriate libraries will be included automatically.</p>
<h4>LOCAL_LDFLAGS</h4>
<p>You can pass additional flags to the linker by setting <code>LOCAL_LDFLAGS</code>.  Keep in mind that the order of parameters is very important to ld, so test whatever you do on all platforms.</p>
<h4>LOCAL_LDLIBS</h4>
<p><code>LOCAL_LDLIBS</code> allows you to specify additional libraries that are not part of the build for your executable or library.  Specify the libraries you want in -lxxx format; they&#8217;re passed directly to the  link line.  However, keep in mind that there will be no dependency generated for these libraries.  It&#8217;s most useful in simulator builds where you want to use a library preinstalled on the host.  The linker (ld) is a particularly fussy beast, so it&#8217;s sometimes necessary to pass other flags here if you&#8217;re doing something sneaky. Some examples:</p>
<p><code>LOCAL_LDLIBS += -lcurses -lpthread<br />
LOCAL_LDLIBS += -Wl,-z,origin </code></p>
<h4>LOCAL_NO_MANIFEST</h4>
<p>If your package doesn&#8217;t have a manifest (AndroidManifest.xml), then set <code>LOCAL_NO_MANIFEST:=true</code>.  The common resources package does this.</p>
<h4>LOCAL_PACKAGE_NAME</h4>
<p><code>LOCAL_PACKAGE_NAME</code> is the name of an app.  For example, Dialer, Contacts, etc.  This will probably change or go away when we switch to an ant-based build system for the apps.</p>
<h4>LOCAL_PATH</h4>
<p>The directory your Android.mk file is in. You can set it by putting the following as the first line in your Android.mk:</p>
<p><code>LOCAL_PATH := $(my-dir)</code></p>
<p>The <code>my-dir</code> macro uses the  <code><a href="http://www.gnu.org/software/make/manual/make.html#MAKEFILE_005fLIST-Variable">MAKEFILE_LIST</a></code> variable, so you must call it before you include any other makefiles.  Also, consider that any subdirectories you inlcude might reset LOCAL_PATH, so do your own stuff before you include them.  This also means that if you try to write several <code>include</code> lines that reference <code>LOCAL_PATH</code>, it won&#8217;t work, because those included makefiles might reset LOCAL_PATH.</p>
<h4>LOCAL_POST_PROCESS_COMMAND</h4>
<p>For host executables, you can specify a command to run on the module after it&#8217;s been linked.  You might have to go through some contortions to get variables right because of early or late variable evaluation:</p>
<p><code>module := $(HOST_OUT_EXECUTABLES)/$(LOCAL_MODULE)<br />
LOCAL_POST_PROCESS_COMMAND := /Developer/Tools/Rez -d __DARWIN__ -t APPL\<br />
-d __WXMAC__ -o $(module) Carbon.r </code></p>
<h4>LOCAL_PREBUILT_EXECUTABLES</h4>
<p>When including $(BUILD_PREBUILT) or $(BUILD_HOST_PREBUILT), set these to executables that you want copied.  They&#8217;re located automatically into the right bin directory.</p>
<h4>LOCAL_PREBUILT_LIBS</h4>
<p>When including $(BUILD_PREBUILT) or $(BUILD_HOST_PREBUILT), set these to libraries that you want copied.  They&#8217;re located automatically into the right lib directory.</p>
<h4>LOCAL_SHARED_LIBRARIES</h4>
<p>These are the libraries you directly link against.  You don&#8217;t need to pass transitively included libraries.  Specify the name without the suffix:</p>
<p><code>LOCAL_SHARED_LIBRARIES := \<br />
libutils \<br />
libui \<br />
libaudio \<br />
libexpat \<br />
libsgl </code></p>
<h4>LOCAL_SRC_FILES</h4>
<p>The build system looks at <code>LOCAL_SRC_FILES</code> to know what source files to compile &#8212; .cpp .c .y .l .java.  For lex and yacc files, it knows how to correctly do the intermediate .h and .c/.cpp files automatically.  If the files are in a subdirectory of the one containing the Android.mk, prefix them with the directory name:</p>
<p><code>LOCAL_SRC_FILES := \<br />
file1.cpp \<br />
dir/file2.cpp </code></p>
<h4>LOCAL_STATIC_LIBRARIES</h4>
<p>These are the static libraries that you want to include in your module. Mostly, we use shared libraries, but there are a couple of places, like executables in sbin and host executables where we use static libraries instead.</p>
<p><code>LOCAL_STATIC_LIBRARIES := \<br />
libutils \<br />
libtinyxml </code></p>
<h4>LOCAL_MODULE</h4>
<p><code>LOCAL_MODULE</code> is the name of what&#8217;s supposed to be generated from your Android.mk.  For exmample, for libkjs, the <code>LOCAL_MODULE</code> is “libkjs” (the build system adds the appropriate suffix &#8212; .so .dylib .dll). For app modules, use <code>LOCAL_PACKAGE_NAME</code> instead of  <code>LOCAL_MODULE</code>.  We&#8217;re planning on switching to ant for the apps, so this might become moot.</p>
<h4>LOCAL_MODULE_PATH</h4>
<p>Instructs the build system to put the module somewhere other than what&#8217;s normal for its type.  If you override this, make sure you also set <code>LOCAL_UNSTRIPPED_PATH</code> if it&#8217;s an executable or a shared library so the unstripped binary has somewhere to go.  An error will occur if you forget to.</p>
<p>See <a href="http://android.git.kernel.org/?p=platform/build.git;a=blob_plain;f=core/build-system.html#moving-modules">Putting modules elsewhere</a> for more.</p>
<h4>LOCAL_UNSTRIPPED_PATH</h4>
<p>Instructs the build system to put the unstripped version of the module somewhere other than what&#8217;s normal for its type.  Usually, you override this because you overrode <code>LOCAL_MODULE_PATH</code> for an executable or a shared library.  If you overrode <code>LOCAL_MODULE_PATH</code>, but not  <code>LOCAL_UNSTRIPPED_PATH</code>, an error will occur.</p>
<p>See <a href="http://android.git.kernel.org/?p=platform/build.git;a=blob_plain;f=core/build-system.html#moving-modules">Putting modules elsewhere</a> for more.</p>
<h4>LOCAL_WHOLE_STATIC_LIBRARIES</h4>
<p>These are the static libraries that you want to include in your module without allowing the linker to remove dead code from them. This is mostly useful if you want to add a static library to a shared library and have the static library&#8217;s content exposed from the shared library.</p>
<p><code>LOCAL_WHOLE_STATIC_LIBRARIES := \<br />
libsqlite3_android<br />
</code></p>
<h4>LOCAL_YACCFLAGS</h4>
<p>Any flags to pass to invocations of yacc for your module.  A known limitation here is that the flags will be the same for all invocations of YACC for your module.  This can be fixed.  If you ever need it to be, just ask.</p>
<p><code>LOCAL_YACCFLAGS := -p kjsyy</code></p>
<h2>Implementation Details</h2>
<p>You should never have to touch anything in the config directory unless you&#8217;re adding a new platform, new tools, or adding new features to the build system.  In general, please consult with the build system owner(s) (<a href="mailto:android-build-team">android-build-team</a>) before you go mucking around in here.  That said, here are some notes on what&#8217;s going on under the hood.</p>
<h3>Environment Setup / buildspec.mk Versioning</h3>
<p>In order to make easier for people when the build system changes, when it is necessary to make changes to buildspec.mk or to rerun the environment setup scripts, they contain a version number in the variable BUILD_ENV_SEQUENCE_NUMBER.  If this variable does not match what the build system expects, it fails printing an error message explaining what happened. If you make a change that requires an update, you need to update two places so this message will be printed.</p>
<ul>
<li>In config/envsetup.make, increment the         CORRECT_BUILD_ENV_SEQUENCE_NUMBER definition.</li>
<li>In buildspec.mk.default, update the BUILD_ENV_SEQUENCE_DUMBER         definition to match the one in config/envsetup.make</li>
</ul>
<p>The scripts automatically get the value from the build system, so they will trigger the warning as well.</p>
<h3>Additional makefile variables</h3>
<p>You probably shouldn&#8217;t use these variables.  Please consult <a href="mailto:android-build-team">android-build-team</a> before using them. These are mostly there for workarounds for other issues, or things that aren&#8217;t completely done right.</p>
<h4>LOCAL_ADDITIONAL_DEPENDENCIES</h4>
<p>If your module needs to depend on anything else that isn&#8217;t actually built in to it, you can add those make targets to  <code>LOCAL_ADDITIONAL_DEPENDENCIES</code>.  Usually this is a workaround for some other dependency that isn&#8217;t created automatically.</p>
<h4>LOCAL_BUILT_MODULE</h4>
<p>When a module is built, the module is created in an intermediate directory then copied to its final location.  LOCAL_BUILT_MODULE is the full path to the intermediate file.  See LOCAL_INSTALLED_MODULE for the path to the final installed location of the module.</p>
<h4>LOCAL_HOST</h4>
<p>Set by the host_xxx.make includes to tell base_rules.make and the other includes that we&#8217;re building for the host.  Kenneth did this as part of openbinder, and I would like to clean it up so the rules, includes and definitions aren&#8217;t duplicated for host and target.</p>
<h4>LOCAL_INSTALLED_MODULE</h4>
<p>The fully qualified path name of the final location of the module. See LOCAL_BUILT_MODULE for the location of the intermediate file that the make rules should actually be constructing.</p>
<h4>LOCAL_REPLACE_VARS</h4>
<p>Used in some stuff remaining from the openbinder for building scripts with particular values set,</p>
<h4>LOCAL_SCRIPTS</h4>
<p>Used in some stuff remaining from the openbinder build system that we might find handy some day.</p>
<h4>LOCAL_MODULE_CLASS</h4>
<p>Which kind of module this is.  This variable is used to construct other variable names used to locate the modules.  See base_rules.make and envsetup.make.</p>
<h4>LOCAL_MODULE_NAME</h4>
<p>Set to the leaf name of the LOCAL_BUILT_MODULE.  I&#8217;m not sure, but it looks like it&#8217;s just used in the WHO_AM_I variable to identify in the pretty printing what&#8217;s being built.</p>
<h4>LOCAL_MODULE_SUFFIX</h4>
<p>The suffix that will be appended to <code>LOCAL_MODULE</code> to form <code>LOCAL_MODULE_NAME</code>.  For example, .so, .a, .dylib.</p>
<h4>LOCAL_STRIP_MODULE</h4>
<p>Calculated in base_rules.make to determine if this module should actually be stripped or not, based on whether <code>LOCAL_STRIPPABLE_MODULE</code> is set, and whether the combo is configured to ever strip modules.  With Iliyan&#8217;s stripping tool, this might change.</p>
<h4>LOCAL_STRIPPABLE_MODULE</h4>
<p>Set by the include makefiles if that type of module is strippable.  Executables and shared libraries are.</p>
<h4>LOCAL_SYSTEM_SHARED_LIBRARIES</h4>
<p>Used while building the base libraries: libc, libm, libdl.  Usually it should be set to “none,” as it is in $(CLEAR_VARS).  When building these libraries, it&#8217;s set to the ones they link against.  For example, libc, libstdc++ and libdl don&#8217;t link against anything, and libm links against libc.  Normally, when the value is none, these libraries are automatically linked in to executables and libraries, so you don&#8217;t need to specify them manually.</p>
]]></content:encoded>
			<wfw:commentRss>http://zhuwenhao.com/709/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android%e7%bc%96%e8%af%91c%e4%bb%a3%e7%a0%81%e6%97%b6%e9%93%be%e6%8e%a5%e5%85%b6%e4%bb%96%e5%ba%93%e6%96%87%e4%bb%b6%e7%9a%84%e6%96%b9%e6%b3%95%e9%99%84make-file%e8%af%a6%e8%a7%a3%e6%89%8b%e5%86%8c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TrueCrypt开源的硬盘优盘实时加密软件</title>
		<link>http://zhuwenhao.com/705/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/%e5%8a%a0%e5%af%86%e8%a7%a3%e5%af%86/truecrypt%e5%bc%80%e6%ba%90%e7%9a%84%e7%a1%ac%e7%9b%98%e4%bc%98%e7%9b%98%e5%ae%9e%e6%97%b6%e5%8a%a0%e5%af%86%e8%bd%af%e4%bb%b6/</link>
		<comments>http://zhuwenhao.com/705/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/%e5%8a%a0%e5%af%86%e8%a7%a3%e5%af%86/truecrypt%e5%bc%80%e6%ba%90%e7%9a%84%e7%a1%ac%e7%9b%98%e4%bc%98%e7%9b%98%e5%ae%9e%e6%97%b6%e5%8a%a0%e5%af%86%e8%bd%af%e4%bb%b6/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 15:19:06 +0000</pubDate>
		<dc:creator>朱文昊 Albert Zhu</dc:creator>
				<category><![CDATA[加密解密]]></category>

		<guid isPermaLink="false">http://zhuwenhao.com/?p=705</guid>
		<description><![CDATA[在最近这场360和腾讯的斗争中，以及斗争的结局，让我感到了深深的惊恐。
这场大戏外行看热闹，内行看门道。其深远的现实意义以及历史意义，已经到了只可意会、不可言传的地步。
如果你重视自己的信息安全，除了要在远离实名制网站、流氓软件之外，还要加密所有的网络连接，本地硬盘当然也不能不加密。这是一款开源的免费（许可证不是GPL）的软件，用于在读写过程中加密解密数据，构建一个他人难以窥探的数据存储方案。他甚至可以加密整个硬盘，包括操作系统在内。
网站地址： http://www.truecrypt.org/
新手指南：http://www.truecrypt.org/docs/?s=tutorial
]]></description>
			<content:encoded><![CDATA[<p>在最近这场360和腾讯的斗争中，以及斗争的结局，让我感到了深深的惊恐。</p>
<p>这场大戏外行看热闹，内行看门道。其深远的现实意义以及历史意义，已经到了只可意会、不可言传的地步。</p>
<p>如果你重视自己的信息安全，除了要在远离实名制网站、流氓软件之外，还要加密所有的网络连接，本地硬盘当然也不能不加密。这是一款开源的免费（许可证不是GPL）的软件，用于在读写过程中加密解密数据，构建一个他人难以窥探的数据存储方案。他甚至可以加密整个硬盘，包括操作系统在内。</p>
<p>网站地址： http://www.truecrypt.org/</p>
<p>新手指南：http://www.truecrypt.org/docs/?s=tutorial</p>
]]></content:encoded>
			<wfw:commentRss>http://zhuwenhao.com/705/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/%e5%8a%a0%e5%af%86%e8%a7%a3%e5%af%86/truecrypt%e5%bc%80%e6%ba%90%e7%9a%84%e7%a1%ac%e7%9b%98%e4%bc%98%e7%9b%98%e5%ae%9e%e6%97%b6%e5%8a%a0%e5%af%86%e8%bd%af%e4%bb%b6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AudioRecord的使用例程</title>
		<link>http://zhuwenhao.com/676/%e9%9a%8f%e7%ac%94/audiorecord%e7%9a%84%e4%bd%bf%e7%94%a8%e4%be%8b%e7%a8%8b/</link>
		<comments>http://zhuwenhao.com/676/%e9%9a%8f%e7%ac%94/audiorecord%e7%9a%84%e4%bd%bf%e7%94%a8%e4%be%8b%e7%a8%8b/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 05:36:31 +0000</pubDate>
		<dc:creator>朱文昊 Albert Zhu</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[随笔]]></category>

		<guid isPermaLink="false">http://zhuwenhao.com/?p=676</guid>
		<description><![CDATA[Android 1.5 has a AudioRecord class that can record raw audio. Here  is a tutorial with source code on how to do it. Tried it out and its  working. The program creates a test.raw in the sdcard.
http://www.anddev.org/viewtopic.php?p=22820
This is from that link:
Okay. It works now. It turns out that  [...]]]></description>
			<content:encoded><![CDATA[<p>Android 1.5 has a AudioRecord class that can record raw audio. Here  is a tutorial with source code on how to do it. Tried it out and its  working. The program creates a test.raw in the sdcard.</p>
<p><a title="http://www.anddev.org/viewtopic.php?p=22820" href="http://go2.wordpress.com/?id=725X1342&amp;site=hashspeaks.wordpress.com&amp;url=http%3A%2F%2Fwww.anddev.org%2Fviewtopic.php%3Fp%3D22820&amp;sref=http%3A%2F%2Fhashspeaks.wordpress.com%2F2009%2F06%2F18%2Faudiorecord-part-4%2F" target="_blank">http://www.anddev.org/viewtopic.php?p=22820</a></p>
<p>This is from that link:</p>
<p><em>Okay. It works now. It turns out that the audio device  stopped responding after the Music application, for lack of a more  precise description, wonked-out; a reboot restored the audio device to a  functional state.</em></p>
<p><em>After playing with the the code I have, </em></p>
<p><em><span id="more-676"></span></em></p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p676code11'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p67611"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
</pre></td><td class="code" id="p676code11"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.BufferedOutputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.DataOutputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.File</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.FileNotFoundException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.FileOutputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.media.AudioFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.media.AudioRecord</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.media.MediaRecorder</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Recorder <span style="color: #000000; font-weight: bold;">implements</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Arunnable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Runnable</span></a> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> frequency<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> channelConfiguration<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">volatile</span> <span style="color: #000066; font-weight: bold;">boolean</span> isPaused<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Afile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">File</span></a> fileName<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">volatile</span> <span style="color: #000066; font-weight: bold;">boolean</span> isRecording<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aobject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Object</span></a> mutex <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aobject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Object</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Changing the sample resolution changes sample type. byte vs. short.</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> audioEncoding <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aaudioformat+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">AudioFormat</span></a>.<span style="color: #006633;">ENCODING_PCM_16BIT</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
*
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> Recorder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">setFrequency</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">11025</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">setChannelConfiguration</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aaudioformat+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">AudioFormat</span></a>.<span style="color: #006633;">CHANNEL_CONFIGURATION_MONO</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">setPaused</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// Wait until we’re recording…</span>
<span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #009900;">&#40;</span>mutex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">isRecording</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
mutex.<span style="color: #006633;">wait</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainterruptedexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">InterruptedException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aillegalstateexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IllegalStateException</span></a><span style="color: #009900;">&#40;</span>“Wait<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> interrupted<span style="color: #339933;">!</span>”, e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Open output stream…</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">fileName</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aillegalstateexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IllegalStateException</span></a><span style="color: #009900;">&#40;</span>“fileName is <span style="color: #000066; font-weight: bold;">null</span>”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedoutputstream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">BufferedOutputStream</span></a> bufferedStreamInstance <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>fileName.<span style="color: #006633;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
fileName.<span style="color: #006633;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
fileName.<span style="color: #006633;">createNewFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aillegalstateexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IllegalStateException</span></a><span style="color: #009900;">&#40;</span>“Cannot create file<span style="color: #339933;">:</span> “ <span style="color: #339933;">+</span> fileName.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
bufferedStreamInstance <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedoutputstream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">BufferedOutputStream</span></a><span style="color: #009900;">&#40;</span>
<span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Afileoutputstream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">FileOutputStream</span></a><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">fileName</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Afilenotfoundexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">FileNotFoundException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aillegalstateexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IllegalStateException</span></a><span style="color: #009900;">&#40;</span>“Cannot Open <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Afile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">File</span></a>”, e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adataoutputstream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">DataOutputStream</span></a> dataOutputStreamInstance <span style="color: #339933;">=</span>
<span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adataoutputstream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">DataOutputStream</span></a><span style="color: #009900;">&#40;</span>bufferedStreamInstance<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// We’re important…</span>
android.<span style="color: #006633;">os</span>.<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aprocess+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Process</span></a>
.<span style="color: #006633;">setThreadPriority</span><span style="color: #009900;">&#40;</span>android.<span style="color: #006633;">os</span>.<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aprocess+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Process</span></a>.<span style="color: #006633;">THREAD_PRIORITY_URGENT_AUDIO</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Allocate Recorder and Start Recording…</span>
<span style="color: #000066; font-weight: bold;">int</span> bufferRead <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">int</span> bufferSize <span style="color: #339933;">=</span> AudioRecord.<span style="color: #006633;">getMinBufferSize</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getFrequency</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getChannelConfiguration</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getAudioEncoding</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
AudioRecord recordInstance <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AudioRecord<span style="color: #009900;">&#40;</span>
MediaRecorder.<span style="color: #006633;">AudioSource</span>.<span style="color: #006633;">MIC</span>, <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getFrequency</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">this</span>
.<span style="color: #006633;">getChannelConfiguration</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getAudioEncoding</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
bufferSize<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">short</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> tempBuffer <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">short</span><span style="color: #009900;">&#91;</span>bufferSize<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
recordInstance.<span style="color: #006633;">startRecording</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">isRecording</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// Are we paused?</span>
<span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #009900;">&#40;</span>mutex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">isPaused</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
mutex.<span style="color: #006633;">wait</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainterruptedexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">InterruptedException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aillegalstateexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IllegalStateException</span></a><span style="color: #009900;">&#40;</span>“Wait<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> interrupted<span style="color: #339933;">!</span>”,
e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
bufferRead <span style="color: #339933;">=</span> recordInstance.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span>tempBuffer, <span style="color: #cc66cc;">0</span>, bufferSize<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>bufferRead <span style="color: #339933;">==</span> AudioRecord.<span style="color: #006633;">ERROR_INVALID_OPERATION</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aillegalstateexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IllegalStateException</span></a><span style="color: #009900;">&#40;</span>
“read<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> returned AudioRecord.<span style="color: #006633;">ERROR_INVALID_OPERATION</span>”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>bufferRead <span style="color: #339933;">==</span> AudioRecord.<span style="color: #006633;">ERROR_BAD_VALUE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aillegalstateexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IllegalStateException</span></a><span style="color: #009900;">&#40;</span>
“read<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> returned AudioRecord.<span style="color: #006633;">ERROR_BAD_VALUE</span>”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>bufferRead <span style="color: #339933;">==</span> AudioRecord.<span style="color: #006633;">ERROR_INVALID_OPERATION</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aillegalstateexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IllegalStateException</span></a><span style="color: #009900;">&#40;</span>
“read<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> returned AudioRecord.<span style="color: #006633;">ERROR_INVALID_OPERATION</span>”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> idxBuffer <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> idxBuffer <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> bufferRead<span style="color: #339933;">;</span> <span style="color: #339933;">++</span>idxBuffer<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
dataOutputStreamInstance.<span style="color: #006633;">writeShort</span><span style="color: #009900;">&#40;</span>tempBuffer<span style="color: #009900;">&#91;</span>idxBuffer<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aillegalstateexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IllegalStateException</span></a><span style="color: #009900;">&#40;</span>
“dataOutputStreamInstance.<span style="color: #006633;">writeShort</span><span style="color: #009900;">&#40;</span>curVal<span style="color: #009900;">&#41;</span>”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Close resources…</span>
recordInstance.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
bufferedStreamInstance.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aillegalstateexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IllegalStateException</span></a><span style="color: #009900;">&#40;</span>“Cannot close buffered writer.”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setFileName<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Afile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">File</span></a> fileName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">fileName</span> <span style="color: #339933;">=</span> fileName<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Afile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">File</span></a> getFileName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">return</span> fileName<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
* @param isRecording
*            the isRecording to set
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setRecording<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">boolean</span> isRecording<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #009900;">&#40;</span>mutex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">isRecording</span> <span style="color: #339933;">=</span> isRecording<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">isRecording</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
mutex.<span style="color: #006633;">notify</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
* @return the isRecording
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> isRecording<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #009900;">&#40;</span>mutex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">return</span> isRecording<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
* @param frequency
*            the frequency to set
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setFrequency<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> frequency<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">frequency</span> <span style="color: #339933;">=</span> frequency<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
* @return the frequency
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> getFrequency<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">return</span> frequency<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
* @param channelConfiguration
*            the channelConfiguration to set
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setChannelConfiguration<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> channelConfiguration<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">channelConfiguration</span> <span style="color: #339933;">=</span> channelConfiguration<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
* @return the channelConfiguration
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> getChannelConfiguration<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">return</span> channelConfiguration<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
* @return the audioEncoding
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> getAudioEncoding<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">return</span> audioEncoding<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
* @param isPaused
*            the isPaused to set
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setPaused<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">boolean</span> isPaused<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #009900;">&#40;</span>mutex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">isPaused</span> <span style="color: #339933;">=</span> isPaused<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
* @return the isPaused
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> isPaused<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #009900;">&#40;</span>mutex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">return</span> isPaused<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><em>And, I drive that code with: </em></p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p676code12'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p67612"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code" id="p676code12"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> AudioRecorderPCM <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#123;</span>
<span style="color: #008000; font-style: italic; font-weight: bold;">/** Called when the activity is first created. */</span>
@Override
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
setContentView<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">main</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// Record 20 seconds of audio.</span>
Recorder recorderInstance <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Recorder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Athread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Thread</span></a> th <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Athread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Thread</span></a><span style="color: #009900;">&#40;</span>recorderInstance<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
recorderInstance.<span style="color: #006633;">setFileName</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Afile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">File</span></a><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aenvironment+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Environment</span></a>.<span style="color: #006633;">getExternalStorageDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getAbsolutePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> “<span style="color: #339933;">/</span>test.<span style="color: #006633;">raw</span>”<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
th.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
recorderInstance.<span style="color: #006633;">setRecording</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">wait</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">20000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainterruptedexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">InterruptedException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
recorderInstance.<span style="color: #006633;">setRecording</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
th.<span style="color: #006633;">join</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainterruptedexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">InterruptedException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><em> </em></p>
<p><em>This writes a file ‘test.raw’ to the SDCard. Each sample is a  signed, big endian, 16-bit integer. I was able to play it in matlab with  wavplay.</em></p>
<p><em>Hope this helps anyone else who is trying to get this part of the  API to work. This code works on my G1, but is seems as if there is no  way to tell what the sampling rate and sample resolution on a given  device are. It doesn’t seem to throw any errors if you pick a bad  combination of parameters; it just fails</em> .</p>
<p>原文地址：http://hashspeaks.wordpress.com/2009/06/18/audiorecord-part-4/</p>
]]></content:encoded>
			<wfw:commentRss>http://zhuwenhao.com/676/%e9%9a%8f%e7%ac%94/audiorecord%e7%9a%84%e4%bd%bf%e7%94%a8%e4%be%8b%e7%a8%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android上录音的三种接口</title>
		<link>http://zhuwenhao.com/671/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android%e4%b8%8a%e5%bd%95%e9%9f%b3%e7%9a%84%e4%b8%89%e7%a7%8d%e6%8e%a5%e5%8f%a3/</link>
		<comments>http://zhuwenhao.com/671/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android%e4%b8%8a%e5%bd%95%e9%9f%b3%e7%9a%84%e4%b8%89%e7%a7%8d%e6%8e%a5%e5%8f%a3/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 05:17:11 +0000</pubDate>
		<dc:creator>朱文昊 Albert Zhu</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://zhuwenhao.com/?p=671</guid>
		<description><![CDATA[
THE THREE MUSKETEERS OF AUDIO RECORDING FROM ANDROID
Let me introduce you to the three musketeers of audio recording  from android os. They are the three ways for recording audio in android.  They are
1) Mediarecorder 
2) Audiorecord 
3) Audiorecord :- native  [...]]]></description>
			<content:encoded><![CDATA[<div dir="ltr">
<div>THE THREE MUSKETEERS OF AUDIO RECORDING FROM ANDROID</div>
<div>Let me introduce you to the three musketeers of audio recording  from android os. They are the three ways for recording audio in android.  They are</div>
<div>1)<a href="http://zhuwenhao.com/?p=671#mediarecorder"> Mediarecorder </a></div>
<div>2)<a href="http://zhuwenhao.com/?p=671#audiorecord%20java"> Audiorecord </a></div>
<div>3) <a href="http://zhuwenhao.com/?p=671#audiorecord%20native">Audiorecord :- native interface</a></div>
<div><span style="color: #495900; font-size: medium;"><strong><br />
</strong></span></div>
<p><a name="mediarecorder"></a></p>
<p><a name="mediarecorder"></a><a name="mediarecorder"></a></p>
<div><a name="mediarecorder"></a><a href="http://developer.android.com/reference/android/media/MediaRecorder.html">http://developer.android.com/reference/android/media/MediaRecorder.html</a></div>
<div><strong>USAGE</strong> :- <a href="http://developer.android.com/guide/topics/media/index.html">http://developer.android.com/guide/topics/media/index.html</a></div>
<div>Mediarecorder does what it says. It records media. It can be used  to record audio from Mic to a file on the sdcard. The recorded audio  would be in MPEG4, RAW AMR or 3GP.</div>
<div>Please note : The example provided along with the documentation  does not work. However, there are lots of help on the internet to get  the mediarecorder running.</div>
<div>pros :</div>
<div>
<ul>
<li>easy to use</li>
<li>records audio in compressed format</li>
<li>can be used to record voice calls &#8211; both uplink and downlink</li>
<li>can be used to record speech recognition</li>
</ul>
</div>
<div>cons</div>
<div>
<ul>
<li>can not access the audio buffers</li>
<li>difficult to process the recorded audio as it would be compresses format.</li>
<li>can not change the sampling rate</li>
<li>very little or no control of how the recording happens</li>
</ul>
</div>
<h4>2) <a name="audiorecord java"></a></h4>
<div><strong>API Documentation</strong> :- <a href="http://developer.android.com/reference/android/media/AudioRecord.html">http://developer.android.com/reference/android/media/AudioRecord.html</a></div>
<div><strong>USAGE</strong> :- <a rel="nofollow" href="http://hashspeaks.wordpress.com/2009/06/18/audiorecord-part-4/">http://hashspeaks.wordpress.com/2009/06/18/audiorecord-part-4/</a></div>
<div>Audiorecord API is google&#8217;s official solution to overcome the  limitations of mediarecorder.Audio can be recorded into buffers for post  processing. Audiorecord is a java way to record audio and process  audio.</div>
<div>pros:</div>
<div>
<ul>
<li>records audio as MONO or STEREO</li>
<li>various properties for audiorecording like sample size, sample rate, buffersize can be set.</li>
<li>the recorded audio is provided in buffers.</li>
</ul>
</div>
<div>cons:</div>
<div>
<ul>
<li>difficult to handle buffers.Unless you know what you are doing. you will lose samples.</li>
</ul>
</div>
<h4>3)<a name="audiorecord native"></a></h4>
<div><strong>A LITTLE BIT HELP</strong> : <a rel="nofollow" href="http://hashspeaks.wordpress.com/2009/04/18/audiorecord-in-android-part-2/">http://hashspeaks.wordpress.com/2009/04/18/audiorecord-in-android-part-2/</a></div>
<div>USAGE :- ( Coming soon&#8230; how to build using NDK, sample code and how to use this API )</div>
<div>There is also a native interface &#8211; audiorecord that can be used for  recording audio. The native interface provides API that can be invoked  from c/c++ libraries. These librarires can then be called from Java  activity via JNI. Programs using the interface can be compiled with the  NDK and used in android applications via JNI.</div>
<div>pros:</div>
<div>
<ul>
<li>provides a c/c++ interface to recording</li>
<li>the processing is more efficient when done in c/c++ using this API</li>
</ul>
</div>
<div>cos:</div>
<div>
<ul>
<li>no documentation is available for this interface</li>
<li>google does not official support this interface.</li>
<li>This interface could be removed from future releases without further notification. But has remained for over an year now.</li>
</ul>
</div>
<p>原文地址：http://mobware4u.com/tutorials/android-audio-recording</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://zhuwenhao.com/671/%e6%8a%80%e6%9c%af/%e8%87%aa%e7%94%b1%e8%bd%af%e4%bb%b6%e7%a4%be%e5%8c%ba/android/android%e4%b8%8a%e5%bd%95%e9%9f%b3%e7%9a%84%e4%b8%89%e7%a7%8d%e6%8e%a5%e5%8f%a3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

