{"id":5153,"date":"2020-11-02T13:53:38","date_gmt":"2020-11-02T13:53:38","guid":{"rendered":"https:\/\/www.folio3.com\/mobile\/?p=5153"},"modified":"2020-11-12T11:02:02","modified_gmt":"2020-11-12T11:02:02","slug":"how-to-reduce-apk-size-in-react-native","status":"publish","type":"post","link":"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/","title":{"rendered":"How to reduce apk size in React Native"},"content":{"rendered":"\n<p>When we develop an app using React Native, we want to make sure that our app can run on as many different devices as possible, by providing resources that are optimized for different CPU architectures, screens as well as many other factors. Unluckily, this also means that every single device, which downloads your app, will receive a bunch of code and resources that are not going to be used at all.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Android App Bundle<\/strong><\/h3>\n\n\n\n<p>The size of an APK can be reduced by 35% by publishing the app in AAB (Android App Bundle) format &#8211; official Android Developers blog.<\/p>\n\n\n\n<p>Only compiled code and resources are contained in the AAB bundle. Google play itself generates an optimized APK for every device type based on its specifications and CPU structure.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/YuyiCJqtQki3b3mPapTgJjmoY5xKJSA8Rk6apO0pfollPpV1w0fD-8L65jNN9poh5ZpFLpNDop5pKxegWJl6tDSg8lPH7v0zaIlcCq9XZlSM9rGac2EHlFYbf2av5kRuzg9jeCMj\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Old APK at 26.8MB compared to the new AAB at 14.4 to 17.7 MB&nbsp;<\/strong><\/p>\n\n\n\n<p>Using Android Studio or Command-line tools you can simply build your project as a signed app bundle. To build a signed app bundle from Android studio first, select Build > Generate Signed Bundle\/APK from the Android Studio toolbar. The next step is to select the Android App Bundle checkbox and then click the Next button. Then, open the module dropdown, and choose the app as our base module from the list.<\/p>\n\n\n\n<p>Follow the instructions provided on-screen to complete the build process. On completion, Android Studio will generate a .aab file and store it in our computer\u2019s AndroidAppBundle\/app\/release directory. An Android App Bundle is a file (with the .aab file extension) that you upload to Google Play.<\/p>\n\n\n\n<p>We can also generate signed .aab using the terminal by running the following command in the <strong>android<\/strong> folder:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd android<br>.\/gradlew bundleRelease<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Enable Resource Shrinking&nbsp;<\/strong><\/h3>\n\n\n\n<p>Resource shrinking can be used to identify and eliminate unnecessary resources. It can be enabled using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>buildTypes {\n       release {\n        \/\/Add the following\/\/\n    \tshrinkResources true\n        minifyEnabled true\n       }\n   }<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Enable Proguard<\/strong><\/h3>\n\n\n\n<p>Proguard is used to shrink, optimize, obfuscate, and preverify class files. it detects and eliminates unused classes, methods and attributes and rename the remaining ones using short and meaningless names. It compresses the Java Bytecode and reduces the size of the app a little bit. <\/p>\n\n\n\n<p>To enable it use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def enableProguardInReleaseBuilds = true<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Enable Separate Builds<\/strong><\/h3>\n\n\n\n<p>This is the alternative of Android App Bundle (.aab). If we do not want to generate aab and stick with apk then this is the way to reduce sizes. Basically 2 major architectures, armeabi &amp; x86, are supported by Android devices. When APK is generated via React Native, it contains the native libraries of both the architectures. In order to generate 2 different APKs use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Set def enableSeparateBuildPerCPUArchitecture = true<\/pre>\n\n\n\n<p>Both of the APKs should be uploaded to Google Play, where each one can be distributed to the correct architecture. This can reduce the size of APK around 7mb to 3.5mb for armeabi and 5mb for x86.<\/p>\n\n\n\n<p>Do you know any other tips for reducing APK size? Do let us know in the comments. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>When we develop an app using React Native, we want to make sure that our app can run on as many different devices as possible, by providing resources that are optimized for different CPU architectures, screens as well as many other factors. Unluckily, this also means that every single device, which downloads your app, will &hellip; <a href=\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to reduce apk size in React Native&#8221;<\/span><\/a><\/p>\n","protected":false},"author":37,"featured_media":5156,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[50],"tags":[],"class_list":["post-5153","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-react-native"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to reduce apk size in React Native - Mobile App Development Services<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to reduce apk size in React Native - Mobile App Development Services\" \/>\n<meta property=\"og:description\" content=\"When we develop an app using React Native, we want to make sure that our app can run on as many different devices as possible, by providing resources that are optimized for different CPU architectures, screens as well as many other factors. Unluckily, this also means that every single device, which downloads your app, will &hellip; Continue reading &quot;How to reduce apk size in React Native&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/\" \/>\n<meta property=\"og:site_name\" content=\"Mobile App Development Services\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-02T13:53:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-12T11:02:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.folio3.com\/mobile\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-02-at-7.16.21-PM.png\" \/>\n\t<meta property=\"og:image:width\" content=\"625\" \/>\n\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Noc Folio3\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Noc Folio3\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/\"},\"author\":{\"name\":\"Noc Folio3\",\"@id\":\"https:\/\/www.folio3.com\/mobile\/#\/schema\/person\/0b6e4f68efbd12d222ac9422766c61eb\"},\"headline\":\"How to reduce apk size in React Native\",\"datePublished\":\"2020-11-02T13:53:38+00:00\",\"dateModified\":\"2020-11-12T11:02:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/\"},\"wordCount\":486,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.folio3.com\/mobile\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.folio3.com\/mobile\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-02-at-7.16.21-PM.png\",\"articleSection\":[\"React Native\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/\",\"url\":\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/\",\"name\":\"How to reduce apk size in React Native - Mobile App Development Services\",\"isPartOf\":{\"@id\":\"https:\/\/www.folio3.com\/mobile\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.folio3.com\/mobile\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-02-at-7.16.21-PM.png\",\"datePublished\":\"2020-11-02T13:53:38+00:00\",\"dateModified\":\"2020-11-12T11:02:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#primaryimage\",\"url\":\"https:\/\/www.folio3.com\/mobile\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-02-at-7.16.21-PM.png\",\"contentUrl\":\"https:\/\/www.folio3.com\/mobile\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-02-at-7.16.21-PM.png\",\"width\":625,\"height\":350},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.folio3.com\/mobile\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to reduce apk size in React Native\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.folio3.com\/mobile\/#website\",\"url\":\"https:\/\/www.folio3.com\/mobile\/\",\"name\":\"Mobile App Development Services\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.folio3.com\/mobile\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.folio3.com\/mobile\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.folio3.com\/mobile\/#organization\",\"name\":\"Mobile App Development Services\",\"url\":\"https:\/\/www.folio3.com\/mobile\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.folio3.com\/mobile\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.folio3.com\/mobile\/wp-content\/uploads\/2020\/12\/folio3-mobile.png\",\"contentUrl\":\"https:\/\/www.folio3.com\/mobile\/wp-content\/uploads\/2020\/12\/folio3-mobile.png\",\"width\":210,\"height\":50,\"caption\":\"Mobile App Development Services\"},\"image\":{\"@id\":\"https:\/\/www.folio3.com\/mobile\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.folio3.com\/mobile\/#\/schema\/person\/0b6e4f68efbd12d222ac9422766c61eb\",\"name\":\"Noc Folio3\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.folio3.com\/mobile\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/29f05a21b8db20048e7717694b024bbd?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/29f05a21b8db20048e7717694b024bbd?s=96&d=mm&r=g\",\"caption\":\"Noc Folio3\"},\"url\":\"https:\/\/www.folio3.com\/mobile\/blog\/author\/noc\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to reduce apk size in React Native - Mobile App Development Services","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/","og_locale":"en_US","og_type":"article","og_title":"How to reduce apk size in React Native - Mobile App Development Services","og_description":"When we develop an app using React Native, we want to make sure that our app can run on as many different devices as possible, by providing resources that are optimized for different CPU architectures, screens as well as many other factors. Unluckily, this also means that every single device, which downloads your app, will &hellip; Continue reading \"How to reduce apk size in React Native\"","og_url":"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/","og_site_name":"Mobile App Development Services","article_published_time":"2020-11-02T13:53:38+00:00","article_modified_time":"2020-11-12T11:02:02+00:00","og_image":[{"width":625,"height":350,"url":"https:\/\/www.folio3.com\/mobile\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-02-at-7.16.21-PM.png","type":"image\/png"}],"author":"Noc Folio3","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Noc Folio3","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#article","isPartOf":{"@id":"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/"},"author":{"name":"Noc Folio3","@id":"https:\/\/www.folio3.com\/mobile\/#\/schema\/person\/0b6e4f68efbd12d222ac9422766c61eb"},"headline":"How to reduce apk size in React Native","datePublished":"2020-11-02T13:53:38+00:00","dateModified":"2020-11-12T11:02:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/"},"wordCount":486,"commentCount":0,"publisher":{"@id":"https:\/\/www.folio3.com\/mobile\/#organization"},"image":{"@id":"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#primaryimage"},"thumbnailUrl":"https:\/\/www.folio3.com\/mobile\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-02-at-7.16.21-PM.png","articleSection":["React Native"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/","url":"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/","name":"How to reduce apk size in React Native - Mobile App Development Services","isPartOf":{"@id":"https:\/\/www.folio3.com\/mobile\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#primaryimage"},"image":{"@id":"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#primaryimage"},"thumbnailUrl":"https:\/\/www.folio3.com\/mobile\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-02-at-7.16.21-PM.png","datePublished":"2020-11-02T13:53:38+00:00","dateModified":"2020-11-12T11:02:02+00:00","breadcrumb":{"@id":"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#primaryimage","url":"https:\/\/www.folio3.com\/mobile\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-02-at-7.16.21-PM.png","contentUrl":"https:\/\/www.folio3.com\/mobile\/wp-content\/uploads\/2020\/11\/Screenshot-2020-11-02-at-7.16.21-PM.png","width":625,"height":350},{"@type":"BreadcrumbList","@id":"https:\/\/www.folio3.com\/mobile\/blog\/how-to-reduce-apk-size-in-react-native\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.folio3.com\/mobile\/"},{"@type":"ListItem","position":2,"name":"How to reduce apk size in React Native"}]},{"@type":"WebSite","@id":"https:\/\/www.folio3.com\/mobile\/#website","url":"https:\/\/www.folio3.com\/mobile\/","name":"Mobile App Development Services","description":"","publisher":{"@id":"https:\/\/www.folio3.com\/mobile\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.folio3.com\/mobile\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.folio3.com\/mobile\/#organization","name":"Mobile App Development Services","url":"https:\/\/www.folio3.com\/mobile\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.folio3.com\/mobile\/#\/schema\/logo\/image\/","url":"https:\/\/www.folio3.com\/mobile\/wp-content\/uploads\/2020\/12\/folio3-mobile.png","contentUrl":"https:\/\/www.folio3.com\/mobile\/wp-content\/uploads\/2020\/12\/folio3-mobile.png","width":210,"height":50,"caption":"Mobile App Development Services"},"image":{"@id":"https:\/\/www.folio3.com\/mobile\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.folio3.com\/mobile\/#\/schema\/person\/0b6e4f68efbd12d222ac9422766c61eb","name":"Noc Folio3","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.folio3.com\/mobile\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/29f05a21b8db20048e7717694b024bbd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/29f05a21b8db20048e7717694b024bbd?s=96&d=mm&r=g","caption":"Noc Folio3"},"url":"https:\/\/www.folio3.com\/mobile\/blog\/author\/noc\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.folio3.com\/mobile\/wp-json\/wp\/v2\/posts\/5153"}],"collection":[{"href":"https:\/\/www.folio3.com\/mobile\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.folio3.com\/mobile\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.folio3.com\/mobile\/wp-json\/wp\/v2\/users\/37"}],"replies":[{"embeddable":true,"href":"https:\/\/www.folio3.com\/mobile\/wp-json\/wp\/v2\/comments?post=5153"}],"version-history":[{"count":4,"href":"https:\/\/www.folio3.com\/mobile\/wp-json\/wp\/v2\/posts\/5153\/revisions"}],"predecessor-version":[{"id":5217,"href":"https:\/\/www.folio3.com\/mobile\/wp-json\/wp\/v2\/posts\/5153\/revisions\/5217"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.folio3.com\/mobile\/wp-json\/wp\/v2\/media\/5156"}],"wp:attachment":[{"href":"https:\/\/www.folio3.com\/mobile\/wp-json\/wp\/v2\/media?parent=5153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.folio3.com\/mobile\/wp-json\/wp\/v2\/categories?post=5153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.folio3.com\/mobile\/wp-json\/wp\/v2\/tags?post=5153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}