CINXE.COM
Shrink, obfuscate, and optimize your app | Android Studio | Android Developers
<!doctype html> <html lang="en" dir="ltr"> <head> <meta name="google-signin-client-id" content="721724668570-nbkv1cfusk7kk4eni4pjvepaus73b13t.apps.googleusercontent.com"> <meta name="google-signin-scope" content="profile email https://www.googleapis.com/auth/developerprofiles https://www.googleapis.com/auth/developerprofiles.award"> <meta property="og:site_name" content="Android Developers"> <meta property="og:type" content="website"><meta name="theme-color" content="#34a853"><meta charset="utf-8"> <meta content="IE=Edge" http-equiv="X-UA-Compatible"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="manifest" href="/_pwa/android/manifest.json" crossorigin="use-credentials"> <link rel="preconnect" href="//www.gstatic.com" crossorigin> <link rel="preconnect" href="//fonts.gstatic.com" crossorigin> <link rel="preconnect" href="//fonts.googleapis.com" crossorigin> <link rel="preconnect" href="//apis.google.com" crossorigin> <link rel="preconnect" href="//www.google-analytics.com" crossorigin><link rel="stylesheet" href="//fonts.googleapis.com/css?family=Google+Sans:400,500,600,700|Google+Sans+Text:400,400italic,500,500italic,600,600italic,700,700italic|Roboto+Mono:400,500,700&display=swap"> <link rel="stylesheet" href="//fonts.googleapis.com/css2?family=Material+Icons&family=Material+Symbols+Outlined&display=block"><link rel="stylesheet" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/css/app.css"> <link rel="stylesheet" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/css/dark-theme.css" disabled> <link rel="shortcut icon" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/favicon.svg"> <link rel="apple-touch-icon" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/touchicon-180.png"><link rel="canonical" href="https://developer.android.com/build/shrink-code"><link rel="search" type="application/opensearchdescription+xml" title="Android Developers" href="https://developer.android.com/s/opensearch.xml"> <link rel="alternate" hreflang="en" href="https://developer.android.com/build/shrink-code" /><link rel="alternate" hreflang="x-default" href="https://developer.android.com/build/shrink-code" /><link rel="alternate" hreflang="ar" href="https://developer.android.com/build/shrink-code?hl=ar" /><link rel="alternate" hreflang="bn" href="https://developer.android.com/build/shrink-code?hl=bn" /><link rel="alternate" hreflang="zh-Hans" href="https://developer.android.com/build/shrink-code?hl=zh-cn" /><link rel="alternate" hreflang="zh-Hant" href="https://developer.android.com/build/shrink-code?hl=zh-tw" /><link rel="alternate" hreflang="fa" href="https://developer.android.com/build/shrink-code?hl=fa" /><link rel="alternate" hreflang="fr" href="https://developer.android.com/build/shrink-code?hl=fr" /><link rel="alternate" hreflang="de" href="https://developer.android.com/build/shrink-code?hl=de" /><link rel="alternate" hreflang="he" href="https://developer.android.com/build/shrink-code?hl=he" /><link rel="alternate" hreflang="hi" href="https://developer.android.com/build/shrink-code?hl=hi" /><link rel="alternate" hreflang="id" href="https://developer.android.com/build/shrink-code?hl=id" /><link rel="alternate" hreflang="it" href="https://developer.android.com/build/shrink-code?hl=it" /><link rel="alternate" hreflang="ja" href="https://developer.android.com/build/shrink-code?hl=ja" /><link rel="alternate" hreflang="ko" href="https://developer.android.com/build/shrink-code?hl=ko" /><link rel="alternate" hreflang="pl" href="https://developer.android.com/build/shrink-code?hl=pl" /><link rel="alternate" hreflang="pt-BR" href="https://developer.android.com/build/shrink-code?hl=pt-br" /><link rel="alternate" hreflang="ru" href="https://developer.android.com/build/shrink-code?hl=ru" /><link rel="alternate" hreflang="es-419" href="https://developer.android.com/build/shrink-code?hl=es-419" /><link rel="alternate" hreflang="th" href="https://developer.android.com/build/shrink-code?hl=th" /><link rel="alternate" hreflang="tr" href="https://developer.android.com/build/shrink-code?hl=tr" /><link rel="alternate" hreflang="vi" href="https://developer.android.com/build/shrink-code?hl=vi" /><title>Shrink, obfuscate, and optimize your app | Android Studio | Android Developers</title> <meta property="og:title" content="Shrink, obfuscate, and optimize your app | Android Studio | Android Developers"><meta name="description" content="Learn how to shrink code in your release build to remove unused code and resources."> <meta property="og:description" content="Learn how to shrink code in your release build to remove unused code and resources."><meta property="og:url" content="https://developer.android.com/build/shrink-code"><meta property="og:image" content="https://developer.android.com/static/images/social/android-developers.png"> <meta property="og:image:width" content="1200"> <meta property="og:image:height" content="675"><meta property="og:locale" content="en"><meta name="twitter:card" content="summary_large_image"><script type="application/ld+json"> { "@context": "https://schema.org", "@type": "Article", "headline": "Shrink, obfuscate, and optimize your app" } </script><script type="application/ld+json"> { "@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [{ "@type": "ListItem", "position": 1, "name": "Android Studio", "item": "https://developer.android.com/studio" },{ "@type": "ListItem", "position": 2, "name": "Shrink, obfuscate, and optimize your app", "item": "https://developer.android.com/build/shrink-code" }] } </script> <link rel="stylesheet" href="/extras.css"></head> <body class="" template="page" theme="android-theme" type="article" appearance layout="docs" display-toc pending> <devsite-progress type="indeterminate" id="app-progress"></devsite-progress> <section class="devsite-wrapper"> <devsite-cookie-notification-bar></devsite-cookie-notification-bar><devsite-header role="banner"> <div class="devsite-header--inner nocontent"> <div class="devsite-top-logo-row-wrapper-wrapper"> <div class="devsite-top-logo-row-wrapper"> <div class="devsite-top-logo-row"> <button type="button" id="devsite-hamburger-menu" class="devsite-header-icon-button button-flat material-icons gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Navigation menu button" visually-hidden aria-label="Open menu"> </button> <div class="devsite-product-name-wrapper"> <a href="/" class="devsite-site-logo-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Site logo" track-type="globalNav" track-name="androidDevelopers" track-metadata-position="nav" track-metadata-eventDetail="nav"> <picture> <source srcset="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/lockup-dark-theme.svg" media="(prefers-color-scheme: dark)" class="devsite-dark-theme" alt="Android Developers"> <img src="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/lockup.svg" class="devsite-site-logo" alt="Android Developers"> </picture> </a> <span class="devsite-product-name"> <ul class="devsite-breadcrumb-list" > <li class="devsite-breadcrumb-item "> </li> </ul> </span> </div> <div class="devsite-top-logo-row-middle"> <div class="devsite-header-upper-tabs"> <devsite-tabs class="upper-tabs"> <nav class="devsite-tabs-wrapper" aria-label="Upper tabs"> <tab class="devsite-dropdown devsite-dropdown-full "> <a href="https://developer.android.com/get-started" track-metadata-eventdetail="https://developer.android.com/get-started" class="devsite-tabs-content gc-analytics-event android-dropdown-tab" track-type="nav" track-metadata-position="nav - essentials" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Essentials" track-name="essentials" > Essentials </a> <a href="#" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Dropdown menu for Essentials" track-type="nav" track-metadata-eventdetail="https://developer.android.com/get-started" track-metadata-position="nav - essentials" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Essentials" track-name="essentials" class="devsite-tabs-dropdown-toggle devsite-icon devsite-icon-arrow-drop-down"></a> <div class="devsite-tabs-dropdown" aria-label="submenu" hidden> <div class="devsite-tabs-dropdown-content"> <div class="devsite-tabs-dropdown-column android-dropdown android-dropdown-primary android-dropdown-studio"> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-title" role="heading" tooltip>Gemini in Android Studio</li> <li class="devsite-nav-description">Your AI development companion for Android development. </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/gemini-in-android" track-type="nav" track-metadata-eventdetail="https://developer.android.com/gemini-in-android" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="gemini in android studio" tooltip class="button button-primary" > <div class="devsite-nav-item-title"> Learn more </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/studio" track-type="nav" track-metadata-eventdetail="https://developer.android.com/studio" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="gemini in android studio" tooltip class="button button-white" > <div class="devsite-nav-item-title"> Get Android Studio </div> </a> </li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-launch"> <li class="devsite-nav-title" role="heading" tooltip>Get started</li> <li class="devsite-nav-description">Start by creating your first app. Go deeper with our training courses or explore app development on your own. </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/get-started/overview" track-type="nav" track-metadata-eventdetail="https://developer.android.com/get-started/overview" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get started" tooltip > <div class="devsite-nav-item-title"> Hello world </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/courses" track-type="nav" track-metadata-eventdetail="https://developer.android.com/courses" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get started" tooltip > <div class="devsite-nav-item-title"> Training courses </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/get-started/codelabs" track-type="nav" track-metadata-eventdetail="https://developer.android.com/get-started/codelabs" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get started" tooltip > <div class="devsite-nav-item-title"> Tutorials </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/kotlin" track-type="nav" track-metadata-eventdetail="https://developer.android.com/kotlin" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get started" tooltip > <div class="devsite-nav-item-title"> Kotlin for Android </div> </a> </li> <li class="devsite-nav-item"> <a href="https://play.google.com/console/about/guides/monetize/" track-type="nav" track-metadata-eventdetail="https://play.google.com/console/about/guides/monetize/" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get started" tooltip > <div class="devsite-nav-item-title"> Monetization with Play ↗️ </div> </a> </li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-multiple-screens"> <li class="devsite-nav-title" role="heading" tooltip>Extend by device</li> <li class="devsite-nav-description">Build apps that give your users seamless experiences from phones to tablets, watches, and more. </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/adaptive-apps" track-type="nav" track-metadata-eventdetail="https://developer.android.com/adaptive-apps" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="extend by device" tooltip > <div class="devsite-nav-item-title"> Adaptive apps </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/wear" track-type="nav" track-metadata-eventdetail="https://developer.android.com/wear" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="extend by device" tooltip > <div class="devsite-nav-item-title"> Wear OS </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/cars" track-type="nav" track-metadata-eventdetail="https://developer.android.com/cars" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="extend by device" tooltip > <div class="devsite-nav-item-title"> Android for Cars </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/tv" track-type="nav" track-metadata-eventdetail="https://developer.android.com/tv" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="extend by device" tooltip > <div class="devsite-nav-item-title"> Android TV </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/chrome-os" track-type="nav" track-metadata-eventdetail="https://developer.android.com/chrome-os" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="extend by device" tooltip > <div class="devsite-nav-item-title"> ChromeOS </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/multi-device-development" track-type="nav" track-metadata-eventdetail="https://developer.android.com/multi-device-development" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="extend by device" tooltip > <div class="devsite-nav-item-title"> Cross-device SDK </div> </a> </li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-platform"> <li class="devsite-nav-title" role="heading" tooltip>Build by category</li> <li class="devsite-nav-description">Learn to build for your use case by following Google's prescriptive and opinionated guidance. </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/games" track-type="nav" track-metadata-eventdetail="https://developer.android.com/games" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="build by category" tooltip > <div class="devsite-nav-item-title"> Games </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/media" track-type="nav" track-metadata-eventdetail="https://developer.android.com/media" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="build by category" tooltip > <div class="devsite-nav-item-title"> Camera & Media </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/social-and-messaging" track-type="nav" track-metadata-eventdetail="https://developer.android.com/social-and-messaging" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="build by category" tooltip > <div class="devsite-nav-item-title"> Social & messaging </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/health-and-fitness" track-type="nav" track-metadata-eventdetail="https://developer.android.com/health-and-fitness" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="build by category" tooltip > <div class="devsite-nav-item-title"> Health & Fitness </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/productivity" track-type="nav" track-metadata-eventdetail="https://developer.android.com/productivity" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="build by category" tooltip > <div class="devsite-nav-item-title"> Productivity </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/work/overview" track-type="nav" track-metadata-eventdetail="https://developer.android.com/work/overview" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="build by category" tooltip > <div class="devsite-nav-item-title"> Enterprise apps </div> </a> </li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-stars"> <li class="devsite-nav-title" role="heading" tooltip>Get the latest</li> <li class="devsite-nav-description">Stay in touch with the latest releases throughout the year, join our preview programs, and give us your feedback. </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/latest-updates" track-type="nav" track-metadata-eventdetail="https://developer.android.com/latest-updates" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get the latest" tooltip > <div class="devsite-nav-item-title"> Latest updates </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/latest-updates/experimental" track-type="nav" track-metadata-eventdetail="https://developer.android.com/latest-updates/experimental" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get the latest" tooltip > <div class="devsite-nav-item-title"> Experimental updates </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/studio/preview" track-type="nav" track-metadata-eventdetail="https://developer.android.com/studio/preview" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get the latest" tooltip > <div class="devsite-nav-item-title"> Android Studio preview </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/jetpack/androidx/versions" track-type="nav" track-metadata-eventdetail="https://developer.android.com/jetpack/androidx/versions" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get the latest" tooltip > <div class="devsite-nav-item-title"> Jetpack & Compose libraries </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/training/wearables/versions/4" track-type="nav" track-metadata-eventdetail="https://developer.android.com/training/wearables/versions/4" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get the latest" tooltip > <div class="devsite-nav-item-title"> Wear OS preview </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/design-for-safety/privacy-sandbox" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design-for-safety/privacy-sandbox" track-metadata-position="nav - essentials" track-metadata-module="tertiary nav" track-metadata-module_headline="get the latest" tooltip > <div class="devsite-nav-item-title"> Privacy Sandbox </div> </a> </li> </ul> </div> </div> </div> </tab> <tab class="devsite-dropdown devsite-dropdown-full "> <a href="https://developer.android.com/design" track-metadata-eventdetail="https://developer.android.com/design" class="devsite-tabs-content gc-analytics-event android-dropdown-tab" track-type="nav" track-metadata-position="nav - design & plan" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Design & Plan" track-name="design & plan" > Design & Plan </a> <a href="#" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Dropdown menu for Design & Plan" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design" track-metadata-position="nav - design & plan" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Design & Plan" track-name="design & plan" class="devsite-tabs-dropdown-toggle devsite-icon devsite-icon-arrow-drop-down"></a> <div class="devsite-tabs-dropdown" aria-label="submenu" hidden> <div class="devsite-tabs-dropdown-content"> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-layout"> <li class="devsite-nav-title" role="heading" tooltip>UI Design</li> <li class="devsite-nav-description">Design a beautiful user interface using Android best practices.</li> <li class="devsite-nav-item"> <a href="https://developer.android.com/design/ui" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design/ui" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="ui design" tooltip > <div class="devsite-nav-item-title"> Design for Android </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/design/ui/mobile" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design/ui/mobile" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="ui design" tooltip > <div class="devsite-nav-item-title"> Mobile </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/design/ui/large-screens" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design/ui/large-screens" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="ui design" tooltip > <div class="devsite-nav-item-title"> Large screens (e.g., tablets) </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/design/ui/widget" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design/ui/widget" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="ui design" tooltip > <div class="devsite-nav-item-title"> Widgets </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/design/ui/wear" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design/ui/wear" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="ui design" tooltip > <div class="devsite-nav-item-title"> Wear OS </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/design/ui/tv" track-type="nav" track-metadata-eventdetail="https://developer.android.com/design/ui/tv" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="ui design" tooltip > <div class="devsite-nav-item-title"> Android TV </div> </a> </li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-design"> <li class="devsite-nav-title" role="heading" tooltip>Architecture</li> <li class="devsite-nav-description">Design robust, testable, and maintainable app logic and services.</li> <li class="devsite-nav-item"> <a href="https://developer.android.com/topic/architecture/intro" track-type="nav" track-metadata-eventdetail="https://developer.android.com/topic/architecture/intro" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="architecture" tooltip > <div class="devsite-nav-item-title"> Introduction </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/topic/libraries/view-binding" track-type="nav" track-metadata-eventdetail="https://developer.android.com/topic/libraries/view-binding" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="architecture" tooltip > <div class="devsite-nav-item-title"> Libraries </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/guide/navigation/navigation-principles" track-type="nav" track-metadata-eventdetail="https://developer.android.com/guide/navigation/navigation-principles" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="architecture" tooltip > <div class="devsite-nav-item-title"> Navigation </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/topic/modularization" track-type="nav" track-metadata-eventdetail="https://developer.android.com/topic/modularization" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="architecture" tooltip > <div class="devsite-nav-item-title"> Modularization </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/training/testing/fundamentals" track-type="nav" track-metadata-eventdetail="https://developer.android.com/training/testing/fundamentals" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="architecture" tooltip > <div class="devsite-nav-item-title"> Testing </div> </a> </li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-vitals"> <li class="devsite-nav-title" role="heading" tooltip>Quality</li> <li class="devsite-nav-description">Plan for app quality and align with Play store guidelines.</li> <li class="devsite-nav-item"> <a href="https://developer.android.com/quality" track-type="nav" track-metadata-eventdetail="https://developer.android.com/quality" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="quality" tooltip > <div class="devsite-nav-item-title"> Overview </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/quality/core-value" track-type="nav" track-metadata-eventdetail="https://developer.android.com/quality/core-value" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="quality" tooltip > <div class="devsite-nav-item-title"> Core value </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/quality/user-experience" track-type="nav" track-metadata-eventdetail="https://developer.android.com/quality/user-experience" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="quality" tooltip > <div class="devsite-nav-item-title"> User experience </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/quality/technical" track-type="nav" track-metadata-eventdetail="https://developer.android.com/quality/technical" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="quality" tooltip > <div class="devsite-nav-item-title"> Technical quality </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/quality/privacy-and-security" track-type="nav" track-metadata-eventdetail="https://developer.android.com/quality/privacy-and-security" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="quality" tooltip > <div class="devsite-nav-item-title"> Security </div> </a> </li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-security-2"> <li class="devsite-nav-title" role="heading" tooltip>Security</li> <li class="devsite-nav-description">Safeguard users against threats and ensure a secure Android experience.</li> <li class="devsite-nav-item"> <a href="https://developer.android.com/security" track-type="nav" track-metadata-eventdetail="https://developer.android.com/security" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="security" tooltip > <div class="devsite-nav-item-title"> Overview </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/privacy-and-security/about" track-type="nav" track-metadata-eventdetail="https://developer.android.com/privacy-and-security/about" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="security" tooltip > <div class="devsite-nav-item-title"> Privacy </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/identity" track-type="nav" track-metadata-eventdetail="https://developer.android.com/identity" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="security" tooltip > <div class="devsite-nav-item-title"> Identity </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/security/fraud-prevention" track-type="nav" track-metadata-eventdetail="https://developer.android.com/security/fraud-prevention" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="security" tooltip > <div class="devsite-nav-item-title"> Fraud prevention </div> </a> </li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-earth"> <li class="devsite-nav-title" role="heading" tooltip>Build for Billions</li> <li class="devsite-nav-description">Create the best experience for entry-level devices</li> <li class="devsite-nav-item"> <a href="https://developer.android.com/build-for-billions" track-type="nav" track-metadata-eventdetail="https://developer.android.com/build-for-billions" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="build for billions" tooltip > <div class="devsite-nav-item-title"> Overview </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/docs/quality-guidelines/build-for-billions" track-type="nav" track-metadata-eventdetail="https://developer.android.com/docs/quality-guidelines/build-for-billions" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="build for billions" tooltip > <div class="devsite-nav-item-title"> About new markets </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/guide/topics/androidgo" track-type="nav" track-metadata-eventdetail="https://developer.android.com/guide/topics/androidgo" track-metadata-position="nav - design & plan" track-metadata-module="tertiary nav" track-metadata-module_headline="build for billions" tooltip > <div class="devsite-nav-item-title"> Android (Go edition) </div> </a> </li> </ul> </div> </div> </div> </tab> <tab class="devsite-dropdown devsite-dropdown-full devsite-active "> <a href="https://developer.android.com/develop" track-metadata-eventdetail="https://developer.android.com/develop" class="devsite-tabs-content gc-analytics-event android-dropdown-tab" track-type="nav" track-metadata-position="nav - develop" track-metadata-module="primary nav" aria-label="Develop, selected" data-category="Site-Wide Custom Events" data-label="Tab: Develop" track-name="develop" > Develop </a> <a href="#" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Dropdown menu for Develop" track-type="nav" track-metadata-eventdetail="https://developer.android.com/develop" track-metadata-position="nav - develop" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Develop" track-name="develop" class="devsite-tabs-dropdown-toggle devsite-icon devsite-icon-arrow-drop-down"></a> <div class="devsite-tabs-dropdown" aria-label="submenu" hidden> <div class="devsite-tabs-dropdown-content"> <div class="devsite-tabs-dropdown-column android-dropdown android-dropdown-primary android-dropdown-ai"> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-title" role="heading" tooltip>Build AI experiences</li> <li class="devsite-nav-description">Build AI-powered Android apps with Gemini APIs and more. </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/ai" track-type="nav" track-metadata-eventdetail="https://developer.android.com/ai" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="build ai experiences" tooltip class="button button-primary" > <div class="devsite-nav-item-title"> Get started </div> </a> </li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-flag"> <li class="devsite-nav-title" role="heading" tooltip>Core areas</li> <li class="devsite-nav-description">Get the samples and docs for the features you need.</li> <li class="devsite-nav-item"> <a href="https://developer.android.com/samples" track-type="nav" track-metadata-eventdetail="https://developer.android.com/samples" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="core areas" tooltip > <div class="devsite-nav-item-title"> Samples </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/quick-guides" track-type="nav" track-metadata-eventdetail="https://developer.android.com/quick-guides" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="core areas" tooltip > <div class="devsite-nav-item-title"> Try Quick Guidesᵇᵉᵗᵃ </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/develop/ui" track-type="nav" track-metadata-eventdetail="https://developer.android.com/develop/ui" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="core areas" tooltip > <div class="devsite-nav-item-title"> User interfaces </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/guide/topics/permissions/overview" track-type="nav" track-metadata-eventdetail="https://developer.android.com/guide/topics/permissions/overview" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="core areas" tooltip > <div class="devsite-nav-item-title"> Permissions </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/develop/background-work" track-type="nav" track-metadata-eventdetail="https://developer.android.com/develop/background-work" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="core areas" tooltip > <div class="devsite-nav-item-title"> Background work </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/guide/topics/data" track-type="nav" track-metadata-eventdetail="https://developer.android.com/guide/topics/data" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="core areas" tooltip > <div class="devsite-nav-item-title"> Data and files </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/develop#core-areas" track-type="nav" track-metadata-eventdetail="https://developer.android.com/develop#core-areas" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="core areas" tooltip > <div class="devsite-nav-item-title"> All core areas ⤵️ </div> </a> </li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-tools-2"> <li class="devsite-nav-title" role="heading" tooltip>Tools and workflow</li> <li class="devsite-nav-description">Use the IDE to write and build your app, or create your own pipeline.</li> <li class="devsite-nav-item"> <a href="https://developer.android.com/studio/write" track-type="nav" track-metadata-eventdetail="https://developer.android.com/studio/write" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="tools and workflow" tooltip > <div class="devsite-nav-item-title"> Write and debug code </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/build/gradle-build-overview" track-type="nav" track-metadata-eventdetail="https://developer.android.com/build/gradle-build-overview" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="tools and workflow" tooltip > <div class="devsite-nav-item-title"> Build projects </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/training/testing" track-type="nav" track-metadata-eventdetail="https://developer.android.com/training/testing" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="tools and workflow" tooltip > <div class="devsite-nav-item-title"> Test your app </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/topic/performance/overview" track-type="nav" track-metadata-eventdetail="https://developer.android.com/topic/performance/overview" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="tools and workflow" tooltip > <div class="devsite-nav-item-title"> Performance </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/tools" track-type="nav" track-metadata-eventdetail="https://developer.android.com/tools" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="tools and workflow" tooltip > <div class="devsite-nav-item-title"> Command-line tools </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/reference/tools/gradle-api" track-type="nav" track-metadata-eventdetail="https://developer.android.com/reference/tools/gradle-api" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="tools and workflow" tooltip > <div class="devsite-nav-item-title"> Gradle plugin API </div> </a> </li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-multiple-screens"> <li class="devsite-nav-title" role="heading" tooltip>Device tech</li> <li class="devsite-nav-description">Write code for form factors. Connect devices and share data.</li> <li class="devsite-nav-item"> <a href="https://developer.android.com/guide/topics/large-screens/get-started-with-large-screens" track-type="nav" track-metadata-eventdetail="https://developer.android.com/guide/topics/large-screens/get-started-with-large-screens" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="device tech" tooltip > <div class="devsite-nav-item-title"> Large screens (e.g., tablets) </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/training/wearables" track-type="nav" track-metadata-eventdetail="https://developer.android.com/training/wearables" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="device tech" tooltip > <div class="devsite-nav-item-title"> Wear OS </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/health-and-fitness/guides" track-type="nav" track-metadata-eventdetail="https://developer.android.com/health-and-fitness/guides" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="device tech" tooltip > <div class="devsite-nav-item-title"> Android Health </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/guide/topics/connectivity/cross-device-sdk/overview" track-type="nav" track-metadata-eventdetail="https://developer.android.com/guide/topics/connectivity/cross-device-sdk/overview" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="device tech" tooltip > <div class="devsite-nav-item-title"> Cross-device SDK </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/training/cars" track-type="nav" track-metadata-eventdetail="https://developer.android.com/training/cars" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="device tech" tooltip > <div class="devsite-nav-item-title"> Android for Cars </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/training/tv" track-type="nav" track-metadata-eventdetail="https://developer.android.com/training/tv" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="device tech" tooltip > <div class="devsite-nav-item-title"> Android TV </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/chrome-os/intro" track-type="nav" track-metadata-eventdetail="https://developer.android.com/chrome-os/intro" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="device tech" tooltip > <div class="devsite-nav-item-title"> ChromeOS </div> </a> </li> </ul> </div> <div class="devsite-tabs-dropdown-column android-dropdown"> <ul class="devsite-tabs-dropdown-section android-dropdown-section-icon android-dropdown-section-icon-core-library"> <li class="devsite-nav-title" role="heading" tooltip>Libraries</li> <li class="devsite-nav-description">Browse API reference documentation with all the details.</li> <li class="devsite-nav-item"> <a href="https://developer.android.com/reference/packages" track-type="nav" track-metadata-eventdetail="https://developer.android.com/reference/packages" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="libraries" tooltip > <div class="devsite-nav-item-title"> Android platform </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/jetpack/androidx/explorer" track-type="nav" track-metadata-eventdetail="https://developer.android.com/jetpack/androidx/explorer" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="libraries" tooltip > <div class="devsite-nav-item-title"> Jetpack libraries </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developer.android.com/jetpack/androidx/releases/compose" track-type="nav" track-metadata-eventdetail="https://developer.android.com/jetpack/androidx/releases/compose" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="libraries" tooltip > <div class="devsite-nav-item-title"> Compose libraries </div> </a> </li> <li class="devsite-nav-item"> <a href="https://developers.google.com/android/reference/packages" track-type="nav" track-metadata-eventdetail="https://developers.google.com/android/reference/packages" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="libraries" tooltip > <div class="devsite-nav-item-title"> Google Play services ↗️ </div> </a> </li> <li class="devsite-nav-item"> <a href="https://play.google.com/sdks" track-type="nav" track-metadata-eventdetail="https://play.google.com/sdks" track-metadata-position="nav - develop" track-metadata-module="tertiary nav" track-metadata-module_headline="libraries" tooltip > <div class="devsite-nav-item-title"> Google Play SDK index ↗️ </div> </a> </li> </ul> </div> </div> </div> </tab> <tab > <a href="https://developer.android.com/distribute" track-metadata-eventdetail="https://developer.android.com/distribute" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - google play" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Google Play" track-name="google play" > Google Play </a> </tab> <tab > <a href="https://developer.android.com/community" track-metadata-eventdetail="https://developer.android.com/community" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - community" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Community" track-name="community" > Community </a> </tab> </nav> </devsite-tabs> </div> <devsite-search enable-signin enable-search enable-suggestions enable-query-completion project-name="Android Studio" tenant-name="Android Developers" > <form class="devsite-search-form" action="https://developer.android.com/s/results" method="GET"> <div class="devsite-search-container"> <button type="button" search-open class="devsite-search-button devsite-header-icon-button button-flat material-icons" aria-label="Open search"></button> <div class="devsite-searchbox"> <input aria-activedescendant="" aria-autocomplete="list" aria-label="Search" aria-expanded="false" aria-haspopup="listbox" autocomplete="off" class="devsite-search-field devsite-search-query" name="q" placeholder="Search" role="combobox" type="text" value="" > <div class="devsite-search-image material-icons" aria-hidden="true"> </div> <div class="devsite-search-shortcut-icon-container" aria-hidden="true"> <kbd class="devsite-search-shortcut-icon">/</kbd> </div> </div> </div> </form> <button type="button" search-close class="devsite-search-button devsite-header-icon-button button-flat material-icons" aria-label="Close search"></button> </devsite-search> </div> <devsite-appearance-selector></devsite-appearance-selector> <devsite-language-selector> <ul role="presentation"> <li role="presentation"> <a role="menuitem" lang="en" >English</a> </li> <li role="presentation"> <a role="menuitem" lang="de" >Deutsch</a> </li> <li role="presentation"> <a role="menuitem" lang="es_419" >Español – América Latina</a> </li> <li role="presentation"> <a role="menuitem" lang="fr" >Français</a> </li> <li role="presentation"> <a role="menuitem" lang="id" >Indonesia</a> </li> <li role="presentation"> <a role="menuitem" lang="it" >Italiano</a> </li> <li role="presentation"> <a role="menuitem" lang="pl" >Polski</a> </li> <li role="presentation"> <a role="menuitem" lang="pt_br" >Português – Brasil</a> </li> <li role="presentation"> <a role="menuitem" lang="vi" >Tiếng Việt</a> </li> <li role="presentation"> <a role="menuitem" lang="tr" >Türkçe</a> </li> <li role="presentation"> <a role="menuitem" lang="ru" >Русский</a> </li> <li role="presentation"> <a role="menuitem" lang="he" >עברית</a> </li> <li role="presentation"> <a role="menuitem" lang="ar" >العربيّة</a> </li> <li role="presentation"> <a role="menuitem" lang="fa" >فارسی</a> </li> <li role="presentation"> <a role="menuitem" lang="hi" >हिंदी</a> </li> <li role="presentation"> <a role="menuitem" lang="bn" >বাংলা</a> </li> <li role="presentation"> <a role="menuitem" lang="th" >ภาษาไทย</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_cn" >中文 – 简体</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_tw" >中文 – 繁體</a> </li> <li role="presentation"> <a role="menuitem" lang="ja" >日本語</a> </li> <li role="presentation"> <a role="menuitem" lang="ko" >한국어</a> </li> </ul> </devsite-language-selector> <a class="devsite-header-link devsite-top-button button gc-analytics-event" href="https://developer.android.com/studio" data-category="Site-Wide Custom Events" data-label="Site header link" > Android Studio </a> <devsite-user enable-profiles id="devsite-user"> <span class="button devsite-top-button" aria-hidden="true" visually-hidden>Sign in</span> </devsite-user> </div> </div> </div> <div class="devsite-collapsible-section "> <div class="devsite-header-background"> <div class="devsite-product-id-row" > <div class="devsite-product-description-row"> <ul class="devsite-breadcrumb-list" > <li class="devsite-breadcrumb-item "> <a href="https://developer.android.com/studio" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Lower Header" data-value="1" track-type="globalNav" track-name="breadcrumb" track-metadata-position="1" track-metadata-eventdetail="Android Studio" > Android Studio </a> </li> </ul> </div> </div> <div class="devsite-doc-set-nav-row"> <devsite-tabs class="lower-tabs"> <nav class="devsite-tabs-wrapper" aria-label="Lower tabs"> <tab > <a href="https://developer.android.com/studio" track-metadata-eventdetail="https://developer.android.com/studio" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - download" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Download" track-name="download" > Download </a> </tab> <tab > <a href="https://developer.android.com/studio/intro" track-metadata-eventdetail="https://developer.android.com/studio/intro" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - android studio editor" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Android Studio editor" track-name="android studio editor" > Android Studio editor </a> </tab> <tab > <a href="https://developer.android.com/gemini-in-android" track-metadata-eventdetail="https://developer.android.com/gemini-in-android" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - gemini in android studio" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Gemini in Android Studio" track-name="gemini in android studio" > Gemini in Android Studio </a> </tab> <tab class="devsite-active"> <a href="https://developer.android.com/build/gradle-build-overview" track-metadata-eventdetail="https://developer.android.com/build/gradle-build-overview" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - android gradle plugin" track-metadata-module="primary nav" aria-label="Android Gradle Plugin, selected" data-category="Site-Wide Custom Events" data-label="Tab: Android Gradle Plugin" track-name="android gradle plugin" > Android Gradle Plugin </a> </tab> <tab > <a href="https://developer.android.com/tools" track-metadata-eventdetail="https://developer.android.com/tools" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - sdk tools" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: SDK tools" track-name="sdk tools" > SDK tools </a> </tab> <tab > <a href="https://developer.android.com/studio/preview" track-metadata-eventdetail="https://developer.android.com/studio/preview" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - preview" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Preview" track-name="preview" > Preview </a> </tab> </nav> </devsite-tabs> </div> </div> </div> </div> </devsite-header> <devsite-book-nav scrollbars > <div class="devsite-book-nav-filter" > <span class="filter-list-icon material-icons" aria-hidden="true"></span> <input type="text" placeholder="Filter" aria-label="Type to filter" role="searchbox"> <span class="filter-clear-button hidden" data-title="Clear filter" aria-label="Clear filter" role="button" tabindex="0"></span> </div> <nav class="devsite-book-nav devsite-nav nocontent" aria-label="Side menu"> <div class="devsite-mobile-header"> <button type="button" id="devsite-close-nav" class="devsite-header-icon-button button-flat material-icons gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Close navigation" aria-label="Close navigation"> </button> <div class="devsite-product-name-wrapper"> <a href="/" class="devsite-site-logo-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Site logo" track-type="globalNav" track-name="androidDevelopers" track-metadata-position="nav" track-metadata-eventDetail="nav"> <picture> <source srcset="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/lockup-dark-theme.svg" media="(prefers-color-scheme: dark)" class="devsite-dark-theme" alt="Android Developers"> <img src="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/lockup.svg" class="devsite-site-logo" alt="Android Developers"> </picture> </a> <span class="devsite-product-name"> <ul class="devsite-breadcrumb-list" > <li class="devsite-breadcrumb-item "> </li> </ul> </span> </div> </div> <div class="devsite-book-nav-wrapper"> <div class="devsite-mobile-nav-top"> <ul class="devsite-nav-list"> <li class="devsite-nav-item"> <a href="/get-started" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Essentials" track-name="essentials" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Essentials" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Essentials </span> </a> <ul class="devsite-nav-responsive-tabs devsite-nav-has-menu "> <li class="devsite-nav-item"> <span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: Essentials" track-name="essentials" > <span class="devsite-nav-text" tooltip menu="Essentials"> More </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="Essentials"> </span> </span> </li> </ul> </li> <li class="devsite-nav-item"> <a href="/design" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Design & Plan" track-name="design & plan" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Design & Plan" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Design & Plan </span> </a> <ul class="devsite-nav-responsive-tabs devsite-nav-has-menu "> <li class="devsite-nav-item"> <span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: Design & Plan" track-name="design & plan" > <span class="devsite-nav-text" tooltip menu="Design & Plan"> More </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="Design & Plan"> </span> </span> </li> </ul> </li> <li class="devsite-nav-item"> <a href="/develop" class="devsite-nav-title gc-analytics-event devsite-nav-active" data-category="Site-Wide Custom Events" data-label="Tab: Develop" track-name="develop" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Develop" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Develop </span> </a> <ul class="devsite-nav-responsive-tabs devsite-nav-has-menu "> <li class="devsite-nav-item"> <span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: Develop" track-name="develop" > <span class="devsite-nav-text" tooltip menu="Develop"> More </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="Develop"> </span> </span> </li> </ul> <ul class="devsite-nav-responsive-tabs"> <li class="devsite-nav-item"> <a href="/studio" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Download" track-name="download" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Download" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Download </span> </a> </li> <li class="devsite-nav-item"> <a href="/studio/intro" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: Android Studio editor" track-name="android studio editor" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android Studio editor" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Android Studio editor </span> <span class="devsite-nav-icon material-icons" data-icon="forward" > </span> </a> </li> <li class="devsite-nav-item"> <a href="/gemini-in-android" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Gemini in Android Studio" track-name="gemini in android studio" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Gemini in Android Studio" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Gemini in Android Studio </span> </a> </li> <li class="devsite-nav-item"> <a href="/build/gradle-build-overview" class="devsite-nav-title gc-analytics-event devsite-nav-has-children devsite-nav-active" data-category="Site-Wide Custom Events" data-label="Tab: Android Gradle Plugin" track-name="android gradle plugin" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android Gradle Plugin" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip menu="_book"> Android Gradle Plugin </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="_book"> </span> </a> </li> <li class="devsite-nav-item"> <a href="/tools" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: SDK tools" track-name="sdk tools" data-category="Site-Wide Custom Events" data-label="Responsive Tab: SDK tools" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > SDK tools </span> <span class="devsite-nav-icon material-icons" data-icon="forward" > </span> </a> </li> <li class="devsite-nav-item"> <a href="/studio/preview" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: Preview" track-name="preview" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Preview" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Preview </span> <span class="devsite-nav-icon material-icons" data-icon="forward" > </span> </a> </li> </ul> </li> <li class="devsite-nav-item"> <a href="/distribute" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Google Play" track-name="google play" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Google Play" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Google Play </span> </a> </li> <li class="devsite-nav-item"> <a href="/community" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Community" track-name="community" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Community" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Community </span> </a> </li> <li class="devsite-nav-item"> <a href="/studio" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android Studio" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Android Studio </span> </a> </li> </ul> </div> <div class="devsite-mobile-nav-bottom"> <ul class="devsite-nav-list" menu="_book"> <li class="devsite-nav-item devsite-nav-expandable devsite-nav-accordion"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>What's new in Android build</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/build/releases/gradle-plugin" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/releases/gradle-plugin" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/releases/gradle-plugin" ><span class="devsite-nav-text" tooltip>Android Gradle Plugin 8.7 release notes</span></a></li><li class="devsite-nav-item"><a href="/build/releases/gradle-plugin-roadmap" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/releases/gradle-plugin-roadmap" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/releases/gradle-plugin-roadmap" ><span class="devsite-nav-text" tooltip>Android Gradle Plugin roadmap</span></a></li><li class="devsite-nav-item"><a href="/build/releases/gradle-plugin-api-updates" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/releases/gradle-plugin-api-updates" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/releases/gradle-plugin-api-updates" ><span class="devsite-nav-text" tooltip>Android Gradle plugin API updates</span></a></li><li class="devsite-nav-item"><a href="/build/releases/past-releases" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/releases/past-releases" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/releases/past-releases" ><span class="devsite-nav-text" tooltip>Past Android Gradle Plugin releases</span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-expandable devsite-nav-accordion"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Android build overview</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/build/gradle-build-overview" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/gradle-build-overview" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/gradle-build-overview" ><span class="devsite-nav-text" tooltip>Gradle build overview</span></a></li><li class="devsite-nav-item"><a href="/build/android-build-structure" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/android-build-structure" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/android-build-structure" ><span class="devsite-nav-text" tooltip>Android build structure</span></a></li><li class="devsite-nav-item"><a href="/build/tool-and-library-dependencies" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/tool-and-library-dependencies" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/tool-and-library-dependencies" ><span class="devsite-nav-text" tooltip>Tool and library interdependencies</span></a></li><li class="devsite-nav-item"><a href="/build/gradle-dependency-resolution" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/gradle-dependency-resolution" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/gradle-dependency-resolution" ><span class="devsite-nav-text" tooltip>Gradle dependency resolution</span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-expandable devsite-nav-accordion"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Manage your build</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/build" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build" ><span class="devsite-nav-text" tooltip>Configure the Android build system</span></a></li><li class="devsite-nav-item"><a href="/build/annotation-processors" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/annotation-processors" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/annotation-processors" ><span class="devsite-nav-text" tooltip>Add annotation processors</span></a></li><li class="devsite-nav-item"><a href="/build/jdks" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/jdks" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/jdks" ><span class="devsite-nav-text" tooltip>Java versions in Android builds</span></a></li><li class="devsite-nav-item"><a href="/build/configure-app-module" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/configure-app-module" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/configure-app-module" ><span class="devsite-nav-text" tooltip>Configure the app module</span></a></li><li class="devsite-nav-item"><a href="/build/manage-manifests" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/manage-manifests" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/manage-manifests" ><span class="devsite-nav-text" tooltip>Manage manifest files</span></a></li><li class="devsite-nav-item"><a href="/build/custom-build-logic" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/custom-build-logic" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/custom-build-logic" ><span class="devsite-nav-text" tooltip>Apply custom build logic</span></a></li><li class="devsite-nav-item"><a href="/build/build-variants" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/build-variants" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/build-variants" ><span class="devsite-nav-text" tooltip>Configure build variants</span></a></li><li class="devsite-nav-item"><a href="/build/agp-upgrade-assistant" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/agp-upgrade-assistant" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/agp-upgrade-assistant" ><span class="devsite-nav-text" tooltip>Use the Android Gradle plugin Upgrade Assistant</span></a></li><li class="devsite-nav-item"><a href="/build/sdk-upgrade-assistant" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/sdk-upgrade-assistant" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/sdk-upgrade-assistant" ><span class="devsite-nav-text" tooltip>Use the Android SDK Upgrade Assistant</span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-expandable devsite-nav-accordion"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Manage dependencies</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/build/dependencies" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/dependencies" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/dependencies" ><span class="devsite-nav-text" tooltip>Add build dependencies</span></a></li><li class="devsite-nav-item"><a href="/build/native-dependencies" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/native-dependencies" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/native-dependencies" ><span class="devsite-nav-text" tooltip>Add native dependencies</span></a></li><li class="devsite-nav-item"><a href="/build/remote-repositories" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/remote-repositories" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/remote-repositories" ><span class="devsite-nav-text" tooltip>Manage remote repositories</span></a></li><li class="devsite-nav-item"><a href="/build/version-upgrade-strategies" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/version-upgrade-strategies" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/version-upgrade-strategies" ><span class="devsite-nav-text" tooltip>Upgrade build dependencies</span></a></li><li class="devsite-nav-item"><a href="/build/dependency-upgrade-tools" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/dependency-upgrade-tools" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/dependency-upgrade-tools" ><span class="devsite-nav-text" tooltip>Analyze and automate dependency upgrades</span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-expandable devsite-nav-accordion"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Run your build</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/build/building-cmdline" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/building-cmdline" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/building-cmdline" ><span class="devsite-nav-text" tooltip>Build your app from the command line</span></a></li><li class="devsite-nav-item"><a href="/build/build-for-release" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/build-for-release" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/build-for-release" ><span class="devsite-nav-text" tooltip>Build your app for release to users</span></a></li><li class="devsite-nav-item"><a href="/build/building-studio" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/building-studio" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/building-studio" ><span class="devsite-nav-text" tooltip>Build and run your app in Android Studio</span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-expandable devsite-nav-accordion"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Optimize your build</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/build/optimize-your-build" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/optimize-your-build" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/optimize-your-build" ><span class="devsite-nav-text" tooltip>Overview</span></a></li><li class="devsite-nav-item"><a href="/build/build-analyzer" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/build-analyzer" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/build-analyzer" ><span class="devsite-nav-text" tooltip>Troubleshoot build performance</span></a></li><li class="devsite-nav-item"><a href="/build/profile-your-build" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/profile-your-build" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/profile-your-build" ><span class="devsite-nav-text" tooltip>Profile your build</span></a></li><li class="devsite-nav-item"><a href="/build/shrink-code" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/shrink-code" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/shrink-code" ><span class="devsite-nav-text" tooltip>Shrink your app</span></a></li><li class="devsite-nav-item"><a href="/build/kotlin-support" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/kotlin-support" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/kotlin-support" ><span class="devsite-nav-text" tooltip>D8 and R8 compiler version compatibility</span></a></li><li class="devsite-nav-item"><a href="/build/multidex" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/multidex" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/multidex" ><span class="devsite-nav-text" tooltip>Enable multidex</span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-expandable devsite-nav-accordion"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Extend your build</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/build/extend-agp" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/extend-agp" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/extend-agp" ><span class="devsite-nav-text" tooltip>Write Gradle plugins</span></a></li><li class="devsite-nav-item"><a href="/build/gradle-tips" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/gradle-tips" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/gradle-tips" ><span class="devsite-nav-text" tooltip>Gradle tips and recipes</span></a></li><li class="devsite-nav-item"><a href="/build/cxx-ninja" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/cxx-ninja" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/cxx-ninja" ><span class="devsite-nav-text" tooltip>Integrate a custom C/C++ build system</span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-expandable devsite-nav-accordion"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Publish your library</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/build/publish-library" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/publish-library" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/publish-library" ><span class="devsite-nav-text" tooltip>Overview</span></a></li><li class="devsite-nav-item"><a href="/build/publish-library/prep-lib-release" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/publish-library/prep-lib-release" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/publish-library/prep-lib-release" ><span class="devsite-nav-text" tooltip>Prepare your library for release</span></a></li><li class="devsite-nav-item"><a href="/build/publish-library/configure-pub-variants" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/publish-library/configure-pub-variants" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/publish-library/configure-pub-variants" ><span class="devsite-nav-text" tooltip>Configure publication variants</span></a></li><li class="devsite-nav-item"><a href="/build/publish-library/configure-test-fixtures" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/publish-library/configure-test-fixtures" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/publish-library/configure-test-fixtures" ><span class="devsite-nav-text" tooltip>Configure test fixtures for publication</span></a></li><li class="devsite-nav-item"><a href="/build/publish-library/upload-library" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/publish-library/upload-library" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/publish-library/upload-library" ><span class="devsite-nav-text" tooltip>Upload your library</span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-expandable devsite-nav-accordion"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Migrate your build</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/build/migrate-to-kotlin-dsl" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/migrate-to-kotlin-dsl" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/migrate-to-kotlin-dsl" ><span class="devsite-nav-text" tooltip>Migrate to the Kotlin DSL</span></a></li><li class="devsite-nav-item"><a href="/build/migrate-to-catalogs" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/migrate-to-catalogs" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/migrate-to-catalogs" ><span class="devsite-nav-text" tooltip>Migrate to version catalogs</span></a></li><li class="devsite-nav-item"><a href="/build/migrate-to-ksp" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/migrate-to-ksp" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/migrate-to-ksp" ><span class="devsite-nav-text" tooltip>Migrate to Kotlin Symbol Processing</span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-expandable devsite-nav-accordion"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Troubleshoot</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/build/troubleshoot" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/troubleshoot" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/troubleshoot" ><span class="devsite-nav-text" tooltip>Overview</span></a></li><li class="devsite-nav-item"><a href="/build/dependency-resolution-errors" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /build/dependency-resolution-errors" track-type="bookNav" track-name="click" track-metadata-eventdetail="/build/dependency-resolution-errors" ><span class="devsite-nav-text" tooltip>Debug dependency resolution errors</span></a></li></ul></div></li> <li class="devsite-nav-item"><a href="/reference/tools/gradle-api" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /reference/tools/gradle-api" track-type="bookNav" track-name="click" track-metadata-eventdetail="/reference/tools/gradle-api" ><span class="devsite-nav-text" tooltip>Android Gradle plugin API reference</span></a></li> </ul> <ul class="devsite-nav-list" menu="Essentials" aria-label="Side menu" hidden> <li class="devsite-nav-item devsite-nav-heading"> <span class="devsite-nav-title" tooltip > <span class="devsite-nav-text" tooltip > Gemini in Android Studio </span> </span> </li> <li class="devsite-nav-item"> <a href="/gemini-in-android" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Learn more" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Learn more </span> </a> </li> <li class="devsite-nav-item"> <a href="/studio" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Get Android Studio" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Get Android Studio </span> </a> </li> <li class="devsite-nav-item devsite-nav-heading"> <span class="devsite-nav-title" tooltip > <span class="devsite-nav-text" tooltip > Get started </span> </span> </li> <li class="devsite-nav-item"> <a href="/get-started/overview" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Hello world" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Hello world </span> </a> </li> <li class="devsite-nav-item"> <a href="/courses" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Training courses" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Training courses </span> </a> </li> <li class="devsite-nav-item"> <a href="/get-started/codelabs" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Tutorials" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Tutorials </span> </a> </li> <li class="devsite-nav-item"> <a href="/kotlin" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Kotlin for Android" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Kotlin for Android </span> </a> </li> <li class="devsite-nav-item"> <a href="https://play.google.com/console/about/guides/monetize/" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Monetization with Play ↗️" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Monetization with Play ↗️ </span> </a> </li> <li class="devsite-nav-item devsite-nav-heading"> <span class="devsite-nav-title" tooltip > <span class="devsite-nav-text" tooltip > Extend by device </span> </span> </li> <li class="devsite-nav-item"> <a href="/adaptive-apps" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Adaptive apps" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Adaptive apps </span> </a> </li> <li class="devsite-nav-item"> <a href="/wear" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Wear OS" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Wear OS </span> </a> </li> <li class="devsite-nav-item"> <a href="/cars" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android for Cars" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Android for Cars </span> </a> </li> <li class="devsite-nav-item"> <a href="/tv" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android TV" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Android TV </span> </a> </li> <li class="devsite-nav-item"> <a href="/chrome-os" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: ChromeOS" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > ChromeOS </span> </a> </li> <li class="devsite-nav-item"> <a href="/multi-device-development" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Cross-device SDK" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Cross-device SDK </span> </a> </li> <li class="devsite-nav-item devsite-nav-heading"> <span class="devsite-nav-title" tooltip > <span class="devsite-nav-text" tooltip > Build by category </span> </span> </li> <li class="devsite-nav-item"> <a href="/games" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Games" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Games </span> </a> </li> <li class="devsite-nav-item"> <a href="/media" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Camera & Media" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Camera & Media </span> </a> </li> <li class="devsite-nav-item"> <a href="/social-and-messaging" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Social & messaging" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Social & messaging </span> </a> </li> <li class="devsite-nav-item"> <a href="/health-and-fitness" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Health & Fitness" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Health & Fitness </span> </a> </li> <li class="devsite-nav-item"> <a href="/productivity" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Productivity" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Productivity </span> </a> </li> <li class="devsite-nav-item"> <a href="/work/overview" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Enterprise apps" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Enterprise apps </span> </a> </li> <li class="devsite-nav-item devsite-nav-heading"> <span class="devsite-nav-title" tooltip > <span class="devsite-nav-text" tooltip > Get the latest </span> </span> </li> <li class="devsite-nav-item"> <a href="/latest-updates" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Latest updates" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Latest updates </span> </a> </li> <li class="devsite-nav-item"> <a href="/latest-updates/experimental" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Experimental updates" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Experimental updates </span> </a> </li> <li class="devsite-nav-item"> <a href="/studio/preview" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android Studio preview" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Android Studio preview </span> </a> </li> <li class="devsite-nav-item"> <a href="/jetpack/androidx/versions" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Jetpack & Compose libraries" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Jetpack & Compose libraries </span> </a> </li> <li class="devsite-nav-item"> <a href="/training/wearables/versions/4" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Wear OS preview" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Wear OS preview </span> </a> </li> <li class="devsite-nav-item"> <a href="/design-for-safety/privacy-sandbox" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Privacy Sandbox" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Privacy Sandbox </span> </a> </li> </ul> <ul class="devsite-nav-list" menu="Design & Plan" aria-label="Side menu" hidden> <li class="devsite-nav-item devsite-nav-heading"> <span class="devsite-nav-title" tooltip > <span class="devsite-nav-text" tooltip > UI Design </span> </span> </li> <li class="devsite-nav-item"> <a href="/design/ui" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Design for Android" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Design for Android </span> </a> </li> <li class="devsite-nav-item"> <a href="/design/ui/mobile" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Mobile" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Mobile </span> </a> </li> <li class="devsite-nav-item"> <a href="/design/ui/large-screens" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Large screens (e.g., tablets)" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Large screens (e.g., tablets) </span> </a> </li> <li class="devsite-nav-item"> <a href="/design/ui/widget" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Widgets" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Widgets </span> </a> </li> <li class="devsite-nav-item"> <a href="/design/ui/wear" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Wear OS" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Wear OS </span> </a> </li> <li class="devsite-nav-item"> <a href="/design/ui/tv" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android TV" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Android TV </span> </a> </li> <li class="devsite-nav-item devsite-nav-heading"> <span class="devsite-nav-title" tooltip > <span class="devsite-nav-text" tooltip > Architecture </span> </span> </li> <li class="devsite-nav-item"> <a href="/topic/architecture/intro" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Introduction" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Introduction </span> </a> </li> <li class="devsite-nav-item"> <a href="/topic/libraries/view-binding" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Libraries" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Libraries </span> </a> </li> <li class="devsite-nav-item"> <a href="/guide/navigation/navigation-principles" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Navigation" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Navigation </span> </a> </li> <li class="devsite-nav-item"> <a href="/topic/modularization" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Modularization" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Modularization </span> </a> </li> <li class="devsite-nav-item"> <a href="/training/testing/fundamentals" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Testing" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Testing </span> </a> </li> <li class="devsite-nav-item devsite-nav-heading"> <span class="devsite-nav-title" tooltip > <span class="devsite-nav-text" tooltip > Quality </span> </span> </li> <li class="devsite-nav-item"> <a href="/quality" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Overview" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Overview </span> </a> </li> <li class="devsite-nav-item"> <a href="/quality/core-value" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Core value" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Core value </span> </a> </li> <li class="devsite-nav-item"> <a href="/quality/user-experience" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: User experience" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > User experience </span> </a> </li> <li class="devsite-nav-item"> <a href="/quality/technical" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Technical quality" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Technical quality </span> </a> </li> <li class="devsite-nav-item"> <a href="/quality/privacy-and-security" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Security" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Security </span> </a> </li> <li class="devsite-nav-item devsite-nav-heading"> <span class="devsite-nav-title" tooltip > <span class="devsite-nav-text" tooltip > Security </span> </span> </li> <li class="devsite-nav-item"> <a href="/security" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Overview" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Overview </span> </a> </li> <li class="devsite-nav-item"> <a href="/privacy-and-security/about" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Privacy" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Privacy </span> </a> </li> <li class="devsite-nav-item"> <a href="/identity" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Identity" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Identity </span> </a> </li> <li class="devsite-nav-item"> <a href="/security/fraud-prevention" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Fraud prevention" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Fraud prevention </span> </a> </li> <li class="devsite-nav-item devsite-nav-heading"> <span class="devsite-nav-title" tooltip > <span class="devsite-nav-text" tooltip > Build for Billions </span> </span> </li> <li class="devsite-nav-item"> <a href="/build-for-billions" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Overview" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Overview </span> </a> </li> <li class="devsite-nav-item"> <a href="/docs/quality-guidelines/build-for-billions" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: About new markets" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > About new markets </span> </a> </li> <li class="devsite-nav-item"> <a href="/guide/topics/androidgo" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android (Go edition)" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Android (Go edition) </span> </a> </li> </ul> <ul class="devsite-nav-list" menu="Develop" aria-label="Side menu" hidden> <li class="devsite-nav-item devsite-nav-heading"> <span class="devsite-nav-title" tooltip > <span class="devsite-nav-text" tooltip > Build AI experiences </span> </span> </li> <li class="devsite-nav-item"> <a href="/ai" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Get started" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Get started </span> </a> </li> <li class="devsite-nav-item devsite-nav-heading"> <span class="devsite-nav-title" tooltip > <span class="devsite-nav-text" tooltip > Core areas </span> </span> </li> <li class="devsite-nav-item"> <a href="/samples" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Samples" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Samples </span> </a> </li> <li class="devsite-nav-item"> <a href="/quick-guides" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Try Quick Guidesᵇᵉᵗᵃ" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Try Quick Guidesᵇᵉᵗᵃ </span> </a> </li> <li class="devsite-nav-item"> <a href="/develop/ui" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: User interfaces" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > User interfaces </span> </a> </li> <li class="devsite-nav-item"> <a href="/guide/topics/permissions/overview" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Permissions" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Permissions </span> </a> </li> <li class="devsite-nav-item"> <a href="/develop/background-work" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Background work" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Background work </span> </a> </li> <li class="devsite-nav-item"> <a href="/guide/topics/data" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Data and files" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Data and files </span> </a> </li> <li class="devsite-nav-item"> <a href="/develop#core-areas" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: All core areas ⤵️" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > All core areas ⤵️ </span> </a> </li> <li class="devsite-nav-item devsite-nav-heading"> <span class="devsite-nav-title" tooltip > <span class="devsite-nav-text" tooltip > Tools and workflow </span> </span> </li> <li class="devsite-nav-item"> <a href="/studio/write" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Write and debug code" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Write and debug code </span> </a> </li> <li class="devsite-nav-item"> <a href="/build/gradle-build-overview" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Build projects" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Build projects </span> </a> </li> <li class="devsite-nav-item"> <a href="/training/testing" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Test your app" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Test your app </span> </a> </li> <li class="devsite-nav-item"> <a href="/topic/performance/overview" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Performance" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Performance </span> </a> </li> <li class="devsite-nav-item"> <a href="/tools" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Command-line tools" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Command-line tools </span> </a> </li> <li class="devsite-nav-item"> <a href="/reference/tools/gradle-api" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Gradle plugin API" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Gradle plugin API </span> </a> </li> <li class="devsite-nav-item devsite-nav-heading"> <span class="devsite-nav-title" tooltip > <span class="devsite-nav-text" tooltip > Device tech </span> </span> </li> <li class="devsite-nav-item"> <a href="/guide/topics/large-screens/get-started-with-large-screens" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Large screens (e.g., tablets)" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Large screens (e.g., tablets) </span> </a> </li> <li class="devsite-nav-item"> <a href="/training/wearables" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Wear OS" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Wear OS </span> </a> </li> <li class="devsite-nav-item"> <a href="/health-and-fitness/guides" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android Health" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Android Health </span> </a> </li> <li class="devsite-nav-item"> <a href="/guide/topics/connectivity/cross-device-sdk/overview" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Cross-device SDK" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Cross-device SDK </span> </a> </li> <li class="devsite-nav-item"> <a href="/training/cars" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android for Cars" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Android for Cars </span> </a> </li> <li class="devsite-nav-item"> <a href="/training/tv" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android TV" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Android TV </span> </a> </li> <li class="devsite-nav-item"> <a href="/chrome-os/intro" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: ChromeOS" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > ChromeOS </span> </a> </li> <li class="devsite-nav-item devsite-nav-heading"> <span class="devsite-nav-title" tooltip > <span class="devsite-nav-text" tooltip > Libraries </span> </span> </li> <li class="devsite-nav-item"> <a href="/reference/packages" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Android platform" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Android platform </span> </a> </li> <li class="devsite-nav-item"> <a href="/jetpack/androidx/explorer" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Jetpack libraries" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Jetpack libraries </span> </a> </li> <li class="devsite-nav-item"> <a href="/jetpack/androidx/releases/compose" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Compose libraries" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Compose libraries </span> </a> </li> <li class="devsite-nav-item"> <a href="https://developers.google.com/android/reference/packages" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Google Play services ↗️" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Google Play services ↗️ </span> </a> </li> <li class="devsite-nav-item"> <a href="https://play.google.com/sdks" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Google Play SDK index ↗️" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Google Play SDK index ↗️ </span> </a> </li> </ul> </div> </div> </nav> </devsite-book-nav> <section id="gc-wrapper"> <main role="main" class="devsite-main-content" has-book-nav has-sidebar > <div class="devsite-sidebar"> <div class="devsite-sidebar-content"> <devsite-toc class="devsite-nav" role="navigation" aria-label="On this page" depth="2" scrollbars ></devsite-toc> <devsite-recommendations-sidebar class="nocontent devsite-nav"> </devsite-recommendations-sidebar> </div> </div> <devsite-content> <article class="devsite-article"> <div class="devsite-article-meta nocontent" role="navigation"> <ul class="devsite-breadcrumb-list" aria-label="Breadcrumb"> <li class="devsite-breadcrumb-item "> <a href="https://developer.android.com/" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="1" track-type="globalNav" track-name="breadcrumb" track-metadata-position="1" track-metadata-eventdetail="Android Developers" > Android Developers </a> </li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div> <a href="https://developer.android.com/develop" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="2" track-type="globalNav" track-name="breadcrumb" track-metadata-position="2" track-metadata-eventdetail="" > Develop </a> </li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div> <a href="https://developer.android.com/studio" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="3" track-type="globalNav" track-name="breadcrumb" track-metadata-position="3" track-metadata-eventdetail="Android Studio" > Android Studio </a> </li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div> <a href="https://developer.android.com/build/gradle-build-overview" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="4" track-type="globalNav" track-name="breadcrumb" track-metadata-position="4" track-metadata-eventdetail="" > Android Gradle Plugin </a> </li> </ul> <devsite-thumb-rating position="header"> </devsite-thumb-rating> </div> <h1 class="devsite-page-title" tabindex="-1"> Shrink, obfuscate, and optimize your app </h1> <devsite-feature-tooltip ack-key="AckCollectionsBookmarkTooltipDismiss" analytics-category="Site-Wide Custom Events" analytics-action-show="Callout Profile displayed" analytics-action-close="Callout Profile dismissed" analytics-label="Create Collection Callout" class="devsite-page-bookmark-tooltip nocontent" dismiss-button="true" id="devsite-collections-dropdown" dismiss-button-text="Dismiss" close-button-text="Got it"> <devsite-bookmark></devsite-bookmark> <span slot="popout-heading"> Stay organized with collections </span> <span slot="popout-contents"> Save and categorize content based on your preferences. </span> </devsite-feature-tooltip> <div class="devsite-page-title-meta"><devsite-view-release-notes></devsite-view-release-notes></div> <devsite-toc class="devsite-nav" depth="2" devsite-toc-embedded > </devsite-toc> <devsite-recommendations-dropdown class="nocontent"></devsite-recommendations-dropdown> <div class="devsite-article-body clearfix "> <p>To make your app as small and fast as possible, you should optimize and minify your release build with <code translate="no" dir="ltr">isMinifyEnabled = true</code>.</p> <p>Doing so enables <em>shrinking</em>, which removes unused code; <em>obfuscation</em>, which shortens the names of your app’s classes and members; and <em>optimization</em>, which applies improved code optimization strategies to further reduce the size and improve the performance of your app. This page describes how R8 performs these compile-time tasks for your project and how you can customize them.</p> <p>When you build your project using <a href="/studio/releases/gradle-plugin#3-4-0">Android Gradle plugin 3.4.0</a> or higher, the plugin no longer uses ProGuard to perform compile-time code optimization. Instead, the plugin works with the <em>R8 compiler</em> to handle the following compile-time tasks:</p> <ul> <li><strong>Code shrinking (or tree-shaking):</strong> detects and safely removes unused classes, fields, methods, and attributes from your app and its library dependencies (making it a valuable tool for working around the <a href="/studio/build/multidex">64k reference limit</a>). For example, if you use only a few APIs of a library dependency, shrinking can identify library code that your app is <em>not</em> using and remove only that code from your app. To learn more, go to the section about how to <a href="#shrink-code">shrink your code</a>.</li> <li><strong>Resource shrinking:</strong> removes unused resources from your packaged app, including unused resources in your app’s library dependencies. It works in conjunction with code shrinking such that once unused code has been removed, any resources no longer referenced can be safely removed as well. To learn more, go to the section about how to <a href="#shrink-resources">shrink your resources</a>.</li> <li><strong>Optimization:</strong> inspects and rewrites your code to improve runtime performance and further reduce the size of your app’s DEX files. This improves runtime performance of code by up to 30%, drastically improving startup and frame timing. For example, if R8 detects that the <code translate="no" dir="ltr">else {}</code> branch for a given if/else statement is never taken, R8 removes the code for the <code translate="no" dir="ltr">else {}</code> branch. To learn more, go to the section about <a href="#optimization">code optimization</a>.</li> <li><strong>Obfuscation (or identifier minification):</strong> shortens the name of classes and members, which results in reduced DEX file sizes. To learn more, go to the section about how to <a href="#obfuscate">obfuscate your code</a>.</li> </ul> <p>When building the release version of your app, R8 can be configured to perform the compile-time tasks described above for you. You can also disable certain tasks or customize R8's behavior through ProGuard rules files. In fact, <strong>R8 works with all of your existing ProGuard rules files</strong>, so updating the Android Gradle plugin to use R8 should not require you to change your existing rules.</p> <h2 id="enable" data-text="Enable shrinking, obfuscation, and optimization" tabindex="-1">Enable shrinking, obfuscation, and optimization</h2> <p>When you use Android Studio 3.4 or Android Gradle plugin 3.4.0 and higher, R8 is the default compiler that converts your project’s Java bytecode into the DEX format that runs on the Android platform. However, when you create a new project using Android Studio, shrinking, obfuscation, and code optimization is not enabled by default. That’s because these compile-time optimizations increase the build time of your project and might introduce bugs if you do not sufficiently <a href="#keep-code">customize which code to keep</a>.</p> <p>So, it’s best to enable these compile-time tasks when building the final version of your app that you test prior to publishing. To enable shrinking, obfuscation, and optimization, include the following in your project-level build script.</p> <div> <div class="ds-selector-tabs"><section><h3 class="two-line-tab" tab-label="build.gradle.kts" id="kts" data-text="Kotlin" tabindex="-1">Kotlin</h3> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Kotlin"><span class="devsite-syntax-n">android</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">buildTypes</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">getByName</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"release"</span><span class="devsite-syntax-p">)</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// Enables code shrinking, obfuscation, and optimization for only</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// your project's release build type. Make sure to use a build</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// variant with `isDebuggable=false`.</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">isMinifyEnabled</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kc">true</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// Enables resource shrinking, which is performed by the</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// Android Gradle plugin.</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">isShrinkResources</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kc">true</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">proguardFiles</span><span class="devsite-syntax-p">(</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// Includes the default ProGuard rules files that are packaged with</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// the Android Gradle plugin. To learn more, go to the section about</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// R8 configuration files.</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">getDefaultProguardFile</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"proguard-android-optimize.txt"</span><span class="devsite-syntax-p">),</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// Includes a local, custom Proguard rules file</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-s">"proguard-rules.pro"</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">...</span> <span class="devsite-syntax-p">}</span></pre></devsite-code> </section><section><h3 class="two-line-tab" tab-label="build.gradle" id="groovy" data-text="Groovy" tabindex="-1">Groovy</h3> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Groovy"><span class="devsite-syntax-n">android</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">buildTypes</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">release</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// Enables code shrinking, obfuscation, and optimization for only</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// your project's release build type. Make sure to use a build</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// variant with `debuggable false`.</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">minifyEnabled</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kc">true</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// Enables resource shrinking, which is performed by the</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// Android Gradle plugin.</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">shrinkResources</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kc">true</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// Includes the default ProGuard rules files that are packaged with</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// the Android Gradle plugin. To learn more, go to the section about</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// R8 configuration files.</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">proguardFiles</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">getDefaultProguardFile</span><span class="devsite-syntax-o">(</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-s1">'proguard-android-optimize.txt'</span><span class="devsite-syntax-o">),</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-s1">'proguard-rules.pro'</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">}</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">}</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">...</span> <span class="devsite-syntax-o">}</span></pre></devsite-code> </section></div> </div> <h2 id="configuration-files" data-text="R8 configuration files" tabindex="-1">R8 configuration files</h2> <p>R8 uses ProGuard rules files to modify its default behavior and better understand your app’s structure, such as the classes that serve as entry points into your app’s code. Although you can modify some of these rules files, some rules may be generated automatically by compile-time tools, such as AAPT2, or inherited from your app’s library dependencies. The table below describes the sources of ProGuard rules files that R8 uses.</p> <table> <tr> <td>Source </td> <td>Location </td> <td>Description </td> </tr> <tr> <td>Android Studio </td> <td><code translate="no" dir="ltr"><module-dir>/proguard-rules.pro</code> </td> <td>When you create a new module using Android Studio, the IDE creates a <code translate="no" dir="ltr">proguard-rules.pro</code> file in the root directory of that module. <p> By default, this file does not apply any rules. So, include your own ProGuard rules here, such as your <a href="/studio/build/shrink-code#keep-code">custom keep rules</a>. </td> </tr> <tr> <td>Android Gradle plugin </td> <td>Generated by the Android Gradle plugin at compile time. </td> <td>The Android Gradle plugin generates <code translate="no" dir="ltr">proguard-android-optimize.txt</code>, which includes rules that are useful to most Android projects and enables <a href="/reference/androidx/annotation/Keep"><code translate="no" dir="ltr">@Keep*</code> annotations</a>. <p> By default, when creating a new module using Android Studio, the module-level build script includes this rules file in your release build for you. <p class="note"> <b>Note:</b> The Android Gradle plugin includes additional predefined ProGuard rules files, but it is recommended that you use <code translate="no" dir="ltr">proguard-android-optimize.txt</code>. </td> </tr> <tr> <td>Library dependencies </td> <td> <p> In an AAR library:<br>  <code translate="no" dir="ltr">proguard.txt</code></p> <p> In a JAR library:<br>  <code translate="no" dir="ltr">META-INF/proguard/<ProGuard-rules-file></code></p> <p> In addition to these locations, Android Gradle plugin 3.6 or higher also supports <a href="#targeted-shrink-rules">targeted shrink rules</a>.</p> </td> <td><p>If an AAR or JAR library is published with its own rules file, and you include that library as a compile-time dependency, R8 automatically applies those rules when compiling your project.</p> <p> In addition to conventional ProGuard rules, Android Gradle plugin 3.6 or higher also supports <a href="#targeted-shrink-rules">targeted shrink rules</a>. These are rules that target specific shrinkers (R8 or ProGuard), as well as specific shrinker versions.</p> <p> Using rules files that are packaged with libraries is useful if certain rules are required for the library to function properly—that is, the library developer has performed the troubleshooting steps for you.</p> <p> However, you should be aware that, because the rules are <em>additive</em>, certain rules that a library dependency includes cannot be removed and might impact the compilation of other parts of your app. For example, if a library includes a rule to disable code optimizations, that rule disables optimizations for your entire project.</p> </td> </tr> <tr> <td>Android Asset Package Tool 2 (AAPT2) </td> <td>After building your project with <code translate="no" dir="ltr">minifyEnabled true</code>: <code translate="no" dir="ltr"><module-dir>/build/intermediates/aapt_proguard_file/.../aapt_rules.txt</code> </td> <td>AAPT2 generates keep rules based on references to classes in your app’s manifest, layouts, and other app resources. For example, AAPT2 includes a keep rule for each Activity that you register in your app’s manifest as an entry point. </td> </tr> <tr> <td>Custom configuration files </td> <td>By default, when you create a new module using Android Studio, the IDE creates <code translate="no" dir="ltr"><module-dir>/proguard-rules.pro</code> for you to add your own rules. </td> <td>You can <a href="#add-configuration">include additional configurations</a>, and R8 applies them at compile-time. </td> </tr> </table> <p>When you set the <code translate="no" dir="ltr">minifyEnabled</code> property to <code translate="no" dir="ltr">true</code>, R8 combines rules from all the available sources listed above. This is important to remember when you <a href="#troubleshoot">troubleshoot with R8</a>, because other compile-time dependencies, such as library dependencies, may introduce changes to the R8 behavior that you do not know about.</p> <p>To output a full report of all the rules that R8 applies when building your project, include the following in your module’s <code translate="no" dir="ltr">proguard-rules.pro</code> file:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded><code translate="no" dir="ltr">// You can specify any path and filename. -printconfiguration ~/tmp/full-r8-config.txt </code></pre></devsite-code> <h3 id="targeted-shrink-rules" data-text="Targeted shrink rules" tabindex="-1">Targeted shrink rules</h3> <p>Android Gradle plugin 3.6 or higher supports libraries' rules that target specific shrinkers (R8 or ProGuard), as well as specific shrinker versions. This allows library developers to tailor their rules to work optimally in projects that use new shrinker versions, while allowing existing rules to continue to be used in projects with older shrinker versions.</p> <p>To specify targeted shrink rules, library developers will need to include them at specific locations inside an AAR or JAR library, as described below.</p> <p></p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded><code translate="no" dir="ltr">In an AAR library: proguard.txt (legacy location) classes.jar └── META-INF └── com.android.tools (targeted shrink rules location) ├── r8-from-<X>-upto-<Y>/<R8-rules-file> └── proguard-from-<X>-upto-<Y>/<ProGuard-rules-file> In a JAR library: META-INF ├── proguard/<ProGuard-rules-file> (legacy location) └── com.android.tools (targeted shrink rules location) ├── r8-from-<X>-upto-<Y>/<R8-rules-file> └── proguard-from-<X>-upto-<Y>/<ProGuard-rules-file> </code></pre></devsite-code> <p>That means targeted shrink rules are stored in the <code translate="no" dir="ltr">META-INF/com.android.tools</code> directory of a JAR or in the <code translate="no" dir="ltr">META-INF/com.android.tools</code> directory inside <code translate="no" dir="ltr">classes.jar</code> of an AAR.</p> <p>Under that directory, there can be multiple directories with names in the form of <code translate="no" dir="ltr">r8-from-<X>-upto-<Y></code> or <code translate="no" dir="ltr">proguard-from-<X>-upto-<Y></code> to indicate which versions of which shrinker the rules inside the directories are written for. Note that the <code translate="no" dir="ltr">-from-<X></code> and <code translate="no" dir="ltr">-upto-<Y></code> parts are optional, the <code translate="no" dir="ltr"><Y></code> version is <em>exclusive</em>, and the version ranges must be continuous.</p> <p>For example, <code translate="no" dir="ltr">r8-upto-8.0.0</code>, <code translate="no" dir="ltr">r8-from-8.0.0-upto-8.2.0</code>, and <code translate="no" dir="ltr">r8-from-8.2.0</code> form a valid set of targeted shrink rules. The rules under the <code translate="no" dir="ltr">r8-from-8.0.0-upto-8.2.0</code> directory will be used by R8 from version 8.0.0 up to but <em>not including</em> version 8.2.0.</p> <p>Given that information, Android Gradle plugin 3.6 or higher will select the rules from the matching R8 directories. If a library does not specify targeted shrink rules, the Android Gradle plugin will select the rules from the legacy locations (<code translate="no" dir="ltr">proguard.txt</code> for an AAR or <code translate="no" dir="ltr">META-INF/proguard/<ProGuard-rules-file></code> for a JAR).</p> <p>Library developers can choose to include either targeted shrink rules or legacy ProGuard rules in their libraries, or both types if they want to maintain compatibility with Android Gradle plugin older than 3.6 or other tools.</p> <h3 id="add-configuration" data-text="Include additional configurations" tabindex="-1">Include additional configurations</h3> <p>When you create a new project or module using Android Studio, the IDE creates a <code translate="no" dir="ltr"><module-dir>/proguard-rules.pro</code> file for you to include your own rules. You can also include additional rules from other files by adding them to the <code translate="no" dir="ltr">proguardFiles</code> property in your module's build script.</p> <p>For example, you can add rules that are specific to each build variant by adding another <code translate="no" dir="ltr">proguardFiles</code> property in the corresponding <code translate="no" dir="ltr">productFlavor</code> block. The following Gradle file adds <code translate="no" dir="ltr">flavor2-rules.pro</code> to the <code translate="no" dir="ltr">flavor2</code> product flavor. Now, <code translate="no" dir="ltr">flavor2</code> uses all three ProGuard rules because those from the <code translate="no" dir="ltr">release</code> block are also applied.</p> <p>Additionally, you can add the <code translate="no" dir="ltr">testProguardFiles</code> property, which specifies a list of ProGuard files that are included in the test APK only:</p> <div> <div class="ds-selector-tabs"><section><h3 class="two-line-tab" tab-label="build.gradle.kts" id="kts" data-text="Kotlin" tabindex="-1">Kotlin</h3> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Kotlin"><span class="devsite-syntax-n">android</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">...</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">buildTypes</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">getByName</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"release"</span><span class="devsite-syntax-p">)</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">isMinifyEnabled</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kc">true</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">proguardFiles</span><span class="devsite-syntax-p">(</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">getDefaultProguardFile</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"proguard-android-optimize.txt"</span><span class="devsite-syntax-p">),</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// List additional ProGuard rules for the given build type here. By default,</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// Android Studio creates and includes an empty rules file for you (located</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// at the root directory of each module).</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-s">"proguard-rules.pro"</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">testProguardFiles</span><span class="devsite-syntax-p">(</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// The proguard files listed here are included in the</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// test APK only.</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-s">"test-proguard-rules.pro"</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">flavorDimensions</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-na">add</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"version"</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">productFlavors</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">create</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"flavor1"</span><span class="devsite-syntax-p">)</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">...</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">create</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"flavor2"</span><span class="devsite-syntax-p">)</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">proguardFile</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"flavor2-rules.pro"</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-p">}</span></pre></devsite-code> </section><section><h3 class="two-line-tab" tab-label="build.gradle" id="groovy" data-text="Groovy" tabindex="-1">Groovy</h3> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Groovy"><span class="devsite-syntax-n">android</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">...</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">buildTypes</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">release</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">minifyEnabled</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kc">true</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">proguardFiles</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">getDefaultProguardFile</span><span class="devsite-syntax-o">(</span><span class="devsite-syntax-s1">'proguard-android-optimize.txt'</span><span class="devsite-syntax-o">),</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// List additional ProGuard rules for the given build type here. By default,</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// Android Studio creates and includes an empty rules file for you (located</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// at the root directory of each module).</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-s1">'proguard-rules.pro'</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">testProguardFiles</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// The proguard files listed here are included in the</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// test APK only.</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-s1">'test-proguard-rules.pro'</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">}</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">}</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">flavorDimensions</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-s2">"version"</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">productFlavors</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">flavor1</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">...</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">}</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">flavor2</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">proguardFile</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-s1">'flavor2-rules.pro'</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">}</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">}</span> <span class="devsite-syntax-o">}</span></pre></devsite-code> </section></div> </div> <h2 id="shrink-code" data-text="Shrink your code" tabindex="-1">Shrink your code</h2> <p>Code shrinking with R8 is enabled by default when you set the <code translate="no" dir="ltr">minifyEnabled</code> property to <code translate="no" dir="ltr">true</code>.</p> <p>Code shrinking (also known as tree shaking), is the process of removing code that R8 determines is not required at runtime. This process can greatly reduce your app's size if, for example, your app includes many library dependencies but utilizes only a small part of their functionality.</p> <p>To shrink your app’s code, R8 first determines all entry points into your app’s code based on the combined <a href="#configuration-files">set of configuration files</a>. These entry points include all classes that the Android platform may use to open your app’s Activities or services. Starting from each entry point, R8 inspects your app’s code to build a graph of all methods, member variables, and other classes that your app might access at runtime. Code that is not connected to that graph is considered <em>unreachable</em> and may be removed from the app.</p> <p>Figure 1 shows an app with a runtime library dependency. While inspecting the app’s code, R8 determines that methods <code translate="no" dir="ltr">foo()</code>, <code translate="no" dir="ltr">faz()</code>, and <code translate="no" dir="ltr">bar()</code> are reachable from the <code translate="no" dir="ltr">MainActivity.class</code> entry point. However, class <code translate="no" dir="ltr">OkayApi.class</code> or its method <code translate="no" dir="ltr">baz()</code> is never used by your app at runtime, and R8 removes that code when shrinking your app.</p> <p><img src="/static/studio/images/build/r8/tree-shaking.png" alt width="854"> <p class="img-caption"> <strong>Figure 1.</strong> At compile-time, R8 builds a graph based on your project's combined keep rules to determine unreachable code. </p></p> <p>R8 determines entry points through <code translate="no" dir="ltr">-keep</code> rules in the project’s <a href="#configuration-files">R8 configuration files</a>. That is, keep rules specify classes that R8 should not discard when shrinking your app, and R8 considers those classes as possible entry points into your app. The Android Gradle plugin and AAPT2 automatically generate keep rules that are required by most app projects for you, such as your app’s activities, views, and services. However, if you need to customize this default behavior with additional keep rules, read the section about how to <a href="#keep-code">customize which code to keep</a>.</p> <p>If instead you are interested only in reducing the size of your app’s resources, skip to the section about how to <a href="#shrink-resources">shrink your resources</a>.</p> <p>Note that if a library project is shrunk, an app that depends on that library includes shrunk library classes. You might need to adjust library keep rules if there are missing classes in the library APK. If you're building and publishing a library in AAR format, local JAR files that your library depends on <strong>aren't</strong> shrunk in the AAR file.</p> <h3 id="keep-code" data-text="Customize which code to keep" tabindex="-1">Customize which code to keep</h3> <p>For most situations, the default ProGuard rules file (<code translate="no" dir="ltr">proguard-android-optimize.txt</code>) is sufficient for R8 to remove only the unused code. However, some situations are difficult for R8 to analyze correctly and it might remove code your app actually needs. Some examples of when it might incorrectly remove code include:</p> <ul> <li>When your app calls a method from the Java Native Interface (JNI)</li> <li>When your app looks up code at runtime (such as with reflection)</li> </ul> <p>Testing your app should reveal any errors caused by inappropriately removed code, but you can also inspect what code was removed by <a href="#usage">generating a report of removed code</a>.</p> <p>To fix errors and force R8 to keep certain code, add a <a href="https://www.guardsquare.com/en/products/proguard/manual/usage#keepoptions"><code translate="no" dir="ltr">-keep</code></a> line in the ProGuard rules file. For example:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded><code translate="no" dir="ltr">-keep public class MyClass </code></pre></devsite-code> <p>Alternatively, you can add the <a href="/reference/androidx/annotation/Keep"><code translate="no" dir="ltr">@Keep</code></a> annotation to the code you want to keep. Adding <code translate="no" dir="ltr">@Keep</code> on a class keeps the entire class as-is. Adding it on a method or field will keep the method/field (and its name) as well as the class name intact. Note that this annotation is available only when using the <a href="/reference/androidx/annotation/package-summary">AndroidX Annotations Library</a> and when you include the ProGuard rules file that is packaged with the Android Gradle plugin, as described in the section about how to <a href="#enable">enable shrinking</a>.</p> <p>There are many considerations you should make when using the <code translate="no" dir="ltr">-keep</code> option; for more information about customizing your rules file, read the <a href="https://www.guardsquare.com/en/products/proguard/manual/usage">ProGuard Manual</a>. The <a href="https://www.guardsquare.com/en/products/proguard/manual/troubleshooting">Troubleshooting</a> section outlines other common problems you might encounter when your code gets stripped away.</p> <h2 id="strip-native-libraries" data-text="Strip native libraries" tabindex="-1">Strip native libraries</h2> <p>By default, native code libraries are stripped in release builds of your app. This stripping consists of removing the symbol table and debugging information contained in any native libraries used by your app. Stripping native code libraries results in significant size savings; however, it's impossible to diagnose crashes on the Google Play Console due to the missing information (such as class and function names).</p> <h3 id="native-crash-support" data-text="Native crash support" tabindex="-1">Native crash support</h3> <p>The Google Play Console reports native crashes under <a href="/topic/performance/vitals/crash#diagnose-crashes">Android vitals</a>. With a few steps, you can generate and upload a native debug symbols file for your app. This file enables symbolicated native crash stack traces (that include class and function names) in Android vitals to help you debug your app in production. These steps vary depending on the version of the Android Gradle plugin used in your project and the build output of your project.</p> <aside class="note"><strong>Note:</strong><span> To restore symbol names in crash reports yourself, use the <a href="/ndk/guides/ndk-stack">ndk-stack tool</a>, which comes packaged with the Android NDK.</span></aside> <h4 id="android_gradle_plugin_version_41_or_later" data-text="Android Gradle plugin version 4.1 or later" tabindex="-1">Android Gradle plugin version 4.1 or later</h4> <p>If your project builds an Android App Bundle, you can automatically include the native debug symbols file in it. To include this file in release builds, add the following to your app's <code translate="no" dir="ltr">build.gradle.kts</code> file:</p> <p><code translate="no" dir="ltr">android.buildTypes.release.ndk.debugSymbolLevel = { <var translate="no">SYMBOL_TABLE</var> | <var translate="no">FULL</var> }</code></p> <p>Select the debug symbol level from the following:</p> <ul> <li>Use <code translate="no" dir="ltr">SYMBOL_TABLE</code> to get function names in the Play Console's symbolicated stack traces. This level supports <a href="https://source.android.com/devices/tech/debug">tombstones</a>.</li> <li>Use <code translate="no" dir="ltr">FULL</code> to get function names, files, and line numbers in the Play Console's symbolicated stack traces.</li> </ul> <aside class="note"><strong>Note:</strong><span> There is a 300 MB limit for the native debug symbols file. If your debug symbols footprint is too large, use <code translate="no" dir="ltr">SYMBOL_TABLE</code> instead of <code translate="no" dir="ltr">FULL</code> to decrease the file size.</span></aside> <p>If your project builds an APK, use the <code translate="no" dir="ltr">build.gradle.kts</code> build setting shown earlier to generate the native debug symbols file separately. Manually <a href="https://support.google.com/googleplay/android-developer/answer/9848633#upload_file">upload the native debug symbols file</a> to the Google Play Console. As part of the build process, the Android Gradle plugin outputs this file in the following project location:</p> <p><code translate="no" dir="ltr">app/build/outputs/native-debug-symbols/<var translate="no">variant-name</var>/native-debug-symbols.zip</code></p> <h4 id="android_gradle_plugin_version_40_or_earlier_and_other_build_systems" data-text="Android Gradle plugin version 4.0 or earlier (and other build systems)" tabindex="-1">Android Gradle plugin version 4.0 or earlier (and other build systems)</h4> <p>As part of the build process, the Android Gradle plugin keeps a copy of the unstripped libraries in a project directory. This directory structure is similar to the following:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded><code translate="no" dir="ltr">app/build/intermediates/cmake/universal/release/obj/ ├── armeabi-v7a/ │ ├── libgameengine.so │ ├── libothercode.so │ └── libvideocodec.so ├── arm64-v8a/ │ ├── libgameengine.so │ ├── libothercode.so │ └── libvideocodec.so ├── x86/ │ ├── libgameengine.so │ ├── libothercode.so │ └── libvideocodec.so └── x86_64/ ├── libgameengine.so ├── libothercode.so └── libvideocodec.so </code></pre></devsite-code><aside class="note"><strong>Note:</strong><span> If you use a different build system, you could modify it to store unstripped libraries in a directory with the required structure.</span></aside> <ol> <li><p>Zip up the contents of this directory:</p> <div></div><devsite-code><pre class="none" translate="no" dir="ltr" is-upgraded> <code class="devsite-terminal" translate="no" dir="ltr">cd app/build/intermediates/cmake/universal/release/obj</code> <code class="devsite-terminal" translate="no" dir="ltr">zip -r symbols.zip .</code> </pre></devsite-code></li> <li><p>Manually <a href="https://support.google.com/googleplay/android-developer/answer/9848633#upload_file">upload the <code translate="no" dir="ltr">symbols.zip</code> file</a> to the Google Play Console.</p></li> </ol> <aside class="note"><strong>Note:</strong><span> There is a 300 MB limit for the debug symbols file. If your file is too big, it’s likely because your <code translate="no" dir="ltr">.so</code> files contain a symbol table (function names), and also DWARF debugging info (files names and lines of code). These are not needed to symbolicate your code. You can remove them by running the following command: <br/><code translate="no" dir="ltr">$OBJCOPY --strip-debug lib.so lib.so.sym</code> <br/>where <code translate="no" dir="ltr">$OBJCOPY</code> points to the specific version for the ABI you're stripping (for example, <code translate="no" dir="ltr">ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-objcopy</code>).</span></aside> <h2 id="shrink-resources" data-text="Shrink your resources" tabindex="-1">Shrink your resources</h2> <p>Resource shrinking works only in conjunction with code shrinking. After the code shrinker removes all unused code, the resource shrinker can identify which resources the app still uses. This is especially true when you add code libraries that include resources—you must remove unused library code so the library resources become unreferenced and, thus, removable by the resource shrinker.</p> <p>To enable resource shrinking, set the <code translate="no" dir="ltr">shrinkResources</code> property to <code translate="no" dir="ltr">true</code> in your build script (alongside <code translate="no" dir="ltr">minifyEnabled</code> for code shrinking). For example:</p> <div> <div class="ds-selector-tabs"><section><h3 class="two-line-tab" tab-label="build.gradle.kts" id="kts" data-text="Kotlin" tabindex="-1">Kotlin</h3> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Kotlin"><span class="devsite-syntax-n">android</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">...</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">buildTypes</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">getByName</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"release"</span><span class="devsite-syntax-p">)</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">isShrinkResources</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kc">true</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">isMinifyEnabled</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kc">true</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">proguardFiles</span><span class="devsite-syntax-p">(</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">getDefaultProguardFile</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"proguard-android.txt"</span><span class="devsite-syntax-p">),</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-s">"proguard-rules.pro"</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-p">}</span></pre></devsite-code> </section><section><h3 class="two-line-tab" tab-label="build.gradle" id="groovy" data-text="Groovy" tabindex="-1">Groovy</h3> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Groovy"><span class="devsite-syntax-n">android</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">...</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">buildTypes</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">release</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">shrinkResources</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kc">true</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">minifyEnabled</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kc">true</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">proguardFiles</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">getDefaultProguardFile</span><span class="devsite-syntax-o">(</span><span class="devsite-syntax-s1">'proguard-android.txt'</span><span class="devsite-syntax-o">),</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-s1">'proguard-rules.pro'</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">}</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">}</span> <span class="devsite-syntax-o">}</span></pre></devsite-code> </section></div> </div> <p>If you haven't already built your app using <code translate="no" dir="ltr">minifyEnabled</code> for code shrinking, then try that before enabling <code translate="no" dir="ltr">shrinkResources</code>, because you might need to edit your <code translate="no" dir="ltr">proguard-rules.pro</code> file to keep classes or methods that are created or invoked dynamically before you start removing resources.</p> <h3 id="keep-resources" data-text="Customize which resources to keep" tabindex="-1">Customize which resources to keep</h3> <p>If there are specific resources you wish to keep or discard, create an XML file in your project with a <code translate="no" dir="ltr"><resources></code> tag and specify each resource to keep in the <code translate="no" dir="ltr">tools:keep</code> attribute and each resource to discard in the <code translate="no" dir="ltr">tools:discard</code> attribute. Both attributes accept a comma-separated list of resource names. You can use the asterisk character as a wild card.</p> <p>For example:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="XML"><?xml<span class="devsite-syntax-w"> </span>version="1.0"<span class="devsite-syntax-w"> </span>encoding="utf-8"?> <resources<span class="devsite-syntax-w"> </span>xmlns:tools="http://schemas.android.com/tools" <span class="devsite-syntax-w"> </span>tools:keep="@layout/l_used*_c,@layout/l_used_a,@layout/l_used_b*" <span class="devsite-syntax-w"> </span>tools:discard="@layout/unused2"<span class="devsite-syntax-w"> </span>/></pre></devsite-code> <p>Save this file in your project resources, for example, at <code translate="no" dir="ltr">res/raw/my.package.keep.xml</code>. The build does not package this file into your app.</p> <p class="note"> <b>Note:</b> Make sure to use a unique name for the <code translate="no" dir="ltr">keep</code> file. When different libraries get linked together their keep rules would conflict otherwise, causing potential issues with ignored rules or unneeded kept resources.</p> <p>Specifying which resources to discard might seem silly when you could instead delete them, but this can be useful when using build variants. For example, you might put all your resources into the common project directory, then create a different <code translate="no" dir="ltr">my.package.build.variant.keep.xml</code> file for each build variant when you know that a given resource appears to be used in code (and therefore not removed by the shrinker) but you know it actually won't be used for the given build variant. It's also possible that the build tools incorrectly identified a resource as needed, which is possible because the compiler adds the resource IDs inline and then the resource analyzer might not know the difference between a genuinely referenced resource and an integer value in the code that happens to have the same value.</p> <h3 id="strict-reference-checks" data-text="Enable strict reference checks" tabindex="-1">Enable strict reference checks</h3> <p>Normally, the resource shrinker can accurately determine whether a resource is used. However, if your code makes a call to <code translate="no" dir="ltr"><a href="/reference/android/content/res/Resources#getIdentifier(java.lang.String, java.lang.String, java.lang.String)"> Resources.getIdentifier()</a></code> (or if any of your libraries do that—the <a href="/topic/libraries/support-library/features#v7-appcompat">AppCompat</a> library does), that means your code is looking up resource names based on dynamically-generated strings. When you do this, the resource shrinker behaves defensively by default and marks all resources with a matching name format as potentially used and unavailable for removal.</p> <p>For example, the following code causes all resources with the <code translate="no" dir="ltr">img_</code> prefix to be marked as used.</p> <div> <div class="ds-selector-tabs"><section><h3 id="kotlin" data-text="Kotlin" tabindex="-1">Kotlin</h3> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Kotlin"><span class="devsite-syntax-kd">val</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nv">name</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kt">String</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-na">format</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"img_%1d"</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">angle</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">+</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-m">1</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-kd">val</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nv">res</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">resources</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-na">getIdentifier</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">name</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-s">"drawable"</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">packageName</span><span class="devsite-syntax-p">)</span></pre></devsite-code> </section><section><h3 id="java" data-text="Java" tabindex="-1">Java</h3> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Java"><span class="devsite-syntax-n">String</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">name</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">String</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-na">format</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"img_%1d"</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">angle</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">+</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-mi">1</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-n">res</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">getResources</span><span class="devsite-syntax-p">().</span><span class="devsite-syntax-na">getIdentifier</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">name</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-s">"drawable"</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">getPackageName</span><span class="devsite-syntax-p">());</span></pre></devsite-code> </section></div> </div> <p>The resource shrinker also looks through all the string constants in your code, as well as various <code translate="no" dir="ltr">res/raw/</code> resources, looking for resource URLs in a format similar to <code translate="no" dir="ltr">file:///android_res/drawable//ic_plus_anim_016.png</code>. If it finds strings like this or others that look like they could be used to construct URLs like this, it doesn't remove them.</p> <p>These are examples of the safe shrinking mode that is enabled by default. You can, however, turn off this "better safe than sorry" handling, and specify that the resource shrinker keep only resources that it's certain are used. To do this, set <code translate="no" dir="ltr">shrinkMode</code> to <code translate="no" dir="ltr">strict</code> in the <code translate="no" dir="ltr">keep.xml</code> file, as follows:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="XML"><?xml<span class="devsite-syntax-w"> </span>version="1.0"<span class="devsite-syntax-w"> </span>encoding="utf-8"?> <resources<span class="devsite-syntax-w"> </span>xmlns:tools="http://schemas.android.com/tools" <span class="devsite-syntax-w"> </span>tools:shrinkMode="strict"<span class="devsite-syntax-w"> </span>/></pre></devsite-code> <p>If you do enable strict shrinking mode and your code also references resources with dynamically-generated strings, as shown above, then you must manually keep those resources using the <code translate="no" dir="ltr">tools:keep</code> attribute.</p> <h3 id="unused-alt-resources" data-text="Remove unused alternative resources" tabindex="-1">Remove unused alternative resources</h3> <p>The Gradle resource shrinker removes only resources that are not referenced by your app code, which means it will not remove <a href="/guide/topics/resources/providing-resources#AlternativeResources"> alternative resources</a> for different device configurations. If necessary, you can use the Android Gradle plugin's <code translate="no" dir="ltr">resConfigs</code> property to remove alternative resource files that your app does not need.</p> <p>For example, if you are using a library that includes language resources (such as AppCompat or Google Play Services), then your app includes all translated language strings for the messages in those libraries whether the rest of your app is translated to the same languages or not. If you'd like to keep only the languages that your app officially supports, you can specify those languages using the <code translate="no" dir="ltr">resConfig</code> property. Any resources for languages not specified are removed.</p> <p>The following snippet shows how to limit your language resources to just English and French:</p> <div> <div class="ds-selector-tabs"><section><h3 class="two-line-tab" tab-label="build.gradle.kts" id="kts" data-text="Kotlin" tabindex="-1">Kotlin</h3> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Kotlin"><span class="devsite-syntax-n">android</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">defaultConfig</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">...</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">resourceConfigurations</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-na">addAll</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">listOf</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"en"</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-s">"fr"</span><span class="devsite-syntax-p">))</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-p">}</span></pre></devsite-code> </section><section><h3 class="two-line-tab" tab-label="build.gradle" id="groovy" data-text="Groovy" tabindex="-1">Groovy</h3> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Groovy"><span class="devsite-syntax-n">android</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">defaultConfig</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">...</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">resConfigs</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-s2">"en"</span><span class="devsite-syntax-o">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-s2">"fr"</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">}</span> <span class="devsite-syntax-o">}</span></pre></devsite-code> </section></div> </div> <p>When releasing an app using the Android App Bundle format, by default only languages configured on a user's device are downloaded when installing the app. Similarly, only resources matching the device's screen density, and native libraries matching the device's ABI are included in the download. For more information refer to the <a href="/guide/app-bundle/configure-base#disable_config_apks">Android App Bundle configuration</a>.</p> <p>For legacy apps releasing with APKs (created before August 2021), you can customize which screen density or ABI resources to include in your APK by <a href="/studio/build/configure-apk-splits">building multiple APKs</a> that each target a different device configuration.</p> <h3 id="merge-resources" data-text="Merge duplicate resources" tabindex="-1">Merge duplicate resources</h3> <p>By default, Gradle also merges identically named resources, such as drawables with the same name that might be in different resource folders. This behavior is not controlled by the <code translate="no" dir="ltr">shrinkResources</code> property and cannot be disabled, because it is necessary to avoid errors when multiple resources match the name your code is looking up.</p> <p>Resource merging occurs only when two or more files share an identical resource name, type, and qualifier. Gradle selects which file it considers to be the best choice among the duplicates (based on a priority order described below) and passes only that one resource to the AAPT for distribution in the final artifact.</p> <p>Gradle looks for duplicate resources in the following locations:</p> <ul> <li>The main resources, associated with the main source set, generally located in <code translate="no" dir="ltr">src/main/res/</code>.</li> <li>The variant overlays, from the build type and build flavors.</li> <li>The library project dependencies.</li> </ul> <p>Gradle merges duplicate resources in the following cascading priority order:</p> <p>Dependencies → Main → Build flavor → Build type</p> <p>For example, if a duplicate resource appears in both your main resources and a build flavor, Gradle selects the one in the build flavor.</p> <p>If identical resources appear in the same source set, Gradle cannot merge them and emits a resource merge error. This can happen if you define multiple source sets in the <code translate="no" dir="ltr">sourceSet</code> property of your <code translate="no" dir="ltr">build.gradle.kts</code> file—for example if both <code translate="no" dir="ltr">src/main/res/</code> and <code translate="no" dir="ltr">src/main/res2/</code> contain identical resources.</p> <h2 id="obfuscate" data-text="Obfuscate your code" tabindex="-1">Obfuscate your code</h2> <p>The purpose of obfuscation is to reduce your app size by shortening the names of your app’s classes, methods, and fields. The following is an example of obfuscation using R8:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded><code translate="no" dir="ltr">androidx.appcompat.app.ActionBarDrawerToggle$DelegateProvider -> a.a.a.b: androidx.appcompat.app.AlertController -> androidx.appcompat.app.AlertController: android.content.Context mContext -> a int mListItemLayout -> O int mViewSpacingRight -> l android.widget.Button mButtonNeutral -> w int mMultiChoiceItemLayout -> M boolean mShowTitle -> P int mViewSpacingLeft -> j int mButtonPanelSideLayout -> K </code></pre></devsite-code> <p>While obfuscation does not remove code from your app, significant size savings can be seen in apps with DEX files that index many classes, methods, and fields. However, as obfuscation renames different parts of your code, certain tasks, such as inspecting stack traces, require additional tools. To understand your stacktrace after obfuscation, read the section about how to <a href="#retracing">decode an obfuscated stack trace</a>.</p> <p>Additionally, if your code relies on predictable naming for your app’s methods and classes—when using reflection, for example, you should treat those signatures as entry points and specify keep rules for them, as described in the section about how to <a href="#keep-code">customize which code to keep</a>. Those keep rules tell R8 to not only keep that code in your app’s final DEX but also retain its original naming.</p> <h3 id="decode-stack-trace" data-text="Decode an obfuscated stack trace" tabindex="-1">Decode an obfuscated stack trace</h3> <p>After R8 obfuscates your code, understanding a stack trace is difficult (if not impossible) because names of classes and methods might have been changed. To obtain the original stack trace you should <a href="#retracing">retrace the stack trace</a>.</p> <h2 id="optimization" data-text="Code optimization" tabindex="-1">Code optimization</h2> <p>In order to optimize your app even further, R8 inspects your code at a deeper level to remove more unused code or, where possible, rewrite your code to make it less verbose. The following are a few examples of such optimizations:</p> <ul> <li>If your code never takes the <code translate="no" dir="ltr">else {}</code> branch for a given if/else statement, R8 might remove the code for the <code translate="no" dir="ltr">else {}</code> branch.</li> <li>If your code calls a method in only a few places, R8 might remove the method and inline it at the few call sites.</li> <li>If R8 determines that a class has only one unique subclass, and the class itself is not instantiated (for example, an abstract base class only used by one concrete implementation class), then R8 can combine the two classes and remove a class from the app.</li> <li>To learn more, read the <a href="https://jakewharton.com/blog/">R8 optimization blog posts</a> by Jake Wharton.</li> </ul> <p>R8 does not allow you to disable or enable discrete optimizations, or modify the behavior of an optimization. In fact, R8 ignores any ProGuard rules that attempt to modify default optimizations, such as <code translate="no" dir="ltr">-optimizations</code> and <code translate="no" dir="ltr">-optimizationpasses</code>. This restriction is important because, as R8 continues to improve, maintaining a standard behavior for optimizations helps the Android Studio team easily troubleshoot and resolve any issues that you might encounter.</p> <p>Note that enabling optimization will change the stack traces for your application. For example, inlining will remove stack frames. See the section on <a href="#retracing">retracing</a> to learn how to obtain the original stack traces.</p> <h3 id="runtime-performance" data-text="Impact on runtime performance" tabindex="-1">Impact on runtime performance</h3> <p>If shrinking, obfuscation, and optimization are all enabled, R8 will improve runtime performance of code (including startup and frame time on the UI thread) by up to 30%. Disabling any of these drastically limits the set of optimizations R8 uses.</p> <p>If R8 is enabled, you should also <a href="/topic/performance/baselineprofiles/dex-layout-optimizations">create Startup Profiles</a> for even better startup performance.</p> <h3 id="full-mode" data-text="Enable improved optimizations" tabindex="-1">Enable improved optimizations</h3> <p>R8 includes a set of additional optimizations (referred to as "full mode") which makes it behave differently from ProGuard. These optimizations are enabled by default since <a href="/build/releases/past-releases/agp-8-0-0-release-notes#default-changes">Android Gradle plugin version 8.0.0</a>.</p> <p>You can disable these additional optimizations by including the following in your project's <code translate="no" dir="ltr">gradle.properties</code> file:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded><code translate="no" dir="ltr">android.enableR8.fullMode=false </code></pre></devsite-code> <p>Because the additional optimizations make R8 behave differently from ProGuard, they may require you to include additional ProGuard rules to avoid runtime issues if you're using rules designed for ProGuard. For example, say that your code references a class through the Java Reflection API. When <em>not</em> using "full mode," R8 assumes that you intend to examine and manipulate objects of that class at runtime—even if your code actually does not—and it automatically keeps the class and its static initializer.</p> <p>However, when using "full mode", R8 does not make this assumption and, if R8 asserts that your code otherwise never uses the class at runtime, it removes the class from your app’s final DEX. That is, if you want to keep the class and its static initializer, you need to include a keep rule in your rules file to do that.</p> <p>If you encounter any issues while using R8’s "full mode", refer to the <a href="https://r8.googlesource.com/r8/+/refs/heads/master/compatibility-faq.md">R8 FAQ page</a> for a possible solution. If you are unable to resolve the issue, please <a href="https://issuetracker.google.com/issues/new?component=326788&template=1025938">report a bug</a>.</p> <h2 id="retracing" data-text="Retracing stacktraces" tabindex="-1">Retracing stacktraces</h2> <p>Code processed by R8 is changed in various ways that can make stack traces harder to understand because the stack traces won't exactly correspond to the source code. This can be the case for changes to the line numbers when debugging information is not kept. It can be due to optimizations such as inlining and outlining. The largest contributor is obfuscation where even the classes and methods will change names.</p> <p>To recover the original stack trace, R8 provides the <a href="/studio/command-line/retrace">retrace</a> command-line tool, which is bundled with the <a href="/studio#cmdline-tools">command-line tools package</a>.</p> <p>To support retracing of your application's stack traces, you should ensure the build retains sufficient information to retrace with by adding the following rules to your module's <code translate="no" dir="ltr">proguard-rules.pro</code> file:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded><code translate="no" dir="ltr">-keepattributes LineNumberTable,SourceFile -renamesourcefileattribute SourceFile </code></pre></devsite-code> <p>The <code translate="no" dir="ltr">LineNumberTable</code> attribute retains positional information in methods such that those positions are printed in stack traces. The <code translate="no" dir="ltr">SourceFile</code> attribute ensures that all potential runtimes actually print the positional info. The <code translate="no" dir="ltr">-renamesourcefileattribute</code> directive sets the source file name in stack traces to just <code translate="no" dir="ltr">SourceFile</code>. The actual original source file name is not required when retracing because the mapping file contains the original source file.</p> <p>R8 creates a <code translate="no" dir="ltr">mapping.txt</code> file each time it runs, which contains the information needed to map stack traces back to the original stack traces. Android Studio saves the file in the <code translate="no" dir="ltr"><var translate="no"><module-name></var>/build/outputs/mapping/<var translate="no"><build-type></var>/</code> directory.</p> <aside class="caution"><strong>Caution:</strong><span> The <code translate="no" dir="ltr">mapping.txt</code> file studio generates is overwritten every time you build your project, so you must carefully save a copy each time you publish a new release. By retaining a copy of the <code translate="no" dir="ltr">mapping.txt</code> file for each release build, you'll be able to retrace if a user submits an obfuscated stack trace from an older version of your app.</span></aside> <p>When publishing your app on Google Play, you can upload the <code translate="no" dir="ltr">mapping.txt</code> file for each version of your app. When publishing using Android App Bundles this file is included automatically as part of the app bundle content. Then Google Play will retrace incoming stack traces from user-reported issues so you can review them in the Play Console. For more information, see the Help Center article about how to <a href="https://support.google.com/googleplay/android-developer/answer/6295281">deobfuscate crash stack traces</a>.</p> <h2 id="troubleshoot" data-text="Troubleshoot with R8" tabindex="-1">Troubleshoot with R8</h2> <p>This section describes some strategies for troubleshooting issues when enabling shrinking, obfuscation, and optimization using R8. If you do not find a solution to your issue below, also read the <a href="https://r8.googlesource.com/r8/+/refs/heads/master/compatibility-faq.md">R8 FAQ page</a> and <a href="https://www.guardsquare.com/en/products/proguard/manual/troubleshooting">ProGuard’s troubleshooting guide</a>.</p> <h3 id="usage" data-text="Generate a report of removed (or kept) code" tabindex="-1">Generate a report of removed (or kept) code</h3> <p>To help you troubleshoot certain R8 issues, it may be useful to see a report of all the code that R8 removed from your app. For each module for which you want to generate this report, add <code translate="no" dir="ltr">-printusage <output-dir>/usage.txt</code> to your custom rules file. When you <a href="#enable">enable R8</a> and build your app, R8 outputs a report with the path and file name you specified. The report of removed code looks similar to the following:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded><code translate="no" dir="ltr">androidx.drawerlayout.R$attr androidx.vectordrawable.R androidx.appcompat.app.AppCompatDelegateImpl public void setSupportActionBar(androidx.appcompat.widget.Toolbar) public boolean hasWindowFeature(int) public void setHandleNativeActionModesEnabled(boolean) android.view.ViewGroup getSubDecor() public void setLocalNightMode(int) final androidx.appcompat.app.AppCompatDelegateImpl$AutoNightModeManager getAutoNightModeManager() public final androidx.appcompat.app.ActionBarDrawerToggle$Delegate getDrawerToggleDelegate() private static final boolean DEBUG private static final java.lang.String KEY_LOCAL_NIGHT_MODE static final java.lang.String EXCEPTION_HANDLER_MESSAGE_SUFFIX ... </code></pre></devsite-code> <p>If instead you want to see a report of the entry points that R8 determines from your project’s keep rules , include <code translate="no" dir="ltr">-printseeds <output-dir>/seeds.txt</code> in your custom rules file. When you <a href="#enable">enable R8</a> and build your app, R8 outputs a report with the path and file name you specified. The report of kept entry points looks similar to the following:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded><code translate="no" dir="ltr">com.example.myapplication.MainActivity androidx.appcompat.R$layout: int abc_action_menu_item_layout androidx.appcompat.R$attr: int activityChooserViewStyle androidx.appcompat.R$styleable: int MenuItem_android_id androidx.appcompat.R$styleable: int[] CoordinatorLayout_Layout androidx.lifecycle.FullLifecycleObserverAdapter ... </code></pre></devsite-code> <h3 id="troubleshoot-resource-shrink" data-text="Troubleshoot resource shrinking" tabindex="-1">Troubleshoot resource shrinking</h3> <p>When you shrink resources, the <b>Build</b> <img src="/static/studio/images/buttons/window-build-2x.png" alt class="inline-icon"> window shows a summary of the resources that are removed from the app. (You need to first click <b>Toggle view</b> <img src="/static/studio/images/buttons/build-toggle_view-2x.png" alt class="inline-icon"> on the left side of the window to display detailed text output from Gradle.) For example:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded><code translate="no" dir="ltr">:android:shrinkDebugResources Removed unused resources: Resource data reduced from 2570KB to 1711KB: Removed 33% :android:validateDebugSigning </code></pre></devsite-code> <p>Gradle also creates a diagnostic file named <code translate="no" dir="ltr">resources.txt</code> in <code translate="no" dir="ltr"><module-name>/build/outputs/mapping/release/</code> (the same folder as ProGuard's output files). This file includes details such as which resources reference other resources and which resources are used or removed.</p> <p>For example, to find out why <code translate="no" dir="ltr">@drawable/ic_plus_anim_016</code> is still in your app, open the <code translate="no" dir="ltr">resources.txt</code> file and search for that file name. You might find that it's referenced from another resource, as follows:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded><code translate="no" dir="ltr">16:25:48.005 [QUIET] [system.out] @drawable/add_schedule_fab_icon_anim : reachable=true 16:25:48.009 [QUIET] [system.out] @drawable/ic_plus_anim_016 </code></pre></devsite-code> <p>You now need to know why <code translate="no" dir="ltr">@drawable/add_schedule_fab_icon_anim</code> is reachable—and if you search upwards you'll find that resource is listed under "The root reachable resources are:". This means there is a code reference to <code translate="no" dir="ltr">add_schedule_fab_icon_anim</code> (that is, its R.drawable ID was found in the reachable code).</p> <p>If you are not using strict checking, resource IDs can be marked as reachable if there are string constants that look like they might be used to construct resource names for dynamically loaded resources. In that case, if you search the build output for the resource name, you might find a message like this:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded><code translate="no" dir="ltr">10:32:50.590 [QUIET] [system.out] Marking drawable:ic_plus_anim_016:2130837506 used because it format-string matches string pool constant ic_plus_anim_%1$d. </code></pre></devsite-code> <p>If you see one of these strings and you are certain that the string is not being used to load the given resource dynamically, you can use the <code translate="no" dir="ltr">tools:discard</code> attribute to inform the build system to remove it, as described in the section about how to <a href="#keep-resources" >customize which resources to keep</a>.</p> <devsite-hats-survey class="nocontent" hats-id="VxqvKSur40kxBYCLVTd0SSGykbno" listnr-id="5207477"></devsite-hats-survey> </div> <devsite-recommendations display="in-page" hidden yield> </devsite-recommendations> <devsite-thumb-rating position="footer"> </devsite-thumb-rating> <devsite-recommendations id="recommendations-link" yield></devsite-recommendations> <div class="devsite-floating-action-buttons"> </div> </article> <devsite-content-footer class="nocontent"> <p>Content and code samples on this page are subject to the licenses described in the <a href="/license">Content License</a>. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.</p> <p>Last updated 2024-11-12 UTC.</p> </devsite-content-footer> <devsite-notification > </devsite-notification> <div class="devsite-content-data"> <template class="devsite-content-data-template"> [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-12 UTC."],[],[]] </template> </div> </devsite-content> </main> <devsite-footer-promos class="devsite-footer"> <nav class="devsite-footer-promos nocontent" aria-label="Promotions"> <ul class="devsite-footer-promos-list"> <li class="devsite-footer-promo"> <a href="//x.com/AndroidDev" class="devsite-footer-promo-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer X Promo" > <picture> <source class="devsite-dark-theme" srcset="https://developer.android.com/_static/android/images/logo-x_dt.svg" media="(prefers-color-scheme: dark)" loading="lazy" alt="X"> <img class="devsite-footer-promo-icon" src="/_static/android/images/logo-x.svg" loading="lazy" alt="X"> </picture> <span class="devsite-footer-promo-label"> X </span> </a> <div class="devsite-footer-promo-description">Follow @AndroidDev on X</div> </li> <li class="devsite-footer-promo"> <a href="//www.youtube.com/user/androiddevelopers" class="devsite-footer-promo-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer YouTube Promo" > <picture> <source class="devsite-dark-theme" srcset="https://developer.android.com/_static/android/images/logo-youtube_dt.svg" media="(prefers-color-scheme: dark)" loading="lazy" alt="YouTube"> <img class="devsite-footer-promo-icon" src="//www.gstatic.com/images/icons/material/product/2x/youtube_48dp.png" loading="lazy" alt="YouTube"> </picture> <span class="devsite-footer-promo-label"> YouTube </span> </a> <div class="devsite-footer-promo-description">Check out Android Developers on YouTube</div> </li> <li class="devsite-footer-promo"> <a href="//www.linkedin.com/showcase/androiddev" class="devsite-footer-promo-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer LinkedIn Promo" > <picture> <source class="devsite-dark-theme" srcset="https://developer.android.com/_static/android/images/logo-linkedin_dt.svg" media="(prefers-color-scheme: dark)" loading="lazy" alt="LinkedIn"> <img class="devsite-footer-promo-icon" src="/_static/android/images/logo-linkedin.svg" loading="lazy" alt="LinkedIn"> </picture> <span class="devsite-footer-promo-label"> LinkedIn </span> </a> <div class="devsite-footer-promo-description">Connect with the Android Developers community on LinkedIn</div> </li> </ul> </nav> </devsite-footer-promos> <devsite-footer-linkboxes class="devsite-footer"> <nav class="devsite-footer-linkboxes nocontent" aria-label="Footer links"> <ul class="devsite-footer-linkboxes-list"> <li class="devsite-footer-linkbox "> <h3 class="devsite-footer-linkbox-heading no-link">More Android</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"> <a href="//www.android.com" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)" > Android </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//www.android.com/enterprise/" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)" > Android for Enterprise </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//www.android.com/security-center/" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)" > Security </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//source.android.com" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)" > Source </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/news" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 5)" > News </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//android-developers.googleblog.com/" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 6)" > Blog </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/podcasts" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 7)" > Podcasts </a> </li> </ul> </li> <li class="devsite-footer-linkbox "> <h3 class="devsite-footer-linkbox-heading no-link">Discover</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"> <a href="/games" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)" > Gaming </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/ml" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)" > Machine Learning </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/health-and-fitness" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)" > Health & Fitness </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/media" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)" > Camera & Media </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/privacy" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 5)" > Privacy </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/training/connectivity/5g" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 6)" > 5G </a> </li> </ul> </li> <li class="devsite-footer-linkbox "> <h3 class="devsite-footer-linkbox-heading no-link">Android Devices</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"> <a href="/large-screens" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)" > Large screens </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/wear" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)" > Wear OS </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/chrome-os" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)" > ChromeOS devices </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/cars" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)" > Android for cars </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/tv" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 5)" > Android TV </a> </li> </ul> </li> <li class="devsite-footer-linkbox "> <h3 class="devsite-footer-linkbox-heading no-link">Releases</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"> <a href="/about/versions/15" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)" > Android 15 </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/about/versions/14" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)" > Android 14 </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/about/versions/13" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)" > Android 13 </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/about/versions/12" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)" > Android 12 </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/about/versions/11" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 5)" > Android 11 </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/about/versions/10" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 6)" > Android 10 </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/about/versions/pie" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 7)" > Pie </a> </li> </ul> </li> <li class="devsite-footer-linkbox "> <h3 class="devsite-footer-linkbox-heading no-link">Documentation and Downloads</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"> <a href="/studio/intro" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)" > Android Studio guide </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/guide" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)" > Developers guides </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/reference" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)" > API reference </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/studio" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)" > Download Studio </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/ndk" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 5)" > Android NDK </a> </li> </ul> </li> <li class="devsite-footer-linkbox "> <h3 class="devsite-footer-linkbox-heading no-link">Support</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"> <a href="//issuetracker.google.com/issues/new?component=190923&template=841312" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)" > Report platform bug </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//issuetracker.google.com/issues/new?component=192697" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)" > Report documentation bug </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//support.google.com/googleplay/android-developer" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)" > Google Play support </a> </li> <li class="devsite-footer-linkbox-item"> <a href="https://g.co/userresearch/androiddeveloperfooter" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)" > Join research studies </a> </li> </ul> </li> </ul> </nav> </devsite-footer-linkboxes> <devsite-footer-utility class="devsite-footer"> <div class="devsite-footer-utility nocontent"> <nav class="devsite-footer-sites" aria-label="Other Google Developers websites"> <a href="https://developers.google.com/" class="devsite-footer-sites-logo-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Google Developers Link"> <picture> <source srcset="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/lockup-google-for-developers-dark-theme.svg" media="(prefers-color-scheme: none)" class="devsite-dark-theme" loading="lazy" alt="Google Developers"> <img class="devsite-footer-sites-logo" src="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/lockup-google-for-developers.svg" loading="lazy" alt="Google Developers"> </picture> </a> <ul class="devsite-footer-sites-list"> <li class="devsite-footer-sites-item"> <a href="//developer.android.com" class="devsite-footer-sites-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Android Link" > Android </a> </li> <li class="devsite-footer-sites-item"> <a href="//developer.chrome.com/home" class="devsite-footer-sites-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Chrome Link" > Chrome </a> </li> <li class="devsite-footer-sites-item"> <a href="//firebase.google.com" class="devsite-footer-sites-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Firebase Link" > Firebase </a> </li> <li class="devsite-footer-sites-item"> <a href="//cloud.google.com" class="devsite-footer-sites-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Google Cloud Platform Link" > Google Cloud Platform </a> </li> <li class="devsite-footer-sites-item"> <a href="//developers.google.com/products/" class="devsite-footer-sites-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer All products Link" > All products </a> </li> </ul> </nav> <nav class="devsite-footer-utility-links" aria-label="Utility links"> <ul class="devsite-footer-utility-list"> <li class="devsite-footer-utility-item "> <a class="devsite-footer-utility-link gc-analytics-event" href="//policies.google.com/privacy" data-category="Site-Wide Custom Events" data-label="Footer Privacy link" > Privacy </a> </li> <li class="devsite-footer-utility-item "> <a class="devsite-footer-utility-link gc-analytics-event" href="/license" data-category="Site-Wide Custom Events" data-label="Footer License link" > License </a> </li> <li class="devsite-footer-utility-item "> <a class="devsite-footer-utility-link gc-analytics-event" href="/distribute/marketing-tools/brand-guidelines" data-category="Site-Wide Custom Events" data-label="Footer Brand guidelines link" > Brand guidelines </a> </li> <li class="devsite-footer-utility-item glue-cookie-notification-bar-control"> <a class="devsite-footer-utility-link gc-analytics-event" href="#" data-category="Site-Wide Custom Events" data-label="Footer Manage cookies link" aria-hidden="true" > Manage cookies </a> </li> <li class="devsite-footer-utility-item devsite-footer-utility-button"> <span class="devsite-footer-utility-description">Get news and tips by email</span> <a class="devsite-footer-utility-link gc-analytics-event" href="/updates" data-category="Site-Wide Custom Events" data-label="Footer Subscribe link" > Subscribe </a> </li> </ul> <devsite-language-selector> <ul role="presentation"> <li role="presentation"> <a role="menuitem" lang="en" >English</a> </li> <li role="presentation"> <a role="menuitem" lang="de" >Deutsch</a> </li> <li role="presentation"> <a role="menuitem" lang="es_419" >Español – América Latina</a> </li> <li role="presentation"> <a role="menuitem" lang="fr" >Français</a> </li> <li role="presentation"> <a role="menuitem" lang="id" >Indonesia</a> </li> <li role="presentation"> <a role="menuitem" lang="it" >Italiano</a> </li> <li role="presentation"> <a role="menuitem" lang="pl" >Polski</a> </li> <li role="presentation"> <a role="menuitem" lang="pt_br" >Português – Brasil</a> </li> <li role="presentation"> <a role="menuitem" lang="vi" >Tiếng Việt</a> </li> <li role="presentation"> <a role="menuitem" lang="tr" >Türkçe</a> </li> <li role="presentation"> <a role="menuitem" lang="ru" >Русский</a> </li> <li role="presentation"> <a role="menuitem" lang="he" >עברית</a> </li> <li role="presentation"> <a role="menuitem" lang="ar" >العربيّة</a> </li> <li role="presentation"> <a role="menuitem" lang="fa" >فارسی</a> </li> <li role="presentation"> <a role="menuitem" lang="hi" >हिंदी</a> </li> <li role="presentation"> <a role="menuitem" lang="bn" >বাংলা</a> </li> <li role="presentation"> <a role="menuitem" lang="th" >ภาษาไทย</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_cn" >中文 – 简体</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_tw" >中文 – 繁體</a> </li> <li role="presentation"> <a role="menuitem" lang="ja" >日本語</a> </li> <li role="presentation"> <a role="menuitem" lang="ko" >한국어</a> </li> </ul> </devsite-language-selector> </nav> </div> </devsite-footer-utility> <devsite-panel></devsite-panel> </section></section> <devsite-sitemask></devsite-sitemask> <devsite-snackbar></devsite-snackbar> <devsite-tooltip ></devsite-tooltip> <devsite-heading-link></devsite-heading-link> <devsite-analytics> <script type="application/json" analytics>[]</script> <script type="application/json" tag-management>{"at": "True", "ga4": [{"id": "G-QFRN08RN6E", "purpose": 0}], "ga4p": [{"id": "G-QFRN08RN6E", "purpose": 0}], "gtm": [{"id": "GTM-KMSWPCJ", "purpose": 0}], "parameters": {"internalUser": "False", "language": {"machineTranslated": "False", "requested": "en", "served": "en"}, "pageType": "article", "projectName": "Android Studio", "signedIn": "False", "tenant": "android", "recommendations": {"sourcePage": "", "sourceType": 0, "sourceRank": 0, "sourceIdenticalDescriptions": 0, "sourceTitleWords": 0, "sourceDescriptionWords": 0, "experiment": ""}, "experiment": {"ids": ""}}}</script> </devsite-analytics> <devsite-badger></devsite-badger> <android-fully-clickable target=" .android-case-study .devsite-landing-row-item, .android-grouped-resources .devsite-landing-row-item, .android-grouped-resources-primary .devsite-landing-row-item, .android-grouped-resources-secondary .devsite-landing-row-item, .android-guide-cards .devsite-landing-row-item, .android-illustrated-resources-index .devsite-landing-row-item, .android-illustrated-resources-primary .devsite-landing-row-item, .android-illustrated-resources-secondary .devsite-landing-row-item, .android-illustrated-resources-secondary-small .devsite-landing-row-item, .android-illustrated-resources-tertiary .devsite-landing-row-item, .android-illustrated-resources-tertiary-small .devsite-landing-row-item, .android-promo .devsite-landing-row-item, .android-quick-link, .android-samples .devsite-card-wrapper, .fully-clickable" watch=".android-samples, devsite-content"></android-fully-clickable> <script nonce="1fW1t0J7qB+lEQ3subt7ZvOrHckfLR"> (function(d,e,v,s,i,t,E){d['GoogleDevelopersObject']=i; t=e.createElement(v);t.async=1;t.src=s;E=e.getElementsByTagName(v)[0]; E.parentNode.insertBefore(t,E);})(window, document, 'script', 'https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/js/app_loader.js', '[3,"en",null,"/js/devsite_app_module.js","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android","https://android-dot-devsite-v2-prod.appspot.com",null,null,["/_pwa/android/manifest.json","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/images/video-placeholder.svg","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/favicon.svg","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/android/images/lockup.svg","https://fonts.googleapis.com/css?family=Google+Sans:400,500,600,700|Google+Sans+Text:400,400italic,500,500italic,600,600italic,700,700italic|Roboto+Mono:400,500,700&display=swap"],1,null,[1,6,8,12,14,17,21,25,50,52,63,70,75,76,80,87,91,92,93,97,98,100,101,102,103,104,105,107,108,109,110,112,113,116,117,118,120,122,124,125,126,127,129,130,131,132,133,134,135,136,138,140,141,147,148,149,151,152,156,157,158,159,161,163,164,168,169,170,179,180,182,183,186,191,193,196],"AIzaSyAP-jjEJBzmIyKR4F-3XITp8yM9T1gEEI8","AIzaSyB6xiKGDR5O3Ak2okS4rLkauxGUG7XP0hg","developer.android.com","AIzaSyAQk0fBONSGUqCNznf6Krs82Ap1-NV6J4o","AIzaSyCCxcqdrZ_7QMeLCRY20bh_SXdAYqy70KY",null,null,null,["MiscFeatureFlags__emergency_css","MiscFeatureFlags__enable_dark_theme","Cloud__enable_cloud_dlp_service","MiscFeatureFlags__developers_footer_image","MiscFeatureFlags__enable_explain_this_code","Cloud__enable_cloud_shell","Profiles__enable_dashboard_curated_recommendations","Search__enable_ai_search_summaries","TpcFeatures__enable_required_headers","Search__enable_page_map","Cloud__enable_free_trial_server_call","Profiles__enable_public_developer_profiles","Profiles__enable_developer_profiles_callout","Profiles__enable_completecodelab_endpoint","MiscFeatureFlags__enable_firebase_utm","EngEduTelemetry__enable_engedu_telemetry","DevPro__enable_developer_subscriptions","Significatio__enable_by_tenant","Cloud__enable_cloudx_experiment_ids","MiscFeatureFlags__enable_view_transitions","Profiles__enable_complete_playlist_endpoint","Profiles__enable_recognition_badges","MiscFeatureFlags__enable_variable_operator","Concierge__enable_pushui","MiscFeatureFlags__enable_project_variables","CloudShell__cloud_code_overflow_menu","DevPro__enable_cloud_innovators_plus","TpcFeatures__enable_mirror_tenant_redirects","Cloud__enable_cloudx_ping","Profiles__enable_release_notes_notifications","MiscFeatureFlags__developers_footer_dark_image","Cloud__enable_llm_concierge_chat","Profiles__enable_page_saving","CloudShell__cloud_shell_button","Profiles__enable_profile_collections","Analytics__enable_clearcut_logging","Cloud__enable_cloud_facet_chat","Cloud__enable_legacy_calculator_redirect","Search__enable_dynamic_content_confidential_banner","Experiments__reqs_query_experiments","Search__enable_ai_eligibility_checks","Cloud__enable_cloud_shell_fte_user_flow","Search__enable_suggestions_from_borg","Profiles__require_profile_eligibility_for_signin","BookNav__enable_tenant_cache_key","Profiles__enable_awarding_url"],null,null,"AIzaSyBLEMok-5suZ67qRPzx0qUtbnLmyT_kCVE","https://developerscontentserving-pa.googleapis.com","AIzaSyCM4QpTRSqP5qI4Dvjt4OAScIN8sOUlO-k","https://developerscontentsearch-pa.googleapis.com",2,4,null,"https://developerprofiles-pa.googleapis.com",[3,"android","Android Developers","developer.android.com",null,"android-dot-devsite-v2-prod.appspot.com",null,null,[null,1,null,null,null,null,null,null,null,null,null,[1],null,null,null,null,null,null,[1],[1,null,null,[1,20],"/recommendations"],null,null,null,[1,null,1],[1,1,null,1,1]],null,[18,null,null,null,null,null,"/images/lockup.svg","/images/touchicon-180.png",null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,null,null,"/images/lockup-dark-theme.svg",[]],[],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[6,1,14,15,20,22,23,28,29,37,43],null,[[null,null,1],[1,1]],[[null,null,null,null,null,null,null,[["G-QFRN08RN6E"],null,null,[["G-QFRN08RN6E",1]]],null,null,null,null,1],null,[[1,1],[2,2]]],null,4,null,null,null,null,null,null,null,null,null,null,null,null,null,"android.devsite.google"],null,"pk_live_5170syrHvgGVmSx9sBrnWtA5luvk9BwnVcvIi7HizpwauFG96WedXsuXh790rtij9AmGllqPtMLfhe2RSwD6Pn38V00uBCydV4m"]') </script> <devsite-a11y-announce></devsite-a11y-announce> </body> </html>