{"id":1212,"date":"2023-03-18T06:53:13","date_gmt":"2023-03-17T22:53:13","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1212"},"modified":"2023-04-29T09:41:02","modified_gmt":"2023-04-29T01:41:02","slug":"android-componentized-container-framework-atlas","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/18\/android-componentized-container-framework-atlas\/","title":{"rendered":"Android\u7ec4\u4ef6\u5316\u5bb9\u5668\u6846\u67b6Atlas"},"content":{"rendered":"<h2>Atlas\u57fa\u672c\u7b80\u4ecb<\/h2>\n<p>Atlas\u662f\u4f34\u968f\u7740\u624b\u673a\u6dd8\u5b9d\u7684\u4e0d\u65ad\u53d1\u5c55\u800c\u884d\u751f\u51fa\u6765\u7684\u4e00\u4e2a\u8fd0\u884c\u4e8eAndroid\u7cfb\u7edf\u4e0a\u7684\u4e00\u4e2a\u5bb9\u5668\u5316\u6846\u67b6\uff0c\u6211\u4eec\u4e5f\u53eb\u52a8\u6001\u7ec4\u4ef6\u5316(Dynamic Bundle)\u6846\u67b6\u3002\u5b83\u4e3b\u8981\u63d0\u4f9b\u4e86\u89e3\u8026\u5316\u3001\u7ec4\u4ef6\u5316\u3001\u52a8\u6001\u6027\u7684\u652f\u6301\u3002\u8986\u76d6\u4e86\u5de5\u7a0b\u5e08\u7684\u5de5\u7a0b\u7f16\u7801\u671f\u3001Apk\u8fd0\u884c\u671f\u4ee5\u53ca\u540e\u7eed\u8fd0\u7ef4\u671f\u7684\u5404\u79cd\u95ee\u9898\u3002<\/p>\n<p>\u4e0e\u63d2\u4ef6\u5316\u6846\u67b6\u4e0d\u540c\u7684\u662f\uff0cAtlas\u662f\u4e00\u4e2a\u7ec4\u4ef6\u6846\u67b6\uff0cAtlas\u4e0d\u662f\u4e00\u4e2a\u591a\u8fdb\u7a0b\u7684\u6846\u67b6\uff0c\u4ed6\u4e3b\u8981\u5b8c\u6210\u7684\u5c31\u662f\u5728\u8fd0\u884c\u73af\u5883\u4e2d\u6309\u9700\u5730\u53bb\u5b8c\u6210\u5404\u4e2abundle\u7684\u5b89\u88c5\uff0c\u52a0\u8f7d\u7c7b\u548c\u8d44\u6e90\u3002<\/p>\n<p><!-- more --><\/p>\n<p>\u5b98\u7f51\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/atlas.taobao.org\/\">http:\/\/atlas.taobao.org\/<\/a><br \/>\n\u6587\u6863\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/alibaba.github.io\/atlas\/\">https:\/\/alibaba.github.io\/atlas\/<\/a><br \/>\nGithub\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/alibaba\/atlas\">https:\/\/github.com\/alibaba\/atlas<\/a><\/p>\n<h3>Atlas\u5bf9app\u7684\u5212\u5206<\/h3>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u62c6\u5206<\/th>\n<th style=\"text-align: center;\">\u5b9a\u4f4d<\/th>\n<th style=\"text-align: center;\">\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">host<\/td>\n<td style=\"text-align: center;\">\u57fa\u7840\u652f\u6301<\/td>\n<td style=\"text-align: center;\">\u5305\u542b\u72ec\u7acb\u7684\u4e2d\u95f4\u4ef6\uff0c\u4ee5\u53ca\u4e00\u4e2aBase\u7684\u5de5\u7a0b\uff0c<br \/>\u91cc\u9762\u53ef\u80fd\u5305\u542b\u5e94\u7528\u7684Application\uff0c\u5e94\u7528icon\u7b49\u57fa\u7840\u6027\u5185\u5bb9<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">bundle<\/td>\n<td style=\"text-align: center;\">\u4e1a\u52a1\u5c42\u57fa\u672c\u5355\u4f4d<\/td>\n<td style=\"text-align: center;\"><strong>\u8fd0\u884c\u671f\u6309\u9700\u52a8\u6001\u52a0\u8f7d<\/strong>\u3002<br \/>bundle\u53ef\u4ee5\u8c03\u7528host\u7684\u4ee3\u7801\u548c\u8d44\u6e90\uff0c\u540c\u65f6bundle\u4e4b\u95f4\u5141\u8bb8\u5b58\u5728\u4f9d\u8d56\u5173\u7cfb<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Atlas\u80fd\u505a\u4ec0\u4e48<\/h3>\n<ul>\n<li>\u5de5\u7a0b\u6a21\u5757\u7684\u72ec\u7acb\u52a0\u8f7d\u548c\u8fd0\u884c<\/li>\n<li>\u53ca\u65f6\u4e0a\u7ebf\u65b0\u9700\u6c42\u3001\u5feb\u901f\u8fed\u4ee3<\/li>\n<li>\u4e1a\u52a1\u7070\u5ea6\u4e0e\u6280\u672f\u7070\u5ea6\u7684\u5feb\u901f\u9a8c\u8bc1<\/li>\n<li>\u52a8\u6001\u4fee\u590d\u7ebf\u4e0a\u6545\u969c<\/li>\n<li>\u6709\u95ee\u9898\u53ca\u65f6\u56de\u6eda<\/li>\n<\/ul>\n<p>\u4eceapp\u7684\u5f00\u53d1\u671f -&gt; \u8fd0\u884c\u671f -&gt; \u4e0a\u7ebf\u540e\u7684\u8fd0\u7ef4\u671f\uff0cAtlas\u63d0\u4f9b\u4e86\u4e00\u6574\u5957\u5b8c\u6574\u7684\u652f\u6301<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u5468\u671f<\/th>\n<th style=\"text-align: center;\">\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">\u5de5\u7a0b\u671f<\/td>\n<td style=\"text-align: center;\">\u5b9e\u73b0host\u3001bundle\u72ec\u7acb\u5f00\u53d1\u3001\u8c03\u8bd5\u7684\u529f\u80fd\uff0cbundle\u72ec\u7acb<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">\u8fd0\u884c\u671f<\/td>\n<td style=\"text-align: center;\">\u5b9e\u73b0\u5b8c\u6574\u7684\u7ec4\u4ef6\u751f\u547d\u5468\u671f\u7684\u6620\u5c04\uff0c\u7c7b\u9694\u79bb\u3001\u8d44\u6e90\u5171\u4eab\u7b49\u673a\u5236<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">\u8fd0\u7ef4\u671f<\/td>\n<td style=\"text-align: center;\">\u589e\u91cf\u66f4\u65b0\u4fee\u590d\u80fd\u529b\uff0c\u63d0\u4f9b\u5bf9class\u3001so\u4ee5\u53ca\u8d44\u6e90\u7684\u589e\u91cf\u66f4\u65b0\u4fee\u590d\u80fd\u529b\uff0c\u5feb\u901f\u5347\u7ea7<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Atlas\u8bde\u751f\u80cc\u666f<\/h2>\n<p>\u968f\u7740\u624b\u673a\u6dd8\u5b9d\u4e1a\u52a1\u7684\u5feb\u901f\u589e\u957f\uff0c\u534f\u4f5c\u7814\u53d1\u56e2\u961f\u7684\u4e0d\u65ad\u6269\u5927\uff0c\u6280\u672f\u4e5f\u9762\u4e34\u7740\u66f4\u591a\u6311\u6218\uff1a\u4e00\u65b9\u9762\u4ee3\u7801\u91cf\u5feb\u901f\u4e0a\u5347\u5bfc\u81f4\u65b9\u6cd5\u8fc7\u591a\uff0c\u9650\u5236\u6253\u5305\u7684\u6b63\u5e38\u8f93\u51fa\uff1b\u53e6\u4e00\u4e2a\u65b9\u9762\u5404\u4e1a\u52a1\u7ebf\u7684\u5f00\u53d1\u548c\u96c6\u6210\u90fd\u9700\u8981\u5230\u4e00\u4e2aapk\u4e0a\uff0c\u4e1a\u52a1\u95f4\u76f8\u4e92\u8026\u5408\u4e25\u91cd\uff0c\u96c6\u6210\u5f00\u53d1\u5de5\u4f5c\u6548\u7387\u4f4e\u4e0b\u3002\u8fd9\u4e2a\u5927\u80cc\u666f\u4e0b\uff0c\u6025\u9700\u8981\u505a\u4e00\u6b21\u4ece\u6784\u5efa\u3001\u96c6\u6210\u3001\u4ea4\u4ed8\u7684\u6280\u672f\u6539\u9020\uff0c\u4e8e\u662fAtlas\u4f5c\u4e3a\u624b\u6dd8\u8fd0\u884c\u7684\u5bb9\u5668\u8bde\u751f\u4e86\uff0c\u5b83\u7075\u6d3b\u7684\u89e3\u51b3\u4e86\u5404\u4e2a\u4e1a\u52a1\u5f00\u53d1\u671f\u95f4\u7684\u76f8\u4e92\u72ec\u7acb\u89e3\u8026\uff0c\u800c\u4e14\u63d0\u4f9b\u4e86\u5404\u4e2a\u6a21\u5757\u7ebf\u4e0a\u72ec\u7acb\u52a8\u6001\u80fd\u529b\u3002<\/p>\n<h2>Atlas\u529f\u80fd\u539f\u7406<\/h2>\n<p>Atlas\u7c7b\u52a0\u8f7d\u673a\u5236\uff08\u52a0\u8f7d\u987a\u5e8f\uff09: <\/p>\n<ol>\n<li>\u67e5\u627e\u81ea\u8eab\u5185\u90e8\u7684class(DelegateClassLoader)<\/li>\n<li>\u67e5\u627ebundle\u4f9d\u8d56\u7684bundle\u5185\u7684class(BundleClassLoader)<\/li>\n<li>\u67e5\u627e\u4e3bapk\u4e2d\u7684class(PathClassLoader)<\/li>\n<\/ol>\n<p><strong>Bundle<\/strong>\uff1a\u7c7b\u4f3cOSGI\u89c4\u8303\u91cc\u9762bundle\uff08\u7ec4\u4ef6\uff09\u7684\u6982\u5ff5\uff0c\u6bcf\u4e2abundle\u6709\u81ea\u5df1\u7684classloader\uff0c\u4e0e\u5176\u4ed6bundle\u76f8\u9694\u79bb\uff0c\u540c\u65f6Atlas\u6846\u67b6\u4e0bbundle\u6709\u81ea\u8eab\u7684\u8d44\u6e90\u6bb5\uff08PackageID\uff0c\u6253\u5305\u65f6AAPT\u6307\u5b9a\uff09\uff1b\u53e6\u5916\u4e0e\u539f\u6709OSGI\u6240\u5b9a\u4e49\u7684service\u683c\u5f0f\u4e0d\u540c\u4e4b\u5904\u662fAtlas\u91cc\u9762Bundle\u900f\u51fa\u6240\u6709\u5b9a\u4e49\u5728Manifest\u91cc\u9762\u7684component\uff0c\u968f\u7740service\uff0cactivity\u7684\u89e6\u53d1\u6267\u884cbundle\u7684\u5b89\u88c5\uff0c\u8fd0\u884c\u3002<\/p>\n<p><strong>awb<\/strong>\uff1a<code>Android Wireless Bundle<\/code>\u7684\u7f29\u5199\uff0c\u5b9e\u9645\u4e0a\u540cAAR\u7c7b\u4f3c\uff0c\u662f\u6700\u7ec8\u6784\u5efa\u6574\u5305\u524d\u7684\u4e2d\u95f4\u4ea7\u7269\u3002\u6bcf\u4e2aawb\u6700\u7ec8\u4f1a\u6253\u6210\u4e00\u4e2abundle\u3002awb\u4e0eaar\u7684\u552f\u4e00\u4e0d\u540c\u4e4b\u5904\u662fawb\u4e0e\u4e4b\u5bf9\u5e94\u6709\u4e2apackageId\u7684\u5b9a\u4e49\u3002<\/p>\n<p><strong>host<\/strong>\uff1a\u5bbf\u4e3b\u7684\u6982\u5ff5\uff0c\u6240\u6709\u7684bundle\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528host\u5185\u7684\u4ee3\u7801\u548c\u8d44\u6e90\uff0c\u6240\u4ee5host\u5e38\u5e38\u96c6\u5408\u4e86\u516c\u5171\u7684\u4e2d\u95f4\u4ef6\uff0cUI\u8d44\u6e90\u7b49\u3002<\/p>\n<h2>Atlas\u63a5\u5165<\/h2>\n<h3>\u5f15\u7528Atlas\u63d2\u4ef6\u53ca\u4f9d\u8d56\u4ed3\u5e93\uff0c\u4fee\u6539\u5de5\u7a0b\u7684build.gradle<\/h3>\n<p>\uff081\uff09\u6ce8\u91ca\u9ed8\u8ba4\u7684<code>gradle-plugin<\/code>\uff0c\u6dfb\u52a0<code>atlasplugin<\/code><\/p>\n<pre><code>buildscript {\n    repositories { jcenter() }\n    dependencies {\n        \/\/classpath &#039;com.android.tools.build:gradle:3.1.3&#039;\n        classpath &quot;com.taobao.android:atlasplugin:2.3.3.rc63&quot;\n    }\n}<\/code><\/pre>\n<p>\uff082\uff09gradle\u7248\u672c\u4f7f\u75283.3<\/p>\n<p>\u4fee\u6539\u6587\u4ef6\uff1a<code>gradle\\wrapper\\gradle-wrapper.properties<\/code><\/p>\n<p>\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/alibaba\/atlas\/issues\/231\">https:\/\/github.com\/alibaba\/atlas\/issues\/231<\/a><\/p>\n<p>\u6709\u4e24\u4e2a\u6982\u5ff5<code>com.android.tools.build:gradle:2.3.3<\/code>\u548c<code>gradle<\/code>\u7684\u7248\u672c\u3002\u524d\u8005\u662fgoogle\u539f\u751f\u7684android\u6253\u5305\u63d2\u4ef6\uff0c\u662f\u57fa\u4e8egradle\u8fd0\u884c\u7684\u3002Atlas\u4fee\u6539\u4e86\u539f\u751f\u7684\u6253\u5305\u63d2\u4ef6\u3002\u6240\u4ee5\u53ea\u9700\u8981\u4f9d\u8d56<code>atlasplugin<\/code>\u5373\u53ef\u3002\u76ee\u524d\u7684<code>atlasplugin<\/code>\u662f\u57fa\u4e8e<code>com.android.tools.build:gradle:2.3.3<\/code>\u6539\u7684\uff0c\u5b83\u9700\u8981\u7684<code>gradle<\/code>\u7248\u672c\u662f3.3\u3002<\/p>\n<h3>bundle\u63a5\u5165\uff0c\u4fee\u6539bundle\u7684build.gradle<\/h3>\n<pre><code>apply plugin: &#039;com.taobao.atlas&#039;\n\natlas {\n    \/\/\u58f0\u660e\u4e3aawb \u5373bundle\u5de5\u7a0b\n    bundleConfig { awbBundle true }\n}<\/code><\/pre>\n<h3>\u5bb9\u5668\u63a5\u5165\uff0c\u4fee\u6539app\u6a21\u5757\u7684build.gradle<\/h3>\n<pre><code>apply plugin: &#039;com.taobao.atlas&#039;\ndependencies {\n    \/\/\u6838\u5fc3sdk\n    compile(&#039;com.taobao.android:atlas_core:5.0.0@aar&#039;) {\n        transitive = true\n    }\n    \/\/\u5982\u679c\u4e0d\u9700\u8981\u7528\u5230atlas\u7684\u52a8\u6001\u90e8\u7f72\u529f\u80fd\uff0c\u4e0d\u9700\u8981\u4f9d\u8d56atlasupdate\n    compile &#039;com.taobao.android:atlasupdate:1.0.8@aar&#039;\n\n    \/\/\u8bbe\u7f6ebundle\u4f9d\u8d56\n    bundleCompile project(&#039;:firstbundle&#039;)\n}\natlas {\n   atlasEnabled true\n   \/\/...\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Atlas\u57fa\u672c\u7b80\u4ecb Atlas\u662f\u4f34\u968f\u7740\u624b\u673a\u6dd8\u5b9d\u7684\u4e0d\u65ad\u53d1\u5c55\u800c\u884d\u751f\u51fa\u6765\u7684\u4e00\u4e2a\u8fd0\u884c\u4e8eAndroid\u7cfb\u7edf\u4e0a\u7684\u4e00\u4e2a\u5bb9\u5668\u5316 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[275],"tags":[],"class_list":["post-1212","post","type-post","status-publish","format-standard","hentry","category-atlas"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1212"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1212\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}