{"id":97,"date":"2014-11-12T12:45:15","date_gmt":"2014-11-12T04:45:15","guid":{"rendered":"http:\/\/blog.haostudio.net\/hwp\/?p=97"},"modified":"2017-07-25T00:19:00","modified_gmt":"2017-07-24T16:19:00","slug":"android-%e9%96%8b%e7%99%bc%e7%92%b0%e5%a2%83%e4%b9%8b%e5%ae%89%e8%a3%9d","status":"publish","type":"post","link":"https:\/\/blog.haostudio.net\/hwp\/android-%e9%96%8b%e7%99%bc%e7%92%b0%e5%a2%83%e4%b9%8b%e5%ae%89%e8%a3%9d\/","title":{"rendered":"Android \u958b\u767c\u74b0\u5883\u4e4b\u5b89\u88dd"},"content":{"rendered":"<!--more-->\n<h1>Android \u958b\u767c\u74b0\u5883\u4e4b\u5b89\u88dd<\/h1>\n<h2>OS \u4e4b\u9078\u64c7<\/h2>\n<p>\u5b89\u88dd 64-bit Debian or Ubuntu.  !!\u6ce8\u610f \u4e00\u5b9a\u898164-bit OS, 32-bit \u5728\u7de8\u8b6f\u6642\u6703\u6709\u554f\u984c.\n\u6211\u9078\u64c7\u7684OS \u662f64-bit Debian 7.<\/p>\n<h2>JDK 7<\/h2>\n<p>\u4f9d\u64da<a href=\"https:\/\/source.android.com\/\">Android Open Source Project (AOSP)<\/a> \u4e4b\u5efa\u8b70, \u5148\u5b89\u88ddJDK 7,\n\u7531\u65bcSun \u88abOracle\u4f75\u6389\u5f8c, \u5c0d\u65bcOpen Source \u6975\u5ea6\u4e0d\u53cb\u5584, \u6240\u4ee5\u81ea\u7531\u8edf\u9ad4\u793e\u7fa4\u7d1b\u7d1b\u6295\u9760OpenJDK\u7684\u61f7\u62b1. \u56e0\u6b64\u6b64\u8003<a href=\"http:\/\/openjdk.java.net\/install\/\">\u9019\u88e1<\/a>\u4f86\u5b89\u88ddOpenJDK. \u5728Debian\u74b0\u5883\u4e0b, \u771f\u662f\u7c21\u55ae\u5230\u7206<\/p>\n<pre><code># apt-get install openjdk-7-jre\n<\/code><\/pre>\n<p>\u6216\u8a31\u4f60\u7684\u74b0\u5883\u4e4b\u524d\u5df2\u7d93\u5b89\u88dd\u904eJDK 6 \u6216\u5176\u4ed6\u7248\u672c, \u53ef\u4ee5\u4f7f\u7528\u4e0b\u5217\u6307\u4ee4\u9078\u64c7\u7cfb\u7d71\u4f7f\u7528\u7684JDK\u7248\u672c. \u8acb\u9078\u64c7JDK7\u5594<\/p>\n<pre><code># update-alternatives --config java\n1. update-alternatives --config javac\n<\/code><\/pre>\n<p>\u641e\u5b9a!<\/p>\n<h2>Debian 7(wheezy) \u53caUbuntu 12.04 \u4e0b\u5fc5\u8981\u4e4b\u5957\u4ef6<\/h2>\n<pre><code># apt-get install git gnupg flex bison gperf build-essential \\\n  zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \\\n  libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \\\n  libgl1-mesa-dev g++-multilib mingw32 tofrodos \\\n  python-markdown libxml2-utils xsltproc zlib1g-dev:i386\n<\/code><\/pre>\n<p>\u82e5\u6709\u4e9bi386\u7684\u5957\u4ef6\u7121\u6cd5\u5b89\u88dd, \u53ef\u80fd\u9700\u8981\u5148\u65b0\u589ei386 \u7684architecture. \u5982\u4e0b:<\/p>\n<pre><code># dpkg --add-architecture i386\n1. apt-get update\n<\/code><\/pre>\n<p>\u6709\u4e9b\u7248\u672c\u5728build kernel \u6642\u9700\u8981\u5728\u5b89\u88dd\u4e0b\u5217\u5957\u4ef6<\/p>\n<pre><code># apt-get install u-boot-tools\n<\/code><\/pre>\n<h2>USB \u5b58\u53d6\u6b0a\u9650<\/h2>\n<p>\u5728\u4e00\u4e9bLinux \u4e2dDistribution \u4e2d, \u4e00\u822c\u7684\u4f7f\u7528\u8005\u4e26\u6c92\u6709USB \u88dd\u7f6e\u5b58\u53d6\u7684\u6b0a\u9650, \u56e0\u6b64\u6211\u5011\u53ef\u4ee5\u900f\u904eudev \u7684\u8a2d\u5b9a\u6a94\u4f86\u70ba\u6211\u5011\u6307\u5b9a\u6b0a\u9650.\n\u5148\u5207\u63db\u5230root, \u7136\u5f8c\u5728 \/etc\/udev\/rules.d\/\u4e2d\u65b0\u589e\u4e00\u500budev\u898f\u5247\u8a2d\u5b9a\u6a94. \u6211\u5011\u5c07\u6b64\u6a94\u53d6\u540d\u53eb51-android.rules \u597d\u4e86.\n!! \u6ce8\u610f!! udev \u5fc5\u9808\u662f\u5728linux kernel 2.6\u4ee5\u5f8c\u624d\u6709\u652f\u63f4. \u8a73\u7d30\u7684udev\u539f\u7406\u53ca\u898f\u5247\u8a2d\u5b9a, \u8acb\u53c3\u8003\u5f8c\u9762\u7684\u53c3\u8003\u8cc7\u6599.\n\u6a94\u6848: 51-android.rules \u5167\u5bb9\u5982\u4e0b<\/p>\n<pre><code># adb protocol on passion (for your ARM board)\nSUBSYSTEM==&quot;usb&quot;, ATTR{idVendor}==&quot;xxxx&quot;, ATTR{idProduct}==&quot;yyyy&quot;, MODE=&quot;0600&quot;, OWNER=&quot;&lt;username&gt;&quot;\n<\/code><\/pre>\n<p>\u5176\u4e2d&#8221;xxxx&#8221;, &#8220;yyyy&#8221; \u5206\u5225\u586b\u5165\u4f60\u7684ARM\u677f\u5b50\u4e0aUSB port(for adb) \u7684vendor id \u53caproduct id. \u800cusername \u5247\u586b\u5165\u4f60\u7684account.<\/p>\n<h2>\u8a2d\u5b9acache<\/h2>\n<p>\u8a2d\u5b9acache \u80fd\u5920\u52a0\u901f\u7de8\u8b6f\u901f\u5ea6. \u9019\u500b\u9078\u9805\u4e0d\u662f\u5fc5\u8981\u6027\u7684. \u4e0d\u8a2d\u5b9a\u4e5f\u53ef\u4ee5.<\/p>\n<p>\u5728\u4f60\u7684\n<em>.bashrc<\/em> \u6a94\u6216\u74b0\u5883\u8a2d\u5b9a\u6a94\u4e2d\u52a0\u5165\u5982\u4e0b\u8a2d\u5b9a:<\/p>\n<pre><code>export USE_CCACHE=1\nexport CCACHE_DIR=&lt;path-to-your-cache-directory&gt;\n<\/code><\/pre>\n<p>\u5176\u4e2d\u7b2c\u4e8c\u884c\u70ba\u6307\u5b9a\u4f60\u7684cache\u76ee\u9304, \u82e5\u6c92\u8a2d\u5b9a, \u5247\u5167\u5b9a\u70ba~\/.ccache \u76ee\u9304.<\/p>\n<p>\u5b98\u65b9\u5efa\u8b70\u7684cache size \u70ba50G ~ 100G.\n\u7576\u4f60\u4e0b\u8f09\u4e86Android source code \u5f8c, \u8acb\u57f7\u884c\u4e0b\u5217\u6307\u4ee4\u4e86\u8a2d\u5b9acache \u5927\u5c0f<\/p>\n<pre><code>prebuilts\/misc\/linux-x86\/ccache\/ccache -M 50G\n<\/code><\/pre>\n<h2>\u8a2d\u5b9a\u8f38\u51fa\u6a94\u7684\u76ee\u9304.<\/h2>\n<p>Android \u5167\u5b9a\u5c07\u7de8\u8b6f\u597d\u7684\u6a94\u6848\u653e\u5230out\/ \u76ee\u9304\u4e0b, \u82e5\u4f60\u60f3\u653e\u7f6e\u65bc\u4e0d\u540c\u7684\u76ee\u9304, \u4f60\u53ef\u4ee5\u4f7f\u7528\u4e0b\u5217\u65b9\u5f0f\u4f86\u6307\u5b9a\u76ee\u9304:<\/p>\n<pre><code>export OUT_DIR_COMMON_BASE=&lt;path-to-your-out-directory&gt;\n<\/code><\/pre>\n<h2>\u5b89\u88ddRepo<\/h2>\n<p>Repo \u662f\u958b\u767cAndroid\u7cfb\u7d71\u4e2d\u4e00\u500b\u975e\u5e38\u6709\u7528\u7684\u7ba1\u7406\u548c\u53d6\u5f97source code\u5de5\u5177, \u4ed6\u662f\u4e00\u500b\u5f88\u5927\u7684script, \u4e26\u4e14\u5fc5\u9808\u8981\u914d\u5408git\u4f86\u4f7f\u7528.  \u56e0\u6b64\u6211\u5011\u5148\u5b89\u88ddgit<\/p>\n<pre><code>apt-get install git\n<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\u5c07Repo \u88dd\u65bc~\/bin \u76ee\u9304\u4e0b, \u4e26\u8a2d\u5b9aPATH \u4ee5\u65b9\u4fbf\u96a8\u6642\u53ef\u4ee5\u4f7f\u7528Repo.<\/p>\n<pre><code>mkdir -p ~\/bin\nPATH=PATH=~\/bin:$PATH\n<\/code><\/pre>\n<p>\u4e0b\u8f09Repo<\/p>\n<pre><code>curl https:\/\/storage.googleapis.com\/git-repo-downloads\/repo &gt; ~\/bin\/repo\nchmod a+x ~\/bin\/repo    \n<\/code><\/pre>\n<hr \/>\n<h3>\u53c3\u8003\u8cc7\u6599<\/h3>\n<ol>\n<li><a href=\"http:\/\/zh.wikipedia.org\/wiki\/Udev\">Udev wiki<\/a><\/li>\n<li><a href=\"http:\/\/blog.xuite.net\/mb1016.flying\/linux\/28257730-%E7%90%86%E8%A7%A3%E5%92%8C%E8%AA%8D%E8%AD%98udev\">\u7406\u89e3\u548c\u8a8d\u8b58udev<\/a><\/li>\n<li><a href=\"http:\/\/possiblelossofprecision.net\/?p=343\">Using udevadm to gather information about specific device<\/a><\/li>\n<li><a href=\"http:\/\/www.reactivated.net\/writing_udev_rules.html\">Writing udev rules<\/a><\/li>\n<li><a href=\"http:\/\/source.android.com\/source\/initializing.html\">Initializing a Build Environment<\/a><\/li>\n<\/ol>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[41,40,42],"class_list":["post-97","post","type-post","status-publish","format-standard","hentry","category-android","tag-android-2","tag-jdk","tag-udev"],"_links":{"self":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts\/97","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/comments?post=97"}],"version-history":[{"count":12,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts\/97\/revisions"}],"predecessor-version":[{"id":408,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts\/97\/revisions\/408"}],"wp:attachment":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/media?parent=97"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/categories?post=97"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/tags?post=97"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}