[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Reduce the size of your instant app\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\nGoogle Play Instant provides rich, native experiences at the tap of a web\nlink. People can experience your app without upfront installation, enabling a\nhigher level and quality of engagement. To make an instant app load as quickly\nas a typical mobile webpage does, though, you need to create a well-structured,\nefficient instant app. The smaller your instant app's binary, the faster it\nloads and the smoother the user experience is.\n\nThis document conveys best practices for managing your app's structure and\nbinary size to enable a smooth instant app experience. You can apply these same\npractices to benefit your installable app, too.\n\nRefactor into multiple feature modules\n--------------------------------------\n\nThe largest improvement to your app's binary size occurs when you refactor the\napp into multiple feature modules. Start with a [base feature\nmodule](/topic/google-play-instant/getting-started/create-base-feature-module),\nthen extract thematically-related workflows into their own feature modules.\nAssign a starting activity and unique URL to each feature module so that users\ncan complete the module's workflow successfully.\n\nAs you create feature modules, keep the base feature module as small as\npossible. In particular, pay close attention to the parts of your app that\nrequire access to your dependent libraries. If only one feature module uses a\ngiven library, import that library in the feature module itself, not the base\nfeature module. Keep in mind that, in order to release an instant app for a\nparticular feature module, the **total** size of that feature\nmodule and the base feature module must be less than 15 MB.\n| **Note:** If your instant experience contains more methods than the DEX limit of 65,536 methods, you can still [enable multidex](/studio/build/multidex) and publish your instant experience, provided that your app satisfies the total size limit.\n\n### Best practices\n\nWhen refactoring your app, keep the following best practices in mind:\n\nUse the same codebase for both app types\n: You can simplify your app's project management process by using the same\n modular codebase to create **both** your installed app and your instant apps.\n\nDesign for multiple feature modules\n: Even if your app has only one workflow and requires only a single feature\n module for now, it's still a good idea to design for multiple feature modules.\n That way, you can add existing modules to your app without affecting the\n original feature module's size.\n\nDon't focus on the feature module size limit at the beginning\n: Feature module size limits don't apply to locally-built binaries. You can\n also release an instant app through the **internal test** track, which enforces\n a 15 MB limit on feature module sizes. Only the **alpha** and\n **production** tracks enforce the 15 MB limit.\n\nUpdate app resources\n--------------------\n\nSome apps, particularly those that have longer codebase histories, contain\nresources that your app's binaries no longer use. As you look for ways to make\nyour app's modules smaller, consider the following common sources of unneeded\ncode.\n\n### Reduce file size of images\n\nYou can significantly reduce the total size of your app's drawables by using\nthe [WebP](https://blog.chromium.org/2010/09/webp-new-image-format-for-web.html)\nfile format instead of PNG. Google Play Instant provides complete support\nfor WebP, including transparency and lossless compression, so image quality\nremains the same.\n| **Note:** The one exception to this rule is your app's launcher icon: it must use the PNG format. This rule has minimal impact on your app's total size, however, because most projects store launcher icons in the `mipmap` directory.\n\nIf possible, remove all backward compatibility requirements for using other PNG\nimages. If you must use PNG images, place them in the module that's used to\nbuild and install your app.\n| **Note:** You can save even more space by converting your app's images to [vector drawables](/guide/topics/graphics/vector-drawable-resources). Unlike the conversion from PNG to WebP, however, you need to change your app's code to use vector drawables.\n\n### Remove unused languages\n\nIf your app supports multiple languages, reduce as many localized resources as\nyou can. This step is particularly useful to complete if you use an \"app\ncompat\" library, such as [`android.support.v7.appcompat`](/reference/android/support/v7/appcompat/package-summary).\nThis library includes messages in many languages, some of which your app might\nnot support.\n\nTo learn more, check out how to [remove unused alternative\nresources](/studio/build/shrink-code#unused-alt-resources), particularly\nunused languages.\n\n### Remove extra files\n\nYour app might no longer use some of the resources that you've imported into\nyour project. To help remove these resources, Android Studio has a Lint check\nfor this specific situation. To use the tool, complete the following steps:\n\n1. Press **Control+Alt+Shift+I** (**Command+Alt+Shift+I** on Mac OS).\n2. In the dialog that appears, type `\"unused resources\"`.\n3. Select the **Unused resources** option to start the resource usage inspection process.\n\nIf any large resources remain in your app, consider whether it's possible to\nunpackage them from your app and download them as standalone files after the\nuser starts interacting with your app. This sort of image-loading deferral\nusually requires a code change, but it can substantially reduce your instant\napp's file size by downloading only the resources that a user explicitly\nrequests.\n\nRemove unused libraries\n-----------------------\n\nAs an app grows in scope, it can take on a surprising number of dependencies,\nparticularly one of the following types:\n\n- **Native libraries:** Libraries that contain native code that your instant app never runs.\n- **Transitive dependencies:** Libraries upon which your app's imported libraries depend.\n\nAndroid Studio has several useful tools for identifying any extraneous\ndependencies in your app's project:\n\nExternal libraries\n\n: Android Studio's **Project** view includes an **External Libraries** section.\n\n This section contains every library that your app uses, including native\n code and all transitive dependencies. In this view, look for unused or dupicate\n libraries that your app doesn't require.\n\nAPK Analyzer\n\n: You can use the [APK Analyzer](/studio/debug/apk-analyzer) tool to compare\n different builds, including instant app builds.\n\nAfter you've determined which libraries your app doesn't need, exclude them by\nadding lines similar to the following to your Gradle build file:\n\n\\\u003cfeature_module\\\u003e/build.gradle \n\n### Groovy\n\n```groovy\ndependencies {\n implementation('some-important-but-large-library') {\n exclude group: 'com.example.imgtools', module: 'native'\n }\n}\n```\n\n### Kotlin\n\n```kotlin\ndependencies {\n implementation('some-important-but-large-library') {\n exclude(group = \"com.example.imgtools\", module = \"native\")\n }\n}\n```\n\nFor more information on reducing the total import size of your app's\ndependencies, see Gradle's guide to [Dependency\nManagement](https://docs.gradle.org/current/userguide/core_dependency_management.html).\n\nImplement cloud delivery of assets\n----------------------------------\n\nIf you need to shrink the size down further, you might need to rely on [cloud delivery of assets](/topic/google-play-instant/getting-started/cloud-delivery-assets)."]]