<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dheeraj Pant on Medium]]></title>
        <description><![CDATA[Stories by Dheeraj Pant on Medium]]></description>
        <link>https://medium.com/@dheeraj_pant?source=rss-a56f718ce68c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*1zTRpi8BTp0zMUuj.jpg</url>
            <title>Stories by Dheeraj Pant on Medium</title>
            <link>https://medium.com/@dheeraj_pant?source=rss-a56f718ce68c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 08:58:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dheeraj_pant/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Dynamic feature module in Android]]></title>
            <link>https://labs.testbook.com/dynamic-feature-module-in-android-a4e12ee85ce4?source=rss-a56f718ce68c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4e12ee85ce4</guid>
            <category><![CDATA[dynamic-feature-module]]></category>
            <category><![CDATA[google-play]]></category>
            <category><![CDATA[dynamic-feature]]></category>
            <category><![CDATA[dynamic-module]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Dheeraj Pant]]></dc:creator>
            <pubDate>Thu, 23 Jun 2022 07:58:06 GMT</pubDate>
            <atom:updated>2022-06-23T10:21:34.856Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vm6CZ_3tEMhn_iAEIYZ6ug.jpeg" /></figure><p>Play Feature Delivery uses app bundles, allowing certain features of your app to be delivered conditionally or downloaded on demand. Features which are used rarely and not right away are the perfect candidate for this. To do that, first, you need to separate these features from your base app into feature modules.</p><p><a href="https://github.com/cptc0ld/DynamicFeatureExample">GitHub - cptc0ld/DynamicFeatureExample</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/299/1*GECRSFUDywDD9Qs_Eby7aw.gif" /></figure><p>There are 4 different delivery options that feature modules support, and below are different examples of how they might be used to optimize the initial download size of the sample app.</p><h4>Install-time delivery</h4><p>If the app has certain training activities which are only used once, you can include that feature at app install, by default.</p><p>However, to reduce the installed size of the app, the app can request to delete the feature after the user has completed the training.</p><h4>On-demand delivery</h4><p>If there are a very low number of audiences who use a certain feature, we can ask the user to download the feature whenever he tries to use it.</p><p>Additionally, we can uninstall the module if the user has not accessed it for a long time.</p><h4>Conditional delivery</h4><p>Allows you to specify certain user device requirements, such as hardware features, locale, and minimum API level to determine whether a modularized feature is downloaded at app install.</p><h4>Instant delivery</h4><p><a href="https://developer.android.com/topic/google-play-instant/overview">Google Play Instant</a> allows users to interact with your app without needing to install the app on their device. Instead, they can experience your app through the “Try Now” button on the Google Play Store or a URL that you create. This form of delivering content makes it easier for you to increase engagement with your app.</p><blockquote>We chose On demand delivery for our use case</blockquote><h4><strong>Walkthrough</strong></h4><blockquote>Creating dynamic feature module</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l91ni3n4pFZ_xMz7VKPHvQ.png" /><figcaption>Dynamic module creation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rhGrfLjh9NxZ854BiZSIUA.png" /><figcaption>Module download option</figcaption></figure><ul><li>build.gradle(dynamicfeature)</li></ul><pre>plugins <strong>{<br>    </strong>id &#39;com.android.dynamic-feature&#39;<br>    <strong>...<br>}<br></strong>android <strong>{<br>    ...<br>}<br><br></strong>dependencies <strong>{<br>    </strong>implementation project(&quot;:app&quot;)<br>    ...<br><strong>}</strong></pre><ul><li>AndroidManifest.xml</li></ul><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:dist=&quot;http://schemas.android.com/apk/distribution&quot;<br>    package=&quot;com.example.dynamicfeature&quot;&gt;<br><br>    &lt;dist:module<br>        dist:instant=&quot;false&quot;<br>        dist:title=&quot;@string/title_dynamicfeature&quot;&gt;<br>        &lt;dist:delivery&gt;<br>            &lt;dist:on-demand /&gt;<br>        &lt;/dist:delivery&gt;<br>        &lt;dist:fusing dist:include=&quot;true&quot; /&gt;<br>    &lt;/dist:module&gt;<br>&lt;/manifest&gt;</pre><ul><li>build.gradle(app)</li></ul><pre>android <strong>{<br>    ...<br>    </strong>dynamicFeatures = [&#39;:dynamicfeature&#39;]<br><strong>}</strong></pre><blockquote>Creating Basic Activity in dynamicfeature</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WswbvM4W9oCS8ijhPVA-7g.png" /><figcaption>Creating DynamicActivity.kt with basic functionality</figcaption></figure><blockquote>Downloading dynamicfeature on demand</blockquote><ul><li>Let&#39;s add <a href="https://developer.android.com/guide/playcore">Play Core Library</a> to our project. This need to be added on build.gradle(app) to download dynamicfeature on-demand and on build.gradle to load resources after installation.</li></ul><pre> implementation ‘com.google.android.play:core-ktx:1.8.1’</pre><ul><li>To access the resources from downloaded module, enable <a href="https://developer.android.com/reference/com/google/android/play/core/splitcompat/SplitCompat">SplitCompat</a> Library for the App and for the Dynamic class(Activity/Fragment)</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34e4cfd60dcfc6f831b2511de676e551/href">https://medium.com/media/34e4cfd60dcfc6f831b2511de676e551/href</a></iframe><p>Add this class to your manifest(app)</p><pre>&lt;application<br>    android:name=&quot;.BaseApplication&quot;<br>    ... &gt;</pre><p>In Dynamic Module Main Activity</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50a1e58da239403a5fde34a87fc9684e/href">https://medium.com/media/50a1e58da239403a5fde34a87fc9684e/href</a></iframe><blockquote>Lets create a Download Module Utility file</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5bfb74b19079d071c9f6bc3404348a9/href">https://medium.com/media/a5bfb74b19079d071c9f6bc3404348a9/href</a></iframe><blockquote>Now to open DynamicActivity from Base App</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a359fb55636a25cd07bc957fab2353b/href">https://medium.com/media/3a359fb55636a25cd07bc957fab2353b/href</a></iframe><p>Some things to note:</p><ol><li><em>DYNAMIC_MODULE_NAME</em> should be same as your dynamic module name</li><li>As app does not implement dynamicfeature , there is no reference for <em>DynamicActivity</em> in <em>MainActivity</em> therefore we need to mention activity with package name as com.example.dynamicfeature.DynamicActivity.</li></ol><p><em>And there you have it, Your Dynamic feature module is implemented.</em></p><p><em>But still the most important part is remaining i.e. Testing your Dynamic feature module.</em></p><blockquote><strong>Using Android Studio</strong></blockquote><p>To test your dynamic module while development<br><em>Go to Edit Configuration -&gt; General -&gt; Installation Options </em>and select dynamicfeature</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MRudvTrTUwV9FO4wK8SmaQ.png" /><figcaption>Installation Options</figcaption></figure><blockquote><strong>Using Internal App Sharing</strong></blockquote><p>The <a href="https://play.google.com/console/internal-app-sharing">Internal App Sharing</a> allows developers to quickly share apps faster and without all the restrictions imposed by the Google Play Console.</p><p><a href="https://support.google.com/googleplay/android-developer/answer/9844679?hl=en"><em>See how to share app bundles using Internal App Sharing</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xX5hyVUTFpm9JPrmBih63A.jpeg" /><figcaption><strong>Don’t forget to clap</strong></figcaption></figure><h4>Recommendations</h4><ul><li>Google play store informs user if a module &gt; 10MB is being downloaded. Additionally you can add a custom dialog box for asking the user whether to download the module or not. Consider the following <em>DynamicDownloadListener</em></li></ul><pre>interface DynamicDownloadListener {<br>    fun onAcceptModuleDownload()<br>    fun onDenyModuleDownload()<br>    fun onDynamicModuleDownloaded()<br>}</pre><p><a href="https://developer.android.com/guide/playcore/feature-delivery/ux-guidelines">https://developer.android.com/guide/playcore/feature-delivery/ux-guidelines</a></p><ul><li>Have a fallback for when dynamic feature is not available or downloaded</li></ul><h4>Note</h4><ul><li>After implementing dynamic feature your testing cycle will shift from Base Apk to App Bundle to fully test the download flow.</li><li>If you need to test features inside dynamic module you can make an Universal APK using ./gradlew :app:packageReleaseUniversalApk <br>APK will be under<em> ./app/build/outputs/universal_apk </em>folder</li></ul><h4>Resources</h4><ol><li><a href="https://developer.android.com/guide/playcore/feature-delivery">https://developer.android.com/guide/playcore/feature-delivery</a></li><li><a href="https://developer.android.com/codelabs/on-demand-dynamic-delivery#3">https://developer.android.com/codelabs/on-demand-dynamic-delivery#3</a></li><li><a href="https://developer.android.com/studio/build/configure-apk-splits">https://developer.android.com/studio/build/configure-apk-splits</a></li><li><a href="https://proandroiddev.com/developing-your-own-dynamic-feature-3c48378e3065">https://proandroiddev.com/developing-your-own-dynamic-feature-3c48378e3065</a></li></ol><p><em>Testbook is a leading EdTech Startup in India working on some exciting technologies. Do check out our </em><a href="https://testbook.com/careers"><em>Careers Page</em></a><em> if you are looking to work on these exciting technology problems</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q7GNvdZpDhF5xA3NlOZ1Yw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4e12ee85ce4" width="1" height="1" alt=""><hr><p><a href="https://labs.testbook.com/dynamic-feature-module-in-android-a4e12ee85ce4">Dynamic feature module in Android</a> was originally published in <a href="https://labs.testbook.com/">Testbook Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>