導入雲端資產提供服務
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
警告:Google Play 免安裝應用程式將停止提供服務。2025 年 12 月起,您無法透過 Google Play 發布免安裝應用程式,且所有 Google Play 服務免安裝 API 都將停止運作。Play 不會再透過任何機制向使用者提供免安裝應用程式。
我們根據開發人員的意見,並持續投入資源改善 Google Play Instant 推出後的生態系統,做出這項變更。
如要持續促進使用人數成長,建議開發人員使用深層連結,將使用者導向標準版應用程式或遊戲,並在適當情況下將他們重新導向至特定路徑或功能。
如要縮減應用程式大小以符合規定,請先嘗試標準 APK 大小最佳化技術。如需進一步縮減大小,可能需要透過雲端傳送素材資源。本文說明如何準備雲端傳送的資產,以及各種遊戲引擎的支援選項。本頁面的指引著重於遊戲,但這些原則適用於任何含有大型資產的應用程式。
準備
考慮將應用程式拆分成多個部分,以便透過雲端傳送資產時,請根據資產何時需要提供給使用者,將應用程式檔案分成不同區段。這類時機通常可分為三類:一律需要、啟動時需要,以及稍後需要。
一律需要
部分資產難以分割成較小的區塊,或必須與基本 APK 捆綁在一起。
例如遊戲程式碼及其程式庫或引擎依附元件。雖然 Google Play Core 支援程式碼的應用程式套件,但許多引擎不支援稍後下載的程式碼。
推出時需要
遊戲啟動後,使用者應可立即開始遊玩。Google Play 免安裝應用程式規定,使用者必須能在 LTE 或 4G 連線下,於 15 秒內開始玩遊戲 (請參閱 Google Play 免安裝應用程式檢查清單)。因此,啟動後進行的任何次要下載作業,都應限制在支援初始體驗所需的範圍內。舉例來說,在遊戲推出後立即進行的快速下載可能包含第一個遊戲關卡和位置資產,或是執行遊戲前幾分鐘所需的任何程式碼。
稍後需要
凡是日後可視需要下載的內容,都屬於這類。這個類別包含大多數的長篇遊戲資產。稍後再下載這些資產,有助於盡可能縮減應用程式大小。
引擎支援
雲端資產傳送是讓遊戲突破免安裝遊戲 15 MB 上限的主要方式。
下載素材資源的支援情況會因遊戲引擎而異。請參閱下方的常見案例,以及資產代管選項。
請注意,啟動時需要的資產越少,使用者就能越快進入遊戲,這表示首次啟動時的流失率會降低,玩家留存率也會提高。
Play Feature Delivery (透過應用程式套件)
如果您以應用程式套件形式發布應用程式 (建議採用這種做法),可以使用功能模組擷取基本 APK 以外的額外資源。對於免安裝應用程式,每個功能模組都必須在資訊清單中設定 dist:instant="true"
。請勿使用 dist:on-demand
屬性,這個屬性主要用於已安裝 APK 中的隨選模組。此外,無論模組是否包含程式碼,每個功能模組都不得超過免安裝 APK 的 15 MB 限制。如果每個模組都超過這個限制,就無法發布至 Alpha 或正式版測試群組。正確設定後,您可以使用 Play Core 程式庫,在執行階段擷取功能模組。
Cocos Creator
Cocos 自 v2.0.4 版起,就支援資產雲端傳送功能。Cocos 會視需要下載素材資源,如果素材資源未及時下載,則會顯示預留位置。Cocos 會產生資產檔案,但由於 Cocos 本身未提供線上服務,因此必須透過其他線上服務代管。
Unity
Unity Google Play 免安裝外掛程式支援雲端傳送功能,適用於 Unity 5.6、2017.4 或 2018.2 版。Unity 後續版本在引擎剝除方面提供更多優勢,因此遷移至這些版本可能有助於釋出更多空間。Unity 雲端資產會儲存在 Unity 為您建立的 AssetBundle
檔案中。將這些檔案上傳至雲端伺服器,即可透過雲端傳送資產,因為 Unity 本身支援下載資產套件。
其他引擎
無論您使用自訂引擎或原生程式庫集合,所選項目可能支援資產的雲端下載功能。如果資產數量龐大,需要從雲端下載,則必須編寫程式碼或整合方法,以便視需要下載遊戲資產。建議先從 Firebase 託管或 Firebase Cloud Storage API 開始。部分引擎提供簡單的 HTTPS 檔案擷取功能,可能也足以滿足您的需求。
代管資產
除非您使用 Google Play 應用程式套件透過 Play 下載資產,否則您必須將資產託管在其他位置。只要服務的全球發布和可用性合理,您就能自由選擇任何服務來代管這些檔案。Google Play 遊戲應用程式的使用者遍布全球,因此無論使用者位於何處,都必須快速提供雲端代管資產。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Implement cloud delivery of assets\n\n**Warning:** Google Play Instant will no longer be available. Starting December 2025,\nInstant Apps cannot be published through Google Play, and all\n[Google Play services Instant APIs](https://developers.google.com/android/reference/com/google/android/gms/instantapps/package-summary)\nwill no longer work. Users will no longer be served Instant Apps by Play using any\nmechanism.\n\nWe're making this change based on developer feedback and our continuous investments\nto improve the ecosystem since the introduction of Google Play Instant.\n\nTo continue optimizing for user growth, we encourage developers to refer users to\ntheir regular app or game, using [deeplinks](https://support.google.com/googleplay/android-developer/answer/12463044)\nto redirect them to specific journeys or features when relevant.\n\nWhen shrinking your app to fit the size requirements, first try the\n[standard APK size optimization techniques](/topic/google-play-instant/getting-started/game-instant-app#apk-size-reduction).\nIf you need to shrink the size down further, you might need to rely on cloud\ndelivery of assets. This document describes how to prepare assets for cloud\ndelivery and the support options from various game engines. While the guidance\non this page focuses on games, the principles apply to any app that contains\nlarge assets.\n\nPreparation\n-----------\n\nWhen thinking about breaking up your app for cloud delivery of assets, consider\nhow you can split your app files into sections based on *when* they need to be\navailable to the user. This timing tends to fall into the following three\ncategories: needed always, needed at launch, and needed later.\n\n### Needed always\n\nSome assets are difficult to separate into smaller blocks or are required to be bundled in the base APK.\nExamples include your game code and its library or engine dependencies. While\n[Google Play Core supports app bundles for code](/guide/app-bundle/playcore),\nmany engines don't support code downloaded later.\n\n### Needed at launch\n\nAfter the game starts, the user should be able to play immediately. Google Play Instant\nrequires that users can start playing your game in less than 15 seconds over an\nLTE or 4G connection (see the [Google Play Instant checklist](/topic/google-play-instant/tech-requirements#total-download-size)).\nTherefore, limit any secondary download after launch to be\nonly as large as necessary to support the initial experience. For example,\na fast-follow download immediately after launch might include the first game\nlevel and location assets, or any code required to run the first few minutes of gameplay.\n\n### Needed later\n\nAnything that you can afford to download later, in the background as needed,\nwill fall into this category. This category includes most assets for long-play\ngames. Downloading these assets later will help decrease the size of your app to\nas small as possible.\n\nEngine support\n--------------\n\nCloud asset delivery is the primary way to enable your game to go beyond the 15 MB limit for Instant play games.\nSupport for downloading assets will vary based on game engine. See the most\ncommon cases below, as well as options for hosting assets.\n\nNote that fewer needed-at-launch assets allow the user to get in the game\nfaster, which translates to lower drop-off and better player retention for that\nfirst launch.\n\n### Play Feature Delivery (through App Bundles)\n\nIf you publish your app as an app bundle (which is the preferred method), you\ncan use\n[feature modules](/guide/app-bundle/dynamic-delivery#customize_delivery)\nto fetch additional resources beyond the base APK. For your instant app, each\nfeature module must set `dist:instant=\"true\"` in the manifest. The\n`dist:on-demand` property should not be used; it is primarily used for on-demand\nmodules in installed APKs. Additionally, each feature module must be under\nthe instant APK limit of 15 MB, regardless of\nwhether or not the module contains code. Failure to keep each module under this\nlimit will prevent publishing to alpha or release tracks. Once properly\nconfigured, you can [fetch feature modules at runtime](/guide/playcore#request)\nusing the PlayCore library.\n\n### Cocos Creator\n\nCocos has supported cloud delivery of assets since\n[version v2.0.4](https://docs.cocos.com/creator/manual/en/publish/publish-android-instant.html).\nCocos downloads assets on demand, rendering placeholders if assets haven't been\ndownloaded in time. Cocos generates asset files that must be hosted with some\nonline service as Cocos does not provide one of its own.\n\n### Unity\n\nCloud delivery is supported in the\n[Unity Google Play Instant Plugin](https://github.com/google/play-instant-unity-plugin)\nfor Unity versions 5.6, 2017.4, or 2018.2. Later versions of Unity offer more\nbenefits for engine stripping, so they may be beneficial to migrate to in order\nto free more space. Unity cloud assets are hosted in `AssetBundle` files that\nUnity creates for you. Uploading these to a cloud server enables cloud delivery\nof assets, as Unity has innate support for\n[downloading asset bundles](https://docs.unity3d.com/540/Documentation/Manual/DownloadingAssetBundles.html).\n\n### Other engines\n\nWhether you use a custom engine or a\ncollection of native libraries, your choice might support cloud downloading of\nassets out of the box. If you have enough assets that you need to\ndownload them off of the cloud, then you'll need to code or integrate a way to\ndownload assets on demand for your game. The\n[Firebase Hosting](https://firebase.google.com/docs/hosting/) or\n[Firebase Cloud Storage APIs](https://firebase.google.com/docs/storage/) are\ngood places to start. Some engines offer simple HTTPS file fetching that might\nbe enough for your needs as well.\n\nHosting assets\n--------------\n\nUnless you're using Google Play [app bundles](/guide/app-bundle/playcore) to\ndownload your assets through Play, you'll need to host your assets elsewhere.\nYou're free to host them with any service you'd like as long as it has a\nreasonable global distribution and availability. Google Play Games app users play\naround the world, so cloud-hosted assets need to be served to them quickly in\nany location."]]