{"id":4092,"date":"2021-08-31T09:56:24","date_gmt":"2021-08-31T01:56:24","guid":{"rendered":"http:\/\/blog.coolcoding.cn\/?p=4092"},"modified":"2022-05-16T17:28:15","modified_gmt":"2022-05-16T09:28:15","slug":"unity2019%e5%87%bagoogle%e7%9a%84aab%e5%8c%85%ef%bc%8c%e4%bd%bf%e7%94%a8assetbundle%e5%8a%a0%e8%bd%bd%e8%b5%84%e6%ba%90%e5%b7%a8%e6%85%a2%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/blog.coolcoding.cn\/?p=4092","title":{"rendered":"Unity2019\u51fagoogle\u7684aab\u5305\uff0c\u4f7f\u7528Assetbundle\u52a0\u8f7d\u8d44\u6e90\u5de8\u6162\u7684\u95ee\u9898"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u4e00\u3001Google\u4ece2021\u5e748\u6708\u5f00\u59cb\uff0cGooglePlay\u5f3a\u884c\u4f7f\u7528aab\u683c\u5f0f<\/h2>\n\n\n\n<p><a href=\"https:\/\/android-developers.googleblog.com\/2021\/06\/the-future-of-android-app-bundles-is.html\">https:\/\/android-developers.googleblog.com\/2021\/06\/the-future-of-android-app-bundles-is.html<\/a><\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>Google 2021\u5e747\u6708\u5ba3\u5e03\uff0c\u4ece 8 \u6708\u958b\u59cb\uff0c\u63d0\u4ea4\u5230 Google Play Store \u53d1\u5e03\u7684\u65b0 App \u4e0d\u518d\u63a5\u53d7\u65e7\u7684 APK \u683c\u5f0f\uff0c\u5fc5\u9808\u4f7f\u7528\u65b0\u7684 AAB \uff08 Android App Bundle \uff09\u683c\u5f0f\u3002\u4f46\u73b0\u6709 App \u7684\u66f4\u65b0\u4e0d\u53d7\u5f71\u54cd\u3002\u800c\u300c Google Play \u514d\u5b89\u88dd\u9ad4\u9a57\uff08 Google Play Instant Experience \uff09\u300d\u5247\u5168\u9762\u4e0d\u518d\u63a5\u53d7 Instant app ZIP \u683c\u5f0f\uff0c\u7121\u8ad6\u65b0\u7a0b\u5f0f\u9084\u662f\u66f4\u65b0\u5747\u8981\u4ee5 Instant-enabled AAB \u683c\u5f0f\u905e\u4ea4\u3002<\/p><p><br>AAB \u662f Google \u5728 2018 \u5e74 5 \u6708 Google I\/O \u4e2d\u63d0\u51fa\u7684\u65b0\u7a0b\u5f0f\u5206\u767c\u683c\u5f0f\uff0c\u63d0\u4f9b\u66f4\u73fe\u4ee3\u5316\u7684\u5206\u767c\u529f\u80fd\uff0c\u9664\u4e86\u53ef\u4ee5\u6309\u7528\u6236\u88dd\u7f6e\u81ea\u8a02\u9700\u8981\u5b89\u88dd\u7684\u529f\u80fd\u6a21\u7d44\uff0c\u904a\u6232\u9019\u985e\u6709\u5f88\u591a\u5927\u578b\u6a94\u6848\u7684\u7a0b\u5f0f\u4e5f\u53ef\u4ee5\u63a1\u7528\u6750\u8cea\u58d3\u7e2e\u683c\u5f0f\u76ee\u6a19\u529f\u80fd\uff0c\u6e1b\u5c11\u4e0b\u8f09\u6642\u9593\u548c\u6a94\u6848\u5927\u5c0f\uff0c\u4e5f\u56e0\u70ba\u4e0d\u7528\u5b89\u88dd\u7528\u4e0d\u5230\u7684\u6a94\u6848\u800c\u7bc0\u7701\u624b\u6a5f\u7684\u5bb9\u91cf\u548c\u6d41\u91cf\uff0c\u4ee4\u7a0b\u5f0f\u88fd\u4f5c\u548c\u767c\u4f48\u66f4\u6709\u6548\u7387\uff0c\u6240\u4ee5\u63a8\u85a6\u958b\u767c\u8005\u63a1\u7528\u3002<\/p><p><br>Google \u6307\u73fe\u6642\u5df2\u6709\u8d85\u904e 100 \u842c\u6b3e Android \u7a0b\u5f0f\u63a1\u7528 AAB \u683c\u5f0f\u767c\u4f48\uff0c\u5305\u62ec\u9996 1,000 \u4f4d\u7a0b\u5f0f\u548c\u904a\u6232\uff0c\u5305\u62ec Adobe \u3001 Gameloft \u3001 Netflix \u3001 Twitter \u7b49\u3002<br>\u4e0d\u904e\u7531\u65bc Android \u63a5\u53d7 Sideloading \uff0c\u73fe\u6642\u53ea\u6709 Google Play Store \u652f\u63f4 AAB \u683c\u5f0f\uff0c\u800c\u5176\u4ed6 Android AppStore \u5982 Samsung \u548c Amazon \u7b49\u5747\u4ecd\u7136\u4f7f\u7528 APK \u683c\u5f0f\uff0c\u6240\u4ee5\u76f8\u4fe1\u4eca\u5f8c\u958b\u767c\u8005\u70ba\u4e86\u5ee3\u6cdb\u767c\u4f48\uff0c\u5c07\u8981\u540c\u6642\u5c0d\u61c9 AAB \u548c APK \u5169\u7a2e\u683c\u5f0f\u3002  <\/p><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u73af\u5883<\/h2>\n\n\n\n<p><br>Unity2019.4.29\uff0c\u51faAndroid\u5305\uff0c\u4f7f\u7528Assetbundle\u65b9\u5f0f\u52a0\u8f7d\u8d44\u6e90<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u8868\u73b0<\/h2>\n\n\n\n<p><br>\u6253\u51fa\u6765\u7684aab\u5305\uff0c\u4f7f\u7528 UnityEngine.SceneManagement.SceneManager.LoadSceneAsync \u52a0\u8f7d\u573a\u666f\uff0c\u6bd4\u4f7f\u7528apk\u5305\uff0c\u616220\u500d\u4ee5\u4e0a<\/p>\n\n\n\n<p>apk\u5927\u69820.1\u79d2\u5c31\u52a0\u8f7d\u5b8c\u6210\uff0c\u800caab\u9700\u89814\u79d2\u4ee5\u4e0a\u624d\u80fd\u52a0\u8f7d\u5b8c<\/p>\n\n\n\n<p>\u56db\u3001\u8d44\u6599\u67e5\u627e<\/p>\n\n\n\n<p><a href=\"https:\/\/forum.unity.com\/threads\/streamingassets-files-are-compressed-in-apk-when-build-app-bundle-google-play-option-is-used.739967\/\">https:\/\/forum.unity.com\/threads\/streamingassets-files-are-compressed-in-apk-when-build-app-bundle-google-play-option-is-used.739967\/<\/a><\/p>\n\n\n\n<p>\u8bf4\u662f\u6253\u5305\u65f6\uff0cab\u5305\u7528\u4e86\u5927\u5199\u5b57\u6bcd\uff0c\u6240\u4ee5\u5c31\u88ab\u5f3a\u884c\u538b\u7f29\u4e86<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e94\u3001\u5c1d\u8bd5\u4f7f\u7528\u5168\u5c0f\u5199\u5b57\u6bcd\u7684ab\u5305<\/h2>\n\n\n\n<p>\u672a\u80fd\u89e3\u51b3\uff1b\u52a0\u8f7d\u4f9d\u7136\u975e\u5e38\u6162<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u516d\u3001\u5c1d\u8bd5\u75287z\u6253\u5f00aab\uff0c\u67e5\u770bssetbundle\u6587\u4ef6<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"482\" height=\"183\" src=\"http:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2021\/08\/image-4.png\" alt=\"\" class=\"wp-image-4093\"\/><\/figure>\n\n\n\n<p>\u53d1\u73b0\u679c\u7136assetbundle\u88ab\u5f3a\u884c\u538b\u7f29\u4e86\uff0c\u800c\u5728apk\u4e2d\uff0c\u662f\u8fd9\u6837\u7684\uff0c\u5927\u5c0f\u5b8c\u5168\u4e00\u6837<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"467\" height=\"201\" src=\"http:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2021\/08\/image-5.png\" alt=\"\" class=\"wp-image-4094\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e03\u3001\u4e34\u65f6\u89e3\u51b3\u65b9\u6848<\/h2>\n\n\n\n<p>\u5c31\u662f\u628aassetbundle\u6587\u4ef6\u5168\u90e8\u4ecestreamingAssetPath\u91ca\u653e\u5230persistentDataPath\u76ee\u5f55<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\npublic IEnumerator ReleaseAllAssetbundles(List&lt;string> abfiles)\n{\n    foreach (var abName abfiles) {\n        var src = Path.Combine(Application.streamingAssetsPath, abName);\n        var dst = Path.Combine(Application.persistentDataPath, abName);\n        if (File.Exists(dst)) {\n            continue;\n        }\n        WWW www = new WWW(src);\n        yield return www;\n        if (www.isDone) {\n            File.WriteAllBytes(dst, www.bytes);\n        }\n    }\n}\n<\/code><\/pre>\n\n\n\n<p>\u7136\u540eAssetBundle\u4eceApplication.persistentDataPath\u76ee\u5f55\u52a0\u8f7d<\/p>\n\n\n\n<p>\u5f0a\u7aef\u5c31\u662f\u4e00\u4e2a1G\u7684\u5b89\u88c5\u5305\uff0c\u5b89\u88c5\u540e\uff0c\u91ca\u653e\u5b8c\u78c1\u76d8\u7a7a\u95f4\u8981\u5360\u75282G<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u516b\u3001\u597d\u7684\u89e3\u51b3\u65b9\u6848<\/h2>\n\n\n\n<p>\u5728Unity\u7684Player Setting\u4e2d\uff0c\u627e\u5230Publishing settings\u4e2d\uff0c\u52fe\u9009Custom main gradle template\uff0c\u5219\u5728Assets\/Plugins\/Android\u76ee\u5f55\u4e2d\uff0c\u4f1a\u591a\u51fa\u4e00\u4e2amainTemplate\u6587\u4ef6\uff0c\u7f16\u8f91\u6b64\u6587\u4ef6\uff0c\u5728aaptOptions\u4e2d\uff0cnoCompress = \u4e00\u586b\u4e2d \uff0c\u628aab\u7684\u6269\u5c55\u540d\u586b\u8fdb\u53bb\u5373\u53ef<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001Google\u4ece2021\u5e748\u6708\u5f00\u59cb\uff0cGooglePlay\u5f3a\u884c\u4f7f\u7528aab\u683c\u5f0f https:\/\/android- [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/4092"}],"collection":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4092"}],"version-history":[{"count":6,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/4092\/revisions"}],"predecessor-version":[{"id":4464,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/4092\/revisions\/4464"}],"wp:attachment":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}