{"id":1213,"date":"2023-03-18T06:55:00","date_gmt":"2023-03-17T22:55:00","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1213"},"modified":"2023-04-29T09:40:50","modified_gmt":"2023-04-29T01:40:50","slug":"atlas-demo-explain","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/18\/atlas-demo-explain\/","title":{"rendered":"Atlas Demo\u89e3\u6790"},"content":{"rendered":"<p>Github\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/alibaba\/atlas\">https:\/\/github.com\/alibaba\/atlas<\/a><\/p>\n<h2>Demo\u4e2d\u7684Module\u7b80\u4ecb<\/h2>\n<p><!-- more --><\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">Module<\/th>\n<th style=\"text-align: left;\">\u542b\u4e49<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\">app<\/td>\n<td style=\"text-align: left;\">Host Module<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">activitygroupcompat<\/td>\n<td style=\"text-align: left;\">Demo\u4e2d\u7684\u5de5\u5177\u7c7b<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">databindbundle<\/td>\n<td style=\"text-align: left;\">\u4f7f\u7528Google Bind\u6846\u67b6Demo<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">firstbundle<\/td>\n<td style=\"text-align: left;\">\u7b2c\u4e00\u4e2a\u4e1a\u52a1bundle\u4ee3\u7801<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">lottie<\/td>\n<td style=\"text-align: left;\">splashScreen\u4f9d\u8d56\u7684\u4ee3\u7801<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">middlewarelibrary<\/td>\n<td style=\"text-align: left;\">\u4e2d\u95f4\u952elibrary\uff0c\u4f1a\u6253\u5305\u5230\u4e3bdex\u4e2d<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">publicbundle<\/td>\n<td style=\"text-align: left;\">\u5171bundle\u4ee3\u7801\uff0c\u4e0d\u4f1a\u6253\u5165\u4e3bdex\u4e2d<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">remotebundle<\/td>\n<td style=\"text-align: left;\">\u8fdc\u7a0bbundle\uff0c\u5728\u53d1\u5e03\u65f6\u4e0d\u4f1a\u7f16\u8bd1\u8fdbapk\uff0c\u800c\u5728\u5ba2\u6237\u7aef\u4f7f\u7528\u65f6\uff0c\u5148\u4e0b\u8f7d\u540e\u52a0\u8f7d<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">secondbundle<\/td>\n<td style=\"text-align: left;\">\u7b2c\u4e8c\u4e2a\u4e1a\u52a1bundle\u4ee3\u7801<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">secondbundlelibrary<\/td>\n<td style=\"text-align: left;\">\u7b2c\u4e8c\u4e2a\u4e1a\u52a1\u5355\u72ec\u4f9d\u8d56\u7684\u4ee3\u7801<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">splashScreen<\/td>\n<td style=\"text-align: left;\">\u95ea\u5c4f\u4ee3\u7801<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u5728Project\u7684build.gradle\u6587\u4ef6\u4e2d\u5f15\u5165<\/h2>\n<pre><code>buildscript {\n\n    repositories {\n        mavenLocal()  \/\/\u5982\u679c\u6709Github\u5730\u5740\u5c31\u6362\u6210Github\u4e0a\u7684\u5730\u5740\n        jcenter()\n        maven {\n            \/\/url &quot;http:\/\/mvnrepo.alibaba-inc.com\/mvn\/repository&quot;\n            url &quot;http:\/\/maven.aliyun.com\/nexus\/content\/groups\/public&quot;\n        }\n    }\n\n    dependencies {\n        \/\/classpath &#039;com.android.tools.build:gradle:3.1.3&#039;  \/\/\u6ce8\u91ca\u81ea\u5e26\u63d2\u4ef6\n        classpath &quot;com.taobao.android:atlasplugin:2.3.3.rc63&quot;\n        classpath &#039;org.greenrobot:greendao-gradle-plugin:3.2.2&#039;\n\n        \/\/ NOTE: Do not place your application dependencies here; they belong\n        \/\/ in the individual module build.gradle files\n    }\n\n    configurations.all {\n        resolutionStrategy.cacheDynamicVersionsFor 0, &#039;seconds&#039;\n        resolutionStrategy.cacheChangingModulesFor 0, &#039;seconds&#039;\n    }\n}\n\next {\n    lib_atlas_core = &quot;com.taobao.android:atlas_core:5.1.0.0@aar&quot;\n    lib_atlas_update = &quot;com.taobao.android:atlasupdate:1.1.4.21@aar&quot;\n}\n\nallprojects {\n    repositories {\n        jcenter()\n        maven {\n            \/\/url &quot;http:\/\/mvnrepo.alibaba-inc.com\/mvn\/repository&quot;\n            url &quot;http:\/\/maven.aliyun.com\/nexus\/content\/groups\/public&quot;\n        }\n        \/\/maven { url &#039;https:\/\/jitpack.io&#039; }\n    }\n}\n\ntask clean(type: Delete) {\n    delete rootProject.buildDir\n}<\/code><\/pre>\n<h2>\u5728app\u7684build.gradle\u6587\u4ef6\u4e2d\u5f15\u5165<\/h2>\n<ul>\n<li>\u5e94\u7528plugin<\/li>\n<\/ul>\n<pre><code>apply plugin: &#039;com.taobao.atlas&#039;  \/\/atlas\u63d2\u4ef6<\/code><\/pre>\n<ul>\n<li>\u6dfb\u52a0\u8fd0\u884c\u5e93\u4f9d\u8d56<\/li>\n<\/ul>\n<pre><code>compile(&#039;com.taobao.android:atlas_core:5.0.7.30@aar&#039;) {  \/\/atlas\u6838\u5fc3\u5e93\n    transitive = true\n}\ncompile &#039;com.taobao.android:atlasupdate:1.1.4.10@aar&#039;  \/\/atlas\u6846\u67b6\u66f4\u65b0\u529f\u80fd\u76f8\u5173\u7684\u5e93<\/code><\/pre>\n<ul>\n<li>\u5f00\u542fatlas\u5bb9\u5668\u529f\u80fd<\/li>\n<\/ul>\n<pre><code>atlas {\n    atlasEnabled true \/\/atlas\u5f00\u5173\uff0c\u4e00\u822c\u63a5\u5165\u540e\u90fd\u6253\u5f00\n    tBuildConfig {\/\/\n        \/\/\u81ea\u542f\u52a8bundle\u914d\u7f6e\uff0c\u8ddf\u968f\u5e94\u7528\u542f\u52a8\u800c\u52a0\u8f7d\uff0c\u666e\u901abundle\u662f\u968f\u8fd0\u884c\u800c\u52a0\u8f7d\n        autoStartBundles = [&#039;com.taobao.firstbundle&#039;]\n        \/\/\u6253\u5305\u65f6\uff0c\u4e0d\u6253\u5305\u5230\u5305\u4e2d\u7684bundle\uff0c\u4e5f\u5c31\u662f\u8fdc\u7a0bbundle\n        outOfApkBundles = [&#039;remotebundle&#039;]\n        \/\/\u662f\u6307\u5728atlas\u6846\u67b6\u542f\u52a8\u524d\u9700\u8981\u542f\u52a8\u7684\u529f\u80fd\uff08\u5982\uff1a\u5d29\u6e83\u4fe1\u606f\u7edf\u8ba1\u7b49\uff09\uff0c\u5e76\u4e14\u5728atlas\u542f\u52a8\u524d\u7684\u529f\u80fd\u662f\u4e0d\u80fd\u88ab\u52a8\u6001\u90e8\u7f72\u7684\uff01\n        preLaunch = &#039;com.taobao.demo.DemoPreLaunch&#039;\n        classInject false\n        dataBindingBundles = [&#039;com.taobao.databindbundle&#039;]\n    }\n\n    manifestOptions {\n        addAtlasProxyComponents true\n    }\n\n    patchConfigs {\n        debug {\n            createTPatch true\n        }\n    }\n\n    buildTypes {\n        debug {\n            if (apVersion) {\n                \/\/\u57fa\u7ebf\u7248\u672c\u5750\u6807\n                baseApDependency &quot;com.taobao.android.atlasdemo:AP-debug:${apVersion}@ap&quot;\n                patchConfig patchConfigs.debug\n            }\n        }\n    }\n}<\/code><\/pre>\n<ul>\n<li>\u4f9d\u8d56\u4e2d\u6dfb\u52a0\u5176\u4ed6bundle<\/li>\n<\/ul>\n<pre><code>\/\/\u8fd9\u79cd\u4f9d\u8d56\u4f1a\u5f53\u6210bundle\uff0c\u4f1a\u6253\u5305\u5230apk\u7684lib\/armeabi\u76ee\u5f55\u4e0b\uff0c\u4e5f\u5c31\u662f\u6211\u4eec\u7684\u63d2\u4ef6\nbundleCompile project(&#039;:firstbundle&#039;)\n\/\/compile &#039;com.taobao.android.atlasdemo:firstbudle:1.0.0@awb&#039;\nbundleCompile project(&#039;:secondbundle&#039;)\nbundleCompile project(&#039;:remotebundle&#039;)\nbundleCompile project(&#039;:publicbundle&#039;)\nbundleCompile project(&#039;:databindbundle&#039;)<\/code><\/pre>\n<h2>\u521b\u5efa\u7b2c\u4e8c\u4e2amodule\uff0c\u5373FirstBundle<\/h2>\n<ul>\n<li>\u914d\u7f6ebuild.gradle<\/li>\n<\/ul>\n<pre><code>apply plugin: &#039;com.android.library&#039;  \/\/(\u6ce8\u610f\u8fd9\u91cc\u662flibrary\u4e0d\u662fapplication \u5e76\u4e14\u5728Android\u4e2d\u6ca1\u6709applicationId\u8bbe\u7f6e)\napply plugin: &#039;com.taobao.atlas&#039; \/\/atlas\u63d2\u4ef6\n\natlas {\n    bundleConfig {\n        \/\/\u6807\u660e\u8fd9\u662f\u4e00\u4e2abundle\u5de5\u7a0b\uff0c\u4ea7\u7269\u4f1a\u751f\u6210awb\u6587\u4ef6\uff0c\u4e5f\u5c31\u662f\u6700\u540e\u6253\u5165\u5305\u4e2d\u7684so\u6587\u4ef6\n        awbBundle true\n    }\n    buildTypes {\n        debug {\n            \/\/\u57fa\u7ebf\u7248\u672c\u4f4d\u7f6e\n            baseApFile project.rootProject.file(&#039;app\/build\/outputs\/apk\/app-debug.ap&#039;)\n        }\n    }\n}\n\n\/\/\u5982\u679c\u9700\u8981\u53d1\u5e03\u7248\u672c\u4f9d\u8d56\n\/*\ngroup = &#039;com.taobao.android.atlasdemo&#039;\nversion = &quot;1.0.0&quot;;\n\napply plugin: &#039;maven&#039;\napply plugin: &#039;maven-publish&#039;\n\npublishing {\n    repositories {\n        mavenLocal()\n    }\n}\n\npublishing {\n    publications {\n        maven(MavenPublication) {\n            artifact &quot;${project.buildDir}\/outputs\/awb\/${project.name}-debug.awb&quot;\n            artifactId &quot;firstbundle&quot;\n        }\n    }\n}\n*\/<\/code><\/pre>\n<ul>\n<li>\u4f9d\u8d56\u5199\u6cd5<\/li>\n<\/ul>\n<pre><code>\/\/\u4f9d\u8d56\u7f16\u8bd1\uff0c\u4f46\u662f\u4e0d\u4f1a\u6253\u5165\u5305\u4e2d\nprovidedCompile project(&#039;:middlewarelibrary&#039;)\nprovidedCompile project(&#039;:publicbundle&#039;)<\/code><\/pre>\n<h2>\u4e86\u89e3\u5b98\u65b9Demo app module \u5728..\/gradlew assembleDebug\u540e\u751f\u6210\u6587\u4ef6\u610f\u4e49<\/h2>\n<p>1\u3001\u8fdb\u5165app\u6587\u4ef6\u76ee\u5f55(\u7528as\u81ea\u5e26terminal\uff1acd app)<br \/>\n2\u3001\u8c03\u7528\u6784\u5efa\u9879\u76eegradle\u547d\u4ee4\uff1a..\/gradlew assembleDebug(\u6216\u70b9\u51fbas\u53f3\u4fa7gradle\u4e2dmodule\u7684assembleDebug\u751f\u6210)<br \/>\n3\u3001\u7136\u540e\u53ef\u4ee5\u8fdb\u5165app-&gt;build-&gt;outputs-&gt;apk\u6587\u4ef6\u76ee\u5f55\u4e0b\u53ef\u4ee5\u770b\u5230\u4e24\u4e2a\u6587\u4ef6\uff1a<br \/>\n\u4e00\u4e2a\u662f.apk debug\u5bf9\u5e94\u7684\u5b89\u88c5\u5305\u6587\u4ef6<br \/>\n\u4e00\u4e2a\u662f.ap \u88ab\u79f0\u4e3a\u57fa\u7ebf\u7248\u672cap\uff0c\u5c06\u6765\u5728\u8fd9\u4e2a\u7248\u672c\u4e0a\uff0c\u8fdb\u884c\u52a8\u6001\u90e8\u7f72\u65f6\u9700\u8981\u7684\uff08\u52a8\u6001\u90e8\u7f72\u65f6\uff0c\u4f1a\u6839\u636e\u8fd9\u4e2aap\u751f\u6210\u5dee\u91cf\u7684\u5185\u5bb9\uff09<br \/>\n4\u3001logs\u6587\u4ef6\u5939\uff08\u4e0d\u5fc5\u5173\u6ce8\uff09<br \/>\n5\u3001remote-bundles-debug\u6587\u4ef6\u5939\uff1a\u5b58\u653e\u6240\u6709\u8fdc\u7a0bbundle\u6587\u4ef6<br \/>\n6\u3001apk-files.txt\u6587\u4ef6\uff1a\u6240\u6709\u6587\u4ef6\u540d\u79f0\u3001\u8def\u5f84\u8fd8\u6709md5\u503c\uff0c\u662f\u4e3a\u4e86\u4ee5\u540e\u7528\u52a8\u6001\u90e8\u7f72\u65f6\u8fdb\u884c\u6bd4\u8f83\u6587\u4ef6\u662f\u5426\u53d8\u5316\u7684\u4f9d\u636e\u3002<br \/>\n7\u3001atlasConfig.json\u6587\u4ef6\uff1a\u8bb0\u5f55\u6240\u6709atlas\u6240\u6709\u914d\u7f6e\u9879\u7684\u503c\uff0c\u91cc\u9762\u5305\u542b\u4e86\u4e00\u4e9b\u9ed8\u8ba4\u503c\u3002<br \/>\n8\u3001atlasFrameworkProperties.json\uff1a\u4e3b\u8981\u8bb0\u5f55\u4e86bundle\u7684\u4fe1\u606f\uff08bundle\u7684\u540d\u79f0\u3001\u4f9d\u8d56\u3001\u7248\u672c\u4fe1\u606f\uff09<br \/>\n9\u3001build.txt\uff1a\u8bb0\u5f55gradle\u7248\u672c\uff0catlas\u7248\u672c\u7b49\u4fe1\u606f<br \/>\n10\u3001dependencies\u3001dependencyTree-debug\u4e24\u4e2a\u6587\u4ef6\uff1a\u8bb0\u5f55\u4e86\u9879\u76ee\u4e2d\u6240\u6709\u4f9d\u8d56<br \/>\n11\u3001packageIdFile.properties\u6587\u4ef6\uff1a\u8bb0\u5f55\u4e86\u6bcf\u4e2abundle\u548c\u5b83\u4eec\u7684\u8d44\u6e90\u5206\u6bb5\uff08\u4e3a\u4e86\u907f\u514dbundle\u8d44\u6e90\u4e0eapk\u8d44\u6e90\u51b2\u7a81\u7684\u95ee\u9898\uff09<br \/>\n12\u3001pluginDependencies.txt\uff1a\u63d2\u4ef6\u7684\u4f9d\u8d56\uff08\u6682\u65f6\u4e0d\u7528\u5173\u6ce8\uff09<br \/>\n13\u3001version.properties\u6587\u4ef6\uff1a\u8bb0\u5f55\u4e86\u6240\u6709\u4f9d\u8d56\u7684\u7248\u672c\u53f7\u548c\u53ca\u5176\u683c\u5f0f<\/p>\n<h2>\u53d1\u5e03\u57fa\u7ebf\u7248\u672c<\/h2>\n<ol>\n<li>\u5728app\u76ee\u5f55\u4e0b\u6267\u884c\u53d1\u5e03\u547d\u4ee4\uff1a<code>..\/gradlew publish<\/code><\/li>\n<li>\u6253\u5f00\u76ee\u5f55\uff1a<code>open ~\/.m2\/repository\/<\/code><\/li>\n<li>\u53ef\u4ee5\u5728\u76ee\u5f55\u4e2d\u770b\u5230\uff1a<code>~\/.m2\/repository\/com\/taobao\/android\/atlasdemo\/AP-debug\/1.0.0\/AP-debug-1.0.0.ap<\/code> \u6587\u4ef6<\/li>\n<\/ol>\n<p>\u90a3\u600e\u4e48\u8bbe\u7f6e\u7248\u672c\u53f7\u5462\uff1f\u6211\u4eec\u5728app\u7684build.gradle\u4e2d\u53ef\u4ee5\u770b\u5230group\u3001version\u3001artifactId\u8fd9\u4e09\u4e2a\u5b57\u6bb5\uff0c\u6807\u793a\u4e86\u53d1\u5e03\u7684\u8def\u5f84\u3001\u540d\u79f0\u3001\u7248\u672c<\/p>\n<pre><code>group = &#039;com.taobao.android.atlasdemo&#039;\nversion = getEnvValue(&quot;versionName&quot;, &quot;1.0.0&quot;);\n\npublishing {\n    publications {\n         maven(MavenPublication) {\n            artifact &quot;${project.buildDir}\/outputs\/apk\/${project.name}-debug.ap&quot;\n            artifactId &quot;AP-debug&quot;\n        }\n    }\n}<\/code><\/pre>\n<h2>\u6784\u5efaTpatch<\/h2>\n<p>\u5177\u4f53\u53ef\u4ee5\u770bdemo\u4e2d\u7684Tpatch.txt\u6587\u4ef6\u6709\u8be6\u7ec6\u8bf4\u660e\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre><code>1\u3001 app\u7684build.gradle\u7684\u8bed\u53e5&quot;version = getEnvValue(&quot;versionName&quot;, &quot;1.0.0&quot;);&quot;\u4e2d\u4fee\u6539\u60f3\u8981\u751f\u6210\u7684app\u7684versionName\uff08\u9ed8\u8ba4\u4e3a1.0.0\uff09\n\n    app\u76ee\u5f55\u4e0b\u6267\u884c..\/gradlew clean assembleDebug \u751f\u6210apk  (windows \u73af\u5883\u7684\u547d\u4ee4\u4e3a ..\\gradlew.bat clean assembleDebug  \u4ee5\u4e0b\u7c7b\u540c)\n\n2\u3001 app\u76ee\u5f55\u4e0b\u6267\u884c..\/gradlew publish \u5c06\u8ddfapk\u540c\u76ee\u5f55\u7684ap\u6587\u4ef6\u53d1\u5e03\u5230\u4ed3\u5e93,\u6b64\u65f6ap\u7684\u7248\u672c\u662f1.0.0\n\n3\u3001 \u624b\u673a\u4e0a\u5b89\u88c5\u751f\u6210\u7684apk\uff0c\u540c\u65f6\u8fdb\u5230\u52a8\u6001\u90e8\u7f72\u754c\u9762\uff08\u4fa7\u8fb9\u680f\u91cc\u9762\u5212\u5f00\u70b9\u51fb\u8fdb\u5165),\u4e14\u624b\u673a\u8fde\u63a5\u7535\u8111adb\uff08\u786e\u4fddadb devices\u53ef\u89c1\uff09\n\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/^^^^^^^\u51c6\u5907\u5de5\u4f5c^^^^^^^^^^\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n4\u3001 \u8fdb\u884c\u4e00\u4e9b\u60f3\u8981\u7684\u4fee\u6539\uff08\u4e0d\u652f\u6301manifest\u7684\u4fee\u6539\uff09\uff0c\u6539\u52a8\u5b8c\u6210\u540e\u9700\u8981\u5347\u7ea7\u4e00\u4e0b\u5bf9\u5e94bundle\/lib\u7684\u7248\u672c\u53f7\n\n5\u3001 app\u5de5\u7a0b\u76ee\u5f55\u4e0b\u6267\u884c..\/gradlew clean assembleDebug -DapVersion=apVersion -DversionName=newVersion,\n    \u5176\u4e2dapVersion\u4e3a\u4e4b\u524d\u6253\u7684\u5b8c\u6574apk\u7684\u7248\u672c\uff0cnewVersion\u4e3a\u6b64\u6b21\u52a8\u6001\u90e8\u7f72\u8981\u751f\u6210\u7684\u65b0\u7684\u7248\u672c\u53f7\uff0c\n    \u4f8b\u5982\u547d\u4ee4 ..\/gradlew clean assembleDebug -DapVersion=1.0.0 -DversionName=1.0.1\n\n6\u3001 \u68c0\u67e5build\/output\/tpatch-debug \u76ee\u5f55\u4e0b\u6587\u4ef6\u662f\u5426\u751f\u6210\uff0c\u7136\u540e\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4(\u4ee5\u4e0b\u4e3amac\u4e0b\u7684\u547d\u4ee4\uff0cwindows\u8bf7\u4fee\u6539\u6587\u4ef6\u5206\u9694\u7b26)\n    (\u6839\u636e\u4f60\u624b\u673a\u7684\u5f53\u524d\u7248\u672c\u63a8\u9001\u5bf9\u5e94\u7248\u672c\u7684update-**.json,\u548c\u5bf9\u5e94\u7684tpatch\u6587\u4ef6)\n    \u4f8b\u5982\uff0c\u8fd9\u65f6\u662f\u7b2c1\u6b21\u90e8\u7f72\uff0cversionName\u662f1.0.0\uff0c\u6240\u4ee5\u547d\u4ee4\u884c\u662f:\n    adb push build\/outputs\/tpatch-debug\/update-1.0.0.json \/sdcard\/Android\/data\/com.taobao.demo\/cache\/update-1.0.0.json\n    adb push build\/outputs\/tpatch-debug\/patch-1.0.1@1.0.0.tpatch \/sdcard\/Android\/data\/com.taobao.demo\/cache\/patch-1.0.1@1.0.0.tpatch\n\n7\u3001 \u70b9\u51fb\u52a8\u6001\u90e8\u7f72\u9875\u9762\u7ea2\u8272\u6309\u94ae\u6267\u884c\u52a8\u6001\u90e8\u7f72,\u751f\u6548\u540eapp\u7684versionName\u53d8\u4e3a\u4e861.0.1\n\n8\u3001 \u540e\u7eed\u7ee7\u7eed\u505a\u60f3\u8981\u7684\u4fee\u6539\uff0c\u6211\u4eec\u8981\u53d8\u62101.0.2 (\u67d0\u4e2abundle\u505a\u52a8\u6001\u90e8\u7f72\u7684\u65f6\u5019\u8bf7\u66f4\u65b0\u7248\u672c\u53f7(versionName)\uff0c\u56e0\u4e3a\u5dee\u91cf\u4f1a\u57fa\u4e8e\u7248\u672c\u53f7\u5bf9\u6bd4)\n    ..\/gradlew clean assembleDebug -DapVersion=1.0.0 -DversionName=1.0.2   \u8fd9\u65f6\u5019\u4f1a\u751f\u6210\u4e24\u4e2a  patch-1.0.2@1.0.0.tpatch  patch-1.0.2@1.0.1.tpatch\n\n    \u6839\u636e\u4f60\u76ee\u524d\u7684app\u7248\u672c\uff0c\u91cd\u590d6\u6b65\u9aa4\uff0c\u63a8\u9001\u5bf9\u5e94\u7248\u672c\u7684update-**.json,\u548c\u5bf9\u5e94\u7684tpatch\u6587\u4ef6\u3002\n\n    \u4f8b\u5982: \u5982\u679c\u8fd9\u65f6\u4f60app\u7684versionName\u662f1.0.1\n\u4f60\u7684\u547d\u4ee4\u884c\u5c31\u662f:\n    adb push build\/outputs\/tpatch-debug\/update-1.0.1.json \/sdcard\/Android\/data\/com.taobao.demo\/cache\/update-1.0.1.json\n    adb push build\/outputs\/tpatch-debug\/patch-1.0.2@1.0.1.tpatch \/sdcard\/Android\/data\/com.taobao.demo\/cache\/patch-1.0.2@1.0.1.tpatch\n\n\u5982\u679c\u8fd9\u65f6\u4f60app\u7684versionName\u662f1.0.0,\u4e5f\u5c31\u662f\u8fd8\u662f\u57fa\u7ebf\u7248\u672c\n\u4f60\u7684\u547d\u4ee4\u884c\u5c31\u662f:\n    adb push build\/outputs\/tpatch-debug\/update-1.0.0.json \/sdcard\/Android\/data\/com.taobao.demo\/cache\/update-1.0.0.json\n    adb push build\/outputs\/tpatch-debug\/patch-1.0.2@1.0.0.tpatch \/sdcard\/Android\/data\/com.taobao.demo\/cache\/patch-1.0.2@1.0.0.tpatch\n\n9\u3001 \u540e\u7eed\u7ee7\u7eed\u505a\u60f3\u8981\u7684\u4fee\u6539\uff0c\u6211\u4eec\u8981\u53d8\u62101.0.3 (\u67d0\u4e2abundle\u505a\u52a8\u6001\u90e8\u7f72\u7684\u65f6\u5019\u8bf7\u66f4\u65b0\u7248\u672c\u53f7\uff0c\u56e0\u4e3a\u5dee\u91cf\u4f1a\u57fa\u4e8e\u7248\u672c\u53f7\u5bf9\u6bd4)\n    ..\/gradlew clean assembleDebug -DapVersion=1.0.0 -DversionName=1.0.3   \u8fd9\u65f6\u5019\u4f1a\u751f\u6210\u4e09\u4e2a  patch-1.0.3@1.0.2.tpatch  patch-1.0.3@1.0.1.tpatch  patch-1.0.3@1.0.0.tpatch\n\n    \u6839\u636e\u4f60\u76ee\u524d\u7684app\u7248\u672c\uff0c\u91cd\u590d6\u6b65\u9aa4\uff0c\u63a8\u9001\u5bf9\u5e94\u7248\u672c\u7684update-**.json,\u548c\u5bf9\u5e94\u7684tpatch\u6587\u4ef6\u3002\n\n10\u3001 \u5982\u679c\u505a\u4e86\u591a\u6b21\u52a8\u6001\u90e8\u7f72\u540e\uff0c\u9700\u8981\u4ece\u5934\u5f00\u59cb\u6d4b\u8bd5\uff0c\u8bf7\u5148\u6e05\u9664AtlasDemo\u6839\u76ee\u5f55\u4e0b\u7684hisTpatch\u6587\u4ef6\u5939\u3002<\/code><\/pre>\n<h2>\u5e38\u7528\u547d\u4ee4<\/h2>\n<p>\u90fd\u9700\u8981\u5230\u5bf9\u5e94\u5305\u4e0b<\/p>\n<p>\u6784\u5efadebug\u547d\u4ee4\uff1a<code>..\/gradlew assembleDebug<\/code><br \/>\n\u53d1\u5e03\u57fa\u7ebf\u7248\u672c\u547d\u4ee4\uff1a<code>..\/gradlew publish<\/code><br \/>\n\u5355\u6a21\u5757\u90e8\u7f72\u547d\u4ee4\uff1a<code>..\/gradlew assemblePatchDebug<\/code><\/p>\n<h2>\u4e3bAPK\u6784\u5efa\u6b65\u9aa4<\/h2>\n<p>Atlas Demo\u4e2d\u5c06\u4e3b\u5ba2\u6237\u7aef\u4ee3\u7801\u548c\u6240\u6709bundle\u90fd\u653e\u5728\u4e86\u4e00\u4e2a\u5de5\u7a0b\u4e0b\u9762\uff0c\u8fd9\u4e5f\u7b26\u5408gradle\u5de5\u7a0b\u7684\u6807\u51c6\u6846\u67b6\u683c\u5f0f\u3002<\/p>\n<p>\u5404\u4e2a\u4e1a\u52a1bundle\u53ef\u4ee5\u6839\u636e\u4e1a\u52a1\u9700\u6c42\u4fee\u6539\u66f4\u65b0\u5404\u81eabundle\u7684\u4ee3\u7801\u3002\u7136\u540e\u518d\u901a\u8fc7\u4fee\u6539app\/build.gradle\u4e2d\u7684<code>version = getEnvValue(&quot;versionName&quot;, &quot;1.0.0&quot;);<\/code>\u6765\u4fee\u6539\u7248\u672c\u53f7\uff0c\u7248\u672c\u53f7\u9ed8\u8ba4\u4e3a1.0.0\u3002<\/p>\n<p>\u7136\u540e\u518d\u5728app\u76ee\u5f55\u4e0b\u9762\u6267\u884c<code>..\/gradlew clean assembleDebug publish<\/code>\u547d\u4ee4\u4ece\u800c\u8fdb\u884cAPK\u6253\u5305\uff0c\u751f\u6210\u7684APK\u6587\u4ef6\u76ee\u5f55\u662f<code>app\/build\/outputs\/apk\/app-debug.apk<\/code>\uff0c\u4e0a\u8ff0\u547d\u4ee4\u4e5f\u4f1a\u5c06\u8be5\u76ee\u5f55\u4e0b\u7684ap\u6587\u4ef6\u53d1\u5e03\u5230\u4ed3\u5e93\u4ee5\u4fbf\u4e8e\u540e\u7eed\u751f\u6210patch\u3002<br \/>\n\u5982\u679c\u6709\u624b\u673a\u8fde\u63a5\u5728pc\u4e0a\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528adb install\u5b89\u88c5\u4e0a\u8ff0APK\uff0c\u5728app\u76ee\u5f55\u4e0b\u6267\u884c<code>adb install app\/build\/outputs\/apk\/app-debug.apk<\/code>\u3002<\/p>\n<h2>\u5982\u4f55\u5728\u7528\u6237\u65e0\u611f\u77e5\u7684\u60c5\u51b5\u4e0b\uff0c\u5b9e\u73b0\u6240\u6709\u4e1a\u52a1\u6a21\u5757\u7684\u72ec\u7acb\u52a8\u6001\u66f4\u65b0<\/h2>\n<h3>\u52a8\u6001\u90e8\u7f72\uff08patch\uff09\u6784\u5efa\u6b65\u9aa4<\/h3>\n<ol>\n<li>\u5404\u4e2a\u4e1a\u52a1bundle\u53ef\u4ee5\u6839\u636e\u4e1a\u52a1\u9700\u6c42\u4fee\u6539\u66f4\u65b0\u5404\u81eabundle\u7684\u4ee3\u7801\u3002<\/li>\n<li>app\u5de5\u7a0b\u76ee\u5f55\u4e0b\u6267\u884c<code>..\/gradlew clean assembleDebug -DapVersion=apVersion -DversionName=newVersion<\/code>, \u5176\u4e2dapVersion\u4e3a\u4e4b\u524d\u6253\u5305\u7684\u5b8c\u6574APK\u7684\u7248\u672c\uff0cnewVersion\u4e3a\u6b64\u6b21\u52a8\u6001\u90e8\u7f72\u8981\u751f\u6210\u7684\u65b0\u7684\u7248\u672c\u53f7\u3002 \u8fd9\u91cc\u4e3e\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u4f8b\u5982\u201c\u4e3bAPK\u6784\u5efa\u201d\u6b65\u9aa4\u7684APK\u7248\u672c\u662f1.0.0\uff0c\u6211\u4eec\u7b80\u5355\u66f4\u65b0firstbundle\u7684\u4e1a\u52a1\u4ee3\u7801\u6216\u8d44\u6e90\uff0c\u7136\u540e\u6267\u884c<code>..\/gradlew clean assembleDebug -DapVersion=1.0.0 -DversionName=1.0.1<\/code>\u3002<\/li>\n<li>\u68c0\u67e5build\/output\/tpatch-debug \u76ee\u5f55\u4e0b\u6587\u4ef6\u662f\u5426\u751f\u6210\uff0c\u5c06\u8fdc\u7a0bpatch\u4e0b\u8f7d\u5230\u4f60\u7684\u8bbe\u5907\u4e0a\uff0c\u8fd9\u91cc\u6f14\u793a\u76f4\u63a5\u5728PC\u4e0a\u6267\u884cadb\u547d\u4ee4\uff1a<code>adb push build\/outputs\/tpatch-debug\/update.json \/sdcard\/Android\/data\/com.taobao.demo\/cache\/update.json<\/code> <code>adb push build\/outputs\/tpatch-debug\/patch-*.tpatch \/sdcard\/Android\/data\/com.taobao.demo\/cache<\/code><\/li>\n<li>\u6253\u5f00Demo\u4fa7\u8fb9\u680f\uff0c\u70b9\u51fb\u201c\u52a8\u6001\u90e8\u7f72\u6a21\u62df\u201d\uff0c\u9875\u9762\u7ea2\u8272\u6309\u94ae\u6267\u884c\u52a8\u6001\u90e8\u7f72\uff0c\u7b49\u5f85\u51e0\u79d2\u949f\u4e4b\u540eAPP\u4f1a\u5173\u95ed\u6b64\u65f6\u8bf4\u660e\u52a8\u6001\u90e8\u7f72\u5df2\u7ecf\u6210\u529f\uff0c\u91cd\u542fAPP\u540e\u5c31\u4f1a\u53d1\u73b0\u81ea\u5df1\u6539\u52a8\u7684\u4ee3\u7801\u5df2\u7ecf\u66f4\u65b0\u6210\u529f\u3002<\/li>\n<\/ol>\n<p>\u611f\u5174\u8da3\u7684\u540c\u5b66\u53ef\u4ee5\u7814\u7a76\u4e0bupdate.json\u548ctpatch\u6587\u4ef6<\/p>\n<p>\u52a8\u6001\u90e8\u7f72\u7684\u4e3b\u8981\u4f18\u52bf\uff1a\u6446\u8131\u7248\u672c\u8fed\u4ee3\u5468\u671f\u9650\u5236\uff0c\u65b0\u589e\u9700\u6c42\u7075\u6d3b\u53d1\u5e03\uff1b\u964d\u4f4e\u7248\u672c\u9891\u7e41\u53d1\u5e03\u7ed9\u7528\u6237\u5e26\u6765\u56f0\u6270\uff1b\u53d1\u73b0\u95ee\u9898\u53ca\u65f6\u56de\u6eda\uff1b\u77ed\u65f6\u95f4\u5185\u66f4\u9ad8\u7684\u8986\u76d6\u7387\u3002<\/p>\n<h3>\u8fdc\u7a0bbundle\u6784\u5efa\u6b65\u9aa4<\/h3>\n<p>\u5982\u679c\u5728APK\u53d1\u5e03\u65f6\uff0c\u4e0d\u60f3\u628a\u67d0\u4e2abundle\u7f16\u8bd1\u8fdbAPK\uff0c\u800c\u662f\u5728\u5ba2\u6237\u7aef\u4f7f\u7528\u65f6\u4e0b\u8f7d\u540e\u52a0\u8f7d\uff0c\u8be5\u600e\u4e48\u529e\uff1f<\/p>\n<ol>\n<li>\u6dfb\u52a0\u8fdc\u7a0bbundle\u7684\u4f9d\u8d56\uff0c\u53c2\u8003 app\/build.gradle\u4e0b\u7684 <code>bundleCompile project(&#039;:remotebundle&#039;)<\/code><\/li>\n<li>\u58f0\u660e\u8fdc\u7a0bbundle\u5217\u8868\uff0c\u53c2\u8003 app\/build.gradle\u4e0b\u7684 <code>atlas { tBuildConfig { outOfApkBundles = [&#039;remotebundle&#039;] }<\/code><\/li>\n<li>\u6784\u5efa\u5b8c\u6574\u5305\uff0c\u5728app\u76ee\u5f55\u4e0b\u6267\u884c <code>..\/gradlew clean assembleDebug publish<\/code>\uff0c\u8fdc\u7a0bbundle \u8def\u5f84\uff1a<code>app\/build\/outputs\/remote-bundles-debug<\/code><\/li>\n<li>\u5c06\u8fdc\u7a0bso\u4e0b\u8f7d\u5230\u4f60\u7684\u8bbe\u5907\u4e0a\uff08\u4e3b\u52a8\u4e0b\u8f7d\u548c\u88ab\u52a8\u63a8\u9001\u90fd\u53ef\u4ee5\uff09\uff0c\u8fd9\u91cc\u76f4\u63a5\u5728PC\u4e0a\u6267\u884c<code>adb push app\/build\/outputs\/remote-bundles-debug\/libcom_taobao_remotebunle.so \/sdcard\/Android\/data\/com.taobao.demo\/cache\/libcom_taobao_remotebunle.so<\/code><\/li>\n<li>\u6253\u5f00Demo\u4fa7\u8fb9\u680f\uff0c\u70b9\u51fb\u201c\u8fdc\u7a0b\u7ec4\u4ef6\u6a21\u62df\u201d\uff0c\u70b9\u51fb\u201c\u52a0\u8f7d\u8fdc\u7a0bbundle\u201d\uff0c\u52a0\u8f7d\u6210\u529f\u540e\u5c31\u4f1a\u8df3\u5230remotebundle\u7684\u9875\u9762\u3002<\/li>\n<\/ol>\n<h3>\u5355bundle\u90e8\u7f72\uff08\u70ed\u90e8\u7f72\uff09<\/h3>\n<p>\u5355bundle\u8c03\u8bd5\uff08\u4f9b\u7ebf\u4e0b\u8c03\u8bd5\u4f7f\u7528\uff0c\u5f53\u53ea\u66f4\u6539\u4e86\u5355\u4e2abundle\u7684\u4ee3\u7801\u65f6\uff0c\u65e0\u9700\u5bf9\u6574\u4e2aAPP\u8fdb\u884c\u52a8\u6001\u90e8\u7f72\uff0c\u53ef\u4ee5\u4e00\u952e\u8fdb\u884c\u5355bundle\u7684\u90e8\u7f72\u8c03\u8bd5\uff09<\/p>\n<ol>\n<li>\u4fee\u6539\u4e00\u4e2abundle\u5de5\u7a0b\u7684\u4e1a\u52a1\u4ee3\u7801\u6216\u8d44\u6e90\uff0c\u5982\u5728firstbundle\u4e2d\u7684FirstBundleActivity\u7684onCreate\u7684\u4e2d\u52a0\u4e00\u4e2aToast\u63d0\u793a\u3002<\/li>\n<li>\u5728firstbundle\u7684\u76ee\u5f55\u4e0b\u6267\u884c <code>..\/gradlew clean assemblePatchDebug<\/code>\uff0c\u7136\u540e\u7b49\u5e94\u7528\u91cd\u542f\u6216\u8005\u5e94\u7528\u5173\u95ed\u540e\u70b9\u51fb\u542f\u52a8\u5c31\u53ef\u4ee5\u770b\u5230Toast\u63d0\u793a\u751f\u6548\u3002 <\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Github\uff1ahttps:\/\/github.com\/alibaba\/atlas Demo\u4e2d\u7684Module\u7b80\u4ecb  [&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-1213","post","type-post","status-publish","format-standard","hentry","category-atlas"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1213","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=1213"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1213\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}