<?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 Akash Khunt on Medium]]></title>
        <description><![CDATA[Stories by Akash Khunt on Medium]]></description>
        <link>https://medium.com/@akashkhunt?source=rss-40ca87650612------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5ddiLcBJEdvUyS0zM7E6cQ.jpeg</url>
            <title>Stories by Akash Khunt on Medium</title>
            <link>https://medium.com/@akashkhunt?source=rss-40ca87650612------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 02:11:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akashkhunt/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[App Size Metrics - Continuous monitoring of App Size, Part 3]]></title>
            <link>https://proandroiddev.com/app-size-metrics-continuous-monitoring-of-app-size-part-3-d9cbd6110b32?source=rss-40ca87650612------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9cbd6110b32</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Akash Khunt]]></dc:creator>
            <pubDate>Thu, 22 Jun 2023 03:54:32 GMT</pubDate>
            <atom:updated>2023-06-22T16:49:23.984Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pic1jaS-k2Iup09K" /><figcaption>Photo by <a href="https://unsplash.com/@sxoxm?utm_source=medium&amp;utm_medium=referral">Sven Mieke</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In <a href="https://proandroiddev.com/app-size-metrics-continuous-monitoring-of-app-size-part-2-bb0fbc91ef2"><strong>Part 2</strong></a>, we finished our GHA workflow which generates apk size diff report and then adds it as a comment to the PR. In this post we’re going to implement the same workflow but using a plugin called <a href="https://github.com/spotify/ruler"><strong>Ruler</strong></a> and also look at some of it’s additional features.</p><p>Let’s rewind a bit to the <a href="https://akashkhunt.medium.com/app-size-metrics-continuous-monitoring-of-app-size-part-1-607f0807fc5c"><strong>Part 1</strong></a>, where we discussed about when we want to reduce the apk size we try to look at the size contribution by each high level categories (i.e. .dex files, resources, assets, JNI libs). An even more advanced stage in this “<strong>Apk Size Reduction”</strong> exercise is to understand the contribution by the 3rd party SDKs (which is not a trivial task by any means 😅). One of the way to calculate it can be to generate two apks with and without the SDK and then calculate the difference. But this is very time consuming and manual process.</p><p>This is where Spotify’s <a href="https://github.com/spotify/ruler"><strong>Ruler</strong></a> plugin comes in very handy as it provides insights into how much size is contributed by each module and dependencies present in your app 😲. You can check the sample report generated with the help of Ruler plugin in the below screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*togDAPlP03_Tbdnb7phbbw.jpeg" /><figcaption><strong>Ruler</strong> report showing <strong>Download (left side) </strong>&amp; <strong>Install (right side)</strong> size contribution by all modules and 3rd party SDKs</figcaption></figure><blockquote>One problem that I faced while using Ruler plugin is that it’s <strong>not compatible with configuration-cache.</strong> But it should not be a blocker as you can always disable configuration-cache setting via passing “ <strong>— no-configuration-cache</strong>” flag while running the Ruler’s gradle tasks.</blockquote><p>Integrating this plugin is very straightforward and doesn’t require much effort. Once this plugin is integrated it’ll expose <strong>analyze{BUILD_VARIANT}Bundle</strong> gradle tasks. For an app with no custom build variant it should expose two tasks i.e. <strong>analyzeDebugBundle</strong> &amp; <strong>analyzeReleaseBundle. </strong>One important feature of this plugin apart from showing the size contribution, is showing <a href="https://github.com/spotify/ruler#ownership"><strong>ownership</strong></a> of different modules of your app. I highly suggest to give it a try as well.</p><p>Once you run this <strong>analyze</strong> gradle task then it should generate two files i.e. an HTML report and a json file. HTML report is a more human readable which you can use to visually inspect the size contribution. You can see the sample report for the same below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CF_ToFXE8VRJY-fnXxPSxw.gif" /><figcaption>HTML report sample</figcaption></figure><p>The file that we’re more interested in is the json report. As we can process the contents of this json file to further generate the data in the format that we want. The json file content looks as shown in below screenshot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*rY1VRI1uIPMYzROkyPwv0g.png" /><figcaption>json report sample</figcaption></figure><p>So our goal here is to process the json file content and generate the same kind of report that we generated previously. The final result should look like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DyD_aj_m4yQpbf4UUrAxxg.png" /><figcaption>Size Diff Report comment added by our workflow (using Ruler plugin)</figcaption></figure><p>We’re going to create new workflow which is very similar to the one we created earlier.</p><p><strong>This workflow is also divided into three jobs:</strong></p><ul><li>Generate html+json reports for both base branch and a merge branch (i.e. head branch + base branch)</li><li>Generate the size diff report (using custom python script)</li><li>Add the size diff report as a PR comment (same as previous workflow)</li></ul><h4>Creating Python Script (to parse json report)</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f97ee79db82f8322a6c2d6d62cfad57/href">https://medium.com/media/7f97ee79db82f8322a6c2d6d62cfad57/href</a></iframe><p>The main difference in this script compared to previous one is the contents of <strong>get_apk_components</strong> function. Here we no longer have to use <strong>apkanalyzer</strong> tool and just need to iterate through the <strong>json_data</strong> (parsed from reading the json report generated by using Ruler plugin) and update the content of <strong>components</strong> dictionary.</p><h4>Ruler report workflow</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2078f21cb98aa82ec3570e18b6ab0d6/href">https://medium.com/media/f2078f21cb98aa82ec3570e18b6ab0d6/href</a></iframe><p>This workflow is also very similar to the earlier one with some minor tweaks in <strong>build</strong> job (instead of executing <strong>assembleRelease</strong> task and uploading the <strong>apks</strong> we’re going to execute the <strong>analyzeReleaseBundle</strong> tasks and upload the <strong>html &amp; json reports</strong>) &amp; <strong>size_report</strong> job (using the updated python script which doesn’t require apkanalyzer tool). The final <strong>pr_comment</strong> job stays same in both workflows as the input file is still going to be <strong>ruler_diff_report.html</strong> file and we’re going to use it’s content to add a comment on the PR.</p><h4>Conclusion</h4><p>The result of both <strong>size_metrics.yml</strong> &amp; <strong>ruler_report.yml</strong> workflows is same except the fact that the later one also exposes html report which allows us to do some granular/deeper level investigation into size contribution visually.</p><p><strong>Reference Material Links and Credits:</strong></p><ul><li><a href="https://github.com/spotify/ruler">https://github.com/spotify/ruler</a></li><li><a href="https://developer.android.com/guide/app-bundle">https://developer.android.com/guide/app-bundle</a></li></ul><p>Hope you liked reading the article. Please feel free to reach me on <a href="https://twitter.com/akash_mercer">Twitter</a> or <a href="https://www.linkedin.com/in/akash-khunt-7690ba95/">LinkedIn</a>. Thank You!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9cbd6110b32" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/app-size-metrics-continuous-monitoring-of-app-size-part-3-d9cbd6110b32">App Size Metrics - Continuous monitoring of App Size, Part 3</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[App Size Metrics - Continuous monitoring of App Size, Part 2]]></title>
            <link>https://proandroiddev.com/app-size-metrics-continuous-monitoring-of-app-size-part-2-bb0fbc91ef2?source=rss-40ca87650612------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb0fbc91ef2</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Akash Khunt]]></dc:creator>
            <pubDate>Tue, 20 Jun 2023 03:34:40 GMT</pubDate>
            <atom:updated>2023-06-20T16:30:18.510Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e-26634ekye9IXMX" /><figcaption>Photo by <a href="https://unsplash.com/@dengxiangs?utm_source=medium&amp;utm_medium=referral">Choong Deng Xiang</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In <a href="https://akashkhunt.medium.com/app-size-metrics-continuous-monitoring-of-app-size-part-1-607f0807fc5c"><strong>Part 1</strong></a>, we discussed about the importance of continuous monitoring of APK size and started implementation of Github Action workflow where the first job was <strong>Generate builds for both base and merge branches</strong>. In this post we’re going to implement the second job i.e. <strong>Generate the size diff report </strong>of the same workflow<strong>.</strong></p><h4>Creating Python Script (to generate the size diff report)</h4><p>This script can itself be divided into following parts:</p><ul><li>Setup</li><li>Generate dictionary - Component category to size mapping</li><li>Generate HTML report - Use the dictionaries generated above to create a human readable HTML output in tabular format</li></ul><p><strong>Setup phase</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/573783425e85855b5dba35faa74b542e/href">https://medium.com/media/573783425e85855b5dba35faa74b542e/href</a></iframe><ul><li>Line 2 &amp; 3 - Here we’re parsing the arguments passed while executing the script</li><li>Line 5 &amp; 6 - We append <strong>.apk</strong> suffix to the above parsed arguments</li><li>Line 9 - This location will be dependent on the GHA runner you’re using. This can be made dynamic based on OS check<strong>.</strong></li><li>Line 15 &amp; 16 - Here we invoke <strong>get_apk_components</strong> function to generate the dictionaries having category name (i.e. Native libraries (arm64-v8a), Classes, Resources, etc) to size mapping.</li><li>Line 18 - Here we invoke <strong>generate_size_diff_html</strong> function which will generate the HTML report comparing the size difference between different categories.</li></ul><p><strong>Generate dictionary phase</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/840479b8e2271eff30a8888fc963fe78/href">https://medium.com/media/840479b8e2271eff30a8888fc963fe78/href</a></iframe><p>In this phase we’re going to use <strong>apk_1_name</strong> &amp; <strong>apk_2_name</strong> generated in <strong>Setup phase.</strong></p><ul><li>Line 32–37 - Here we define a function <strong>execute_command,</strong> whose sole responsibility is to execute the shell command and return the decoded result.</li><li>Line 40–44 - Here we update the <strong>component</strong> dictionary value (i.e. size) in case the provided <strong>key</strong> i.e. (category name) is already present or add a new entry in case the <strong>key</strong> is absent.</li><li>Line 3 - Here we build the <strong>apkanalyzer</strong> command to get the list of all the files bundled into the apk along with their download size. In case you want to read more about different arguments that you can pass, you can refer <a href="https://developer.android.com/tools/apkanalyzer"><strong>this</strong></a>. It took me while to produce the proper command 😅.</li><li>Line 5 - Here we invoke <strong>execute_command</strong> with the command generated in Line 3. The output of this command should look like below where each line contains <strong>file download size in bytes</strong>, <strong>“\t”</strong> separator, &amp; <strong>file name</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CL9Brn7PkbgY_HJ71qTc6A.png" /><figcaption><strong>apkanalyzer</strong> command output example</figcaption></figure><ul><li>Line 6 - Split the <strong>files_with_size_string</strong> with new line character and store it in <strong>files_with_size_list</strong>.</li><li>Line 10 - Here we start looping through each item present in <strong>files_with_size_list.</strong></li><li>Line 11 - Here we further split each item present in <strong>files_with_size_list</strong> using <strong>‘\t’.</strong></li><li>Line 14 - Here we check if the output from Line 11 resulted in a list of exactly 2 items (i.e. <strong>file_size</strong> &amp; <strong>file_name</strong>) and <strong>file_name</strong> is atleast longer than 1 character. This is to filter invalid entries.</li><li>Line 18–27 - Here we add/update the value of each dictionary entry (i.e. Native libraries (arm64-v8a), Classes, Resources, etc) based on <strong>file_name</strong> matching criteria. <strong>NOTE</strong>: This step should be configured based on how you want to categorise your size diff report.</li></ul><p>We‘ll be running <strong>get_apk_components</strong> funtion for both of the apks and end up with <strong>component_1</strong> &amp; <strong>component_2</strong> dictionaries as mentioned in <strong>Setup phase</strong>.</p><p><strong>Generate HTML report phase</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69477b2275e0dda1a43ae5ab389347e4/href">https://medium.com/media/69477b2275e0dda1a43ae5ab389347e4/href</a></iframe><p>In this phase we’re going to generate an HTML table comparing the size of each dictionary entries.</p><ul><li>Line 25–31 - Here we format the size (of dictionary entries and not individual files) from bytes to KB/MB. In case the size is less than a KB then it’s considered as 0KB.</li><li>Line 34–37 - Based on the <strong>size</strong> argument (i.e. size diff of same kind of entry in both the dictionaries), we add 🟢 (for size reduction) or 🔴 (for size increase) indicator.</li><li>Line 40–43 - Calculate overall apk download size using <strong>apkanalyzer</strong> command.</li><li>Line 3–6 - Here we add HTML body content with some text and table row containing <strong>Component</strong>, <strong>Base</strong>, <strong>Merge</strong> &amp; <strong>Diff</strong> items.</li><li>Line 9–12 - Here we iterate through the entries of <strong>component_1</strong> &amp; <strong>component_2</strong> dictionaries and add an entry to the table row.</li><li>Line 15&amp;16 - Here we invoke <strong>apk_size</strong> function to generate the download file size of both base and merge apks.</li><li>Line 18 - Add one final entry to our size diff table containing the total download size comparison between the base and merge apks.</li><li>Line 21 - We write the generated HTML to <strong>apk_size_diff_report.html</strong> file which we will upload for use in the final job i.e. <strong>Add the size diff report as a PR comment.</strong></li></ul><p>Finally the whole script should look like below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a10ef800da50e2e4a5d16faa226af5a/href">https://medium.com/media/6a10ef800da50e2e4a5d16faa226af5a/href</a></iframe><p><strong>Note</strong>: You’ve to put this script in <strong>.github/scripts/</strong> directory to make the following job run.</p><p>Since the apk size compare script is now ready we can start adding second job to our existing workflow that we created previously.</p><h4>Job 2: Generate the size diff report</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40db8752931207bb92d12da08fc47280/href">https://medium.com/media/40db8752931207bb92d12da08fc47280/href</a></iframe><blockquote>To focus only on this job we’ve omitted top-level config as well as the contents of <strong>build</strong> job.</blockquote><p>Line 7–8 - Here we’ve defined the <strong>size_diff_report_file</strong> environment variable as we’re going to use it in this as well as next job. On Line 17 we define dependency on previous <strong>build</strong> job using <strong>needs</strong> config, this will ensure that this job will run only if <strong>build</strong> job gets completed successfully.</p><p><strong>Steps:</strong></p><ol><li>Checkout the code</li><li>Download <strong>head/merge</strong> apk that we uploaded in <strong>build</strong> job</li><li>Download <strong>base</strong> apk that we uploaded in <strong>build</strong> job</li><li>Execute <strong>compare_apks.py</strong> script which will generate <strong>apk_size_diff_report.html</strong> file.</li><li>Upload the <strong>apk_size_diff_report.html</strong> for consumption in next job i.e. <strong>Add the size diff report as a PR comment.</strong></li></ol><h4>Job 3: Add the size diff report as a PR comment</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62a23b8a3b382195fbad91fa69e2ab27/href">https://medium.com/media/62a23b8a3b382195fbad91fa69e2ab27/href</a></iframe><blockquote>To focus only on this job we’ve omitted top-level config as well as the contents of both <strong>build</strong> &amp; <strong>size_diff_report</strong> jobs.</blockquote><p>This is going to be smallest as well as simplest job all 3 jobs as we’re just going to download the size diff report file and then use it’s content to add a PR comment.</p><p>On Line 22 we define dependency on previous <strong>size_diff_report</strong> job using <strong>needs</strong> config, this will ensure that this job will run only if <strong>size_diff_report</strong> job gets completed successfully.</p><p><strong>Steps:</strong></p><ol><li>Download the <strong>apk_size_diff_report.html</strong> file that we generated in previous job.</li><li>Here we first parse the content of the <strong>apk_size_diff_report.html</strong> file to a string and then add it as PR comment to increase the PR reviewer’s visibility on the apk size impact.</li></ol><p>Whole workflow file should look like below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e92255503aa2496e6a2498df1102e40/href">https://medium.com/media/1e92255503aa2496e6a2498df1102e40/href</a></iframe><p>I hope your team is also able to use this workflow (or maybe an improved version 🙂) as a part of your CI pipeline to give you better understanding of how your changes/features are affecting the apk size.</p><p><strong>Reference Material Links and Credits:</strong></p><ul><li><a href="https://developer.android.com/tools/apkanalyzer">https://developer.android.com/tools/apkanalyzer</a></li><li><a href="https://github.com/actions/github-script">https://github.com/actions/github-script</a></li></ul><p>Hope you liked reading the article. Please feel free to reach me on <a href="https://twitter.com/akash_mercer">Twitter</a> or <a href="https://www.linkedin.com/in/akash-khunt-7690ba95/">LinkedIn</a>. Thank You!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb0fbc91ef2" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/app-size-metrics-continuous-monitoring-of-app-size-part-2-bb0fbc91ef2">App Size Metrics - Continuous monitoring of App Size, Part 2</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[App Size Metrics - Continuous monitoring of App Size, Part 1]]></title>
            <link>https://proandroiddev.com/app-size-metrics-continuous-monitoring-of-app-size-part-1-607f0807fc5c?source=rss-40ca87650612------2</link>
            <guid isPermaLink="false">https://medium.com/p/607f0807fc5c</guid>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Akash Khunt]]></dc:creator>
            <pubDate>Thu, 15 Jun 2023 03:05:28 GMT</pubDate>
            <atom:updated>2023-07-12T14:35:58.135Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a1cLZHb-np3gWo7s" /><figcaption>Photo by <a href="https://unsplash.com/@lukechesser?utm_source=medium&amp;utm_medium=referral">Luke Chesser</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>App size is one of the very important metric which impacts the conversion rate. The larger the app size the lower the conversion rate.</p><blockquote>In fact, Google has found a strong correlation between <a href="https://medium.com/googleplaydev/shrinking-apks-growing-installs-5d3fcba23ce2"><strong>APK size and install conversion rates</strong></a>, claiming that install conversion rates drop 1% for every 6MB added to APK size. - Taken from <a href="https://getstream.io/blog/reduce-app-size/#:~:text=Google%20has%20also%20found%20a,6MB%20added%20to%20APK%20size."><strong>GetStream</strong></a> blog.</blockquote><p>Whenever a team tries to reduce the apk size the first thing they do is, measure the app size and the contribution by high level categories (i.e. .dex files, resources, assets, JNI libs), which is generally done via <a href="https://developer.android.com/tools/apkanalyzer"><strong>Apk Analyzer</strong></a> tool (comes bundled with Android Studio). Then the next step is to look for potential improvements via inspecting the size occupied by each of these categories. This process generally involves converting PNG to WEBP, using proguard rules, using vectors instead of raster assets, etc. In case you’re trying to reduce your apk size and want to know what all can be done then you can read <a href="https://proandroiddev.com/my-journey-on-reducing-apk-size-at-getmega-977aabf18068"><strong>this</strong></a><strong>.</strong></p><p>After finishing Size Reduction exercise the thing which often gets missed/ignored is continuous monitoring of the same, which is what we’re going to focus on in this post. Many times teams optimize their apk size but 8–10 months down the line they face the issue of bloated apk size again because they don’t monitors apk size continuously. Continuous monitoring is very helpful because it gives you heads up at the development phase itself and not during later phases like testing (when you might create the release apk for the first time) or release. It also helps you in choosing any 3rd party SDKs when multiple options are available which can suffice your needs. So in this post we’re going to look at how we can implement a solution that can help us with continuous monitoring of apk size.</p><h4>Building the Script</h4><p>To help us with continuous monitoring of the apk size we’re going to build a Github Actions workflow which will generate the apk size diff report (using custom python script) whenever a PR is raised and then adds a comment to the PR, containing the size diff report. The final result should look like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t9ut-jxPA5rMoTwfmkkc8Q.png" /><figcaption><strong>Size Diff Report</strong> comment added by our workflow</figcaption></figure><p><strong>The workflow is divided into 3 jobs:</strong></p><ul><li>Generate builds for both base branch and a merge branch (i.e. head branch + base branch)</li><li>Generate the size diff report (using custom python script &amp; Apk Analyzer tool)</li><li>Add the size diff report as a PR comment</li></ul><h4><strong>Build Configuration</strong></h4><p>This step seems very straightforward but there are some caveats as we can’t just run “<strong>./gradlew assembleRelease”</strong> and then start comparing the apk size. This is because when we build an apk it generally contains the libs/abis for all different supported architectures (i.e. x86_64, armeabi-v7a, arm64-v8a, etc) &amp; resources for all different densities (i.e. mdpi, hdpi, xdpi, etc).</p><p>But since the introduction of <a href="https://developer.android.com/guide/app-bundle"><strong>Android App Bundles</strong></a>, whenever User installs an apk via Play Store, the User gets apk splits very specific to the device in use. This splits include base apk, configurations apks (separate for architecture &amp; screen density), &amp; feature module apks (dynamic feature if used). You can read more about it <a href="https://developer.android.com/guide/app-bundle/app-bundle-format"><strong>here</strong></a>.</p><p>So the first step is to modify our build script so that it allows us to generate apks for a targeted <strong>resConfig</strong> (to select single locale for string resources), <strong>architecture/abi, &amp; density</strong> which will make the comparison easy to understand.</p><p>Configuration for <strong>resConfig</strong> is very straightforward as shown in the below gist.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8b7e045729abe77e03ab8cf406e68d8/href">https://medium.com/media/f8b7e045729abe77e03ab8cf406e68d8/href</a></iframe><p>Here we try to match the <strong>resConfig</strong> property and set it to “en” (i.e. english). This can be supplied via “<strong>./gradlew assembleRelease -PresConfig=en”</strong> command where “<strong>-P”</strong> prefix means it should be treated as a property.</p><p>Next we’ll add configuration for <strong>abi splits</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3fb2b72412d28fcc50914ec839632c8/href">https://medium.com/media/f3fb2b72412d28fcc50914ec839632c8/href</a></iframe><p>Build configuration for <strong>abi splits </strong>is slightly tricky as it involves more steps. First we’ve to enable the splits, then since all the abis are included automatically first we need to clear it and then include the only ones needed. The required abi can be supplied via “<strong>./gradlew assembleRelease -PtargetAbi=arm64-v8a</strong>” command.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ba64f6d77bf58acbb54d112d2e6852d/href">https://medium.com/media/0ba64f6d77bf58acbb54d112d2e6852d/href</a></iframe><p>Build configuration for <strong>density split </strong>is very similar to the abi one and it can be supplied via “<strong>./gradlew assembleRelease -PtargetDensity=xxhdpi</strong>” command.</p><blockquote>After adding configuration for all 3 we can run “<strong>./gradlew assembleRelease -PtargetDensity=xxhdpi -PtargetAbi=arm64-v8a -PresConfig=en</strong>” command, which should generate an apk containing <strong>arm64-v8a</strong> abi, <strong>xxhdpi</strong> density resources and <strong>english</strong> string resources.</blockquote><p>Since the build configuration is now ready we can start implementing the first step of our workflow i.e. <strong>Generate builds for both base and merge branches.</strong> One additional thing we’ll do in this job is renaming the generated apks with short SHA of their respective branches’ HEAD commit, this will make the identification of the apks easier as we’ll be uploading the generated artifacts for later use.</p><p>To generate the short SHA we’ll use following shell script.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/18bf23011fcb2fb8fb20ac61c0769fc4/href">https://medium.com/media/18bf23011fcb2fb8fb20ac61c0769fc4/href</a></iframe><p><strong>Note</strong>: You’ve to put this script in <strong>.github/scripts/</strong> directory to make the following job run.</p><h4>Job 1: Generate builds for both base branch and a merge branch</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/030d34f8eeb4cfcb9ef3e920d1a8bf12/href">https://medium.com/media/030d34f8eeb4cfcb9ef3e920d1a8bf12/href</a></iframe><blockquote>For keeping this post short I won’t go into details of how exactly the Github Actions work as there are many resources available for the same.</blockquote><p>Above script runs whenever a PR is raised against any of the <strong>master, main, release/*, feature/*</strong> branches (Line 8–10). It also takes care of cancelling the in-progress workflow with the help of <strong>concurrency</strong> config (Line 4–6).</p><p>We’ve also specified <strong>outputs</strong> (i.e. <strong>base_short_sha &amp; head_short_sha</strong>) in our <strong>build</strong> job as we’ll be using them for subsequent jobs.</p><p><strong>Steps:</strong></p><ol><li>Checkout the code using <strong>base_ref</strong> (PR target branch)</li><li>Setup JDK 17, which might not be required if you’re using AGP versions below 8.0.0</li><li>Setup Android SDK, which also might not be required based on your target SDK and AGP version in use</li><li>Setup cache to make the subsequent jobs run faster via caching all the gradle files, dependencies and android sdk tooling files</li><li>Generate shorter github sha for base branch - This will be used to rename the apk generated from the same branch</li><li>Build release APK for base branch and rename it to match the short SHA generated in previous step i.e. Step 5</li><li>Upload the apk generated in Step 6 - We’ll download this apk in next jobs and also this allows apk download in case someone needs it</li><li>Checkout the code using <strong>head_ref</strong></li><li>Here we merge the <strong>base_ref</strong> branch to <strong>head_ref</strong> branch to ensure that we’ve all the latest code present in the base branch. This is done to handle the cases where the head branch is not upto date with base branch and some things got added/removed from the base branch.</li><li>Repeat of step 5</li><li>Repeat of step 6</li><li>Repeat of step 7</li></ol><p>Once this job completes successfully we’ll get 2 apks generated and uploaded so that we can use them in next job.</p><p>That’s all for this post. In the next post we’ll implement next job i.e. <strong>Generate the size diff report</strong> which will involve the creation of custom python script using <strong>Apk Analyzer</strong> tool.</p><p><strong>Reference Material Links and Credits:</strong></p><ul><li><a href="https://medium.com/googleplaydev/shrinking-apks-growing-installs-5d3fcba23ce2">https://medium.com/googleplaydev/shrinking-apks-growing-installs-5d3fcba23ce2</a></li><li><a href="https://getstream.io/blog/reduce-app-size">https://getstream.io/blog/reduce-app-size</a></li><li><a href="https://developer.android.com/tools/apkanalyzer">https://developer.android.com/tools/apkanalyzer</a></li><li><a href="https://proandroiddev.com/my-journey-on-reducing-apk-size-at-getmega-977aabf18068">https://proandroiddev.com/my-journey-on-reducing-apk-size-at-getmega-977aabf18068</a></li><li><a href="https://developer.android.com/guide/app-bundle">https://developer.android.com/guide/app-bundle</a></li><li><a href="https://developer.android.com/guide/app-bundle/app-bundle-format">https://developer.android.com/guide/app-bundle/app-bundle-format</a></li></ul><p>Hope you liked reading the article. Please feel free to reach me on <a href="https://twitter.com/akash_mercer">Twitter</a> or <a href="https://www.linkedin.com/in/akash-khunt-7690ba95/">LinkedIn</a>. Thank You!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=607f0807fc5c" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/app-size-metrics-continuous-monitoring-of-app-size-part-1-607f0807fc5c">App Size Metrics - Continuous monitoring of App Size, Part 1</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An ANR Story - How not to freeze when your app is freezing]]></title>
            <link>https://proandroiddev.com/an-anr-story-how-not-to-freeze-when-your-app-is-freezing-1bf204098f70?source=rss-40ca87650612------2</link>
            <guid isPermaLink="false">https://medium.com/p/1bf204098f70</guid>
            <category><![CDATA[android-vital]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Akash Khunt]]></dc:creator>
            <pubDate>Thu, 20 Apr 2023 13:22:47 GMT</pubDate>
            <atom:updated>2023-04-21T02:52:50.964Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A_fKU_ZwGpZ_uoywSqKK9w.png" /><figcaption><a href="https://labs.openai.com/">DALL·E</a> generated image (an intergalactic frozen world)</figcaption></figure><p>In this post we’ll look at the methodology which we can use to categorize and tackle ANRs, as well as how it helped us reduce our <strong>User-perceived ANR</strong> rate by more than <strong>60%</strong> 🤯 by an accident 😅. Since there is a lot of material available around “what is an ANR and how it occurs”, we won’t go into details of that.</p><h4>Categorization</h4><p>First step to understand/resolve any ANR it’s very important to categorize them into whether it’s <strong>User-perceived ANR</strong> or not. This information is readily available in <strong>Android Vitals</strong> on Play Console. As per the definition provided <a href="https://developer.android.com/topic/performance/vitals/anr"><strong>here</strong></a>, any ANR with <strong>Input dispatching timed out</strong> or <strong>Input dispatching timed out (No focused window) </strong>(occurs when an app fails to respond to an input event within 5 seconds) condition can be categorized as the User-perceived ANR ones.</p><p>One of the reason to focus on reducing your User-perceived ANR rate apart from bad User experience is that it’s also a <strong><em>core vital</em></strong> meaning that it affects the discoverability of your app on Google Play.</p><blockquote><strong>Input dispatching timed out (No focused window)</strong> type is not present in the <a href="https://developer.android.com/topic/performance/vitals/anr"><strong>Android Vitals</strong></a> documentation as a <strong>User-perceived ANR</strong> one,<strong> </strong>but it can be confirmed via clicking on <strong>View Issues</strong> in Android Vitals’s User-perceived ANR rate section. Refer following screenshot for reference.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*44pMkbYjamOBxfSSCbVhDg.jpeg" /><figcaption>Android Vitals <strong>Overview</strong> - User-perceived ANR rate</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xGeHgw6lQT3QqTBy3ecHWA.jpeg" /><figcaption>Android Vitals <strong>Crashes and ANRs</strong> -<strong> </strong>User-perceived ANR rate</figcaption></figure><p>In our case Input dispatching timed out (No focused window) type was the biggest culprit in User-perceived ANR rate, raising roughly <strong>80%</strong> of the events<strong>.</strong> The issue here was that though since there is not any documentation on this ANR type we were not sure what exactly <strong>No focused window</strong> meant 😕.</p><p>The second biggest culprit in our overall ANR rate was <strong>Broadcast of intent</strong> type. Even though this is neither user-perceived nor a part of core vital, we wanted to resolve this as well to remove the noise added by it to the overall ANR rate. After looking at the ANR report in Play Console we found that Broadcast of intent type ANRs were happening mainly in the background (more than 99% of cases) and most of them seemed to be related to FCM.</p><p>Since Broadcast of intent ANR type is mainly background one, generic things like doing less work Main thread or doing I/O operation on background thread that we do to resolve mostly Foreground ANRs doesn’t help as these might be happening because of different reasons.</p><p>The reasoning behind Broadcast of intent ANR type can be understood via learning how the Android OS allocates resources during app startup when it’s being launched in Foreground vs Background. When app gets launched in foreground the OS tries to allocate maximum available resources to your app, which can be verified via checking the CPU activity (CPU will be running at ~100%) around the same time. But when your app launches in background then the OS will allocate very minimal amount of resources which might also depend on whether your device is being actively used or is in sleep mode.</p><p>From the above understanding as well after landing on an awesome <a href="https://medium.com/bumble-tech/how-we-achieved-a-6x-reduction-of-anrs-part-2-fixing-anrs-24fedf9a973f"><strong>Medium post</strong></a> published by the Bumble team we understood that if your app receives an FCM while not in RAM then before executing <strong>BroadcastReceiver.onReceive()</strong> your app has to execute <strong>Application.onCreate()</strong>.</p><p>Armed with this learning we started profiling our Application.onCreate() and Content Provider execution time and we found few SDK initializations which were contributing to ~65% of the Application.onCreate() execution time. These SDK initializations were definitely needed during app startup but were not required to handle FCMs so we ended up moving it to out Activity.onCreate() in our single Activity architecture.</p><p>After we released an update with the above mentioned refactoring we were surprised by the results shown on Play Console. We expected the Broadcast of intent ANR type contribution to overall ANR rate go down drastically by 82% (numbers of Users affected went down from 10.9K to 1.6K) but to our surprise the Input dispatching timed out (No focused window) frequency also went down by staggering 99% (numbers of Users affected went down from 78.3K to 609) 🤯. From this we hypothesized that one of the root cause for Input dispatching timed out (No focused window) might be very long execution time of Application.onCreate() only.</p><p>You can check the before and after screenshots of few of the <strong>Input dispatching timed out (No focused window) </strong>and <strong>Broadcast of intent </strong>ANRs below. FYI the overall session count on both of them is very similar (~7% difference).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y73_PjT9gXWSGuPlaEQKxw.jpeg" /><figcaption><strong>Before — Input dispatching timed out (No focused window) ANR type frequency</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6_pc2YwZTIVFaXTes2guow.jpeg" /><figcaption><strong>After - Input dispatching timed out (No focused window) ANR type frequency</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TSyBQDWI7u0LeSz0nGT3gQ.jpeg" /><figcaption><strong>Before — Broadcast of intent ANR type frequency</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-FVwbTo1v2R9uZFgvk3v2A.jpeg" /><figcaption><strong>After — Broadcast of intent ANR type frequency</strong></figcaption></figure><p>Hope this helps in reducing the User-perceived ANR rate for your app as well. 🙂</p><h4><strong>Reference Links:</strong></h4><ul><li><a href="https://developer.android.com/topic/performance/vitals/anr">https://developer.android.com/topic/performance/vitals/anr</a></li><li><a href="https://www.amanjeet.me/demystifying-the-anrs-puzzle/">https://www.amanjeet.me/demystifying-the-anrs-puzzle/</a></li><li><a href="https://medium.com/bumble-tech/how-we-achieved-a-6x-reduction-of-anrs-part-2-fixing-anrs-24fedf9a973f">https://medium.com/bumble-tech/how-we-achieved-a-6x-reduction-of-anrs-part-2-fixing-anrs-24fedf9a973f</a></li><li><a href="https://developer.android.com/topic/performance/benchmarking/microbenchmark-overview#benchmark-consistency">https://developer.android.com/topic/performance/benchmarking/microbenchmark-overview#benchmark-consistency</a></li></ul><p>Hope you liked reading the article. Please feel free to reach me on <a href="https://twitter.com/akash_mercer">Twitter</a> or <a href="https://www.linkedin.com/in/akash-khunt-7690ba95/">LinkedIn</a>. Thank You!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bf204098f70" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/an-anr-story-how-not-to-freeze-when-your-app-is-freezing-1bf204098f70">An ANR Story - How not to freeze when your app is freezing</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sampling Profiler & Rogue Case of App Profiling]]></title>
            <link>https://proandroiddev.com/sampling-profiler-rogue-case-of-app-profiling-54baf646611b?source=rss-40ca87650612------2</link>
            <guid isPermaLink="false">https://medium.com/p/54baf646611b</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[performance-testing]]></category>
            <dc:creator><![CDATA[Akash Khunt]]></dc:creator>
            <pubDate>Tue, 07 Mar 2023 15:15:39 GMT</pubDate>
            <atom:updated>2023-04-20T13:24:18.591Z</atom:updated>
            <content:encoded><![CDATA[<h3>Sampling Profiler &amp; Rogue case of App Profiling</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q8gYXADgHmI4Dem6FCRvzA.png" /><figcaption><a href="https://labs.openai.com/">DALL·E</a> generated image (cartoon of sleeping mammoth in a jungle)</figcaption></figure><p>This is a post about how a false positive performance issue (i.e. <strong>Main thread sleeping for ~1 second during App launch</strong>) made me waste many days in debugging and identifying the root cause. This issue was only observable when profiling a release build, and that is also on a device which was constrained on memory (RAM) and CPU power.</p><h4>Background</h4><p>Let’s cover some background first. If you’ve recently tried your hands on profiling an Android app to identify/debug some performance issues or just to capture Startup Timing metrics, then you might be familiar with very common yet very useful recommendation that you should always profile on <strong>release</strong> builds.</p><blockquote>The rationale behind using <strong>release</strong> builds while profiling is that <strong>debug</strong> builds incur significant and varied performance degradation, and are not useful for measuring timing accurately. This performance degradation can be attributed to one of the many debug build’s capability which allows developers to attach a debugger at any point of time, which requires tracking lot of things like memory and stacktraces.</blockquote><p>But since release builds are meant to be non-debuggable and more performant it doesn’t track anything out of the box and hence are not profileable. To address this issue Android team introduced <a href="https://developer.android.com/guide/topics/manifest/profileable-element"><strong>profileable manifest configuration</strong></a> in API 29 which is safe to be kept even in release builds, which allows us to profile a release build with very less overhead in performance and minimal concern of data exposure as no memory data is readable by the host profiling tools and the shell process.</p><h4><strong>The Issue</strong></h4><p>I faced this Main thread sleeping issue when I was profiling our app on different sets of devices to reduce cold start time. To get the startup timing (i.e. <a href="https://developer.android.com/topic/performance/vitals/launch-time#time-initial"><strong>TTID</strong></a> &amp; <a href="https://developer.android.com/topic/performance/vitals/launch-time#time-full"><strong>TTFD</strong></a>) I created a <a href="https://developer.android.com/topic/performance/benchmarking/benchmarking-overview#macrobenchmark"><strong>macrobenchmark</strong></a> module in my app. The beauty of the macrobenchmark tests is that it also generates <a href="https://developer.android.com/topic/performance/tracing"><strong>Systrace</strong></a> files which you can use to understand what different threads are doing at any point of time. From the test results I found few of the bottlenecks, one of the biggest one being the User attribution callback which involved a network call contributing to 20%–25% of the TTFD time.</p><p>The issue here was that we were making the User wait till we get the attribution data from the network call. From the systrace data on a low-end (<strong>2GB RAM</strong>) device we were also seeing that the Main thread was sleeping for ~1 second 😲 as can be seen in below screenshot.</p><blockquote>Note: Main thread name will be hidden for confidentiality of the app.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*73lgwrtRJTXKFtEzOErB8g.jpeg" /><figcaption><strong>Systrace</strong> showing <strong>Main</strong> thread sleeping for <strong>~1s</strong></figcaption></figure><p>This looked like an easy win in reducing the cold start time so we kicked off the discussion with our product team and got an approval to go ahead with deferred handling of the attribution callback i.e. letting the User continue to our Home page without blocking them.</p><blockquote>Very vigilant eyes might’ve also noticed in the above systrace screenshot that <strong>Jit thread pool</strong> is also running for a decent amount of time which can be reduced significantly by integrating <a href="https://developer.android.com/topic/performance/baselineprofiles/overview"><strong>Baseline Profiles</strong></a>. <em>🙂</em></blockquote><p>After making the appropriate change we ran the tests again and saw our TTFD time do down by <strong>~20%</strong> on a high end device (8GB RAM &amp; Android 13) but on low-end device (2GB RAM &amp; Android 10) it was still very much same. As a first step of troubleshooting we ran the Startup Timing test again (like many other things in life, the first troubleshooting step is always to retry the failed step again 😉) but the result was still same 😅.</p><p>Then I ended up spending few days to identify the issue which might be causing the Main thread to sleep for 1s but didn’t find anything. Then one day I was randomly looking at what every single thread spawned by our app was doing when Main thread went to sleep and finally I found the culprit. It was the <a href="https://android.googlesource.com/platform/libcore-snapshot/+/refs/heads/ics-mr1/dalvik/src/main/java/dalvik/system/profiler/SamplingProfiler.java"><strong>Sampling Profiler</strong></a> thread which was for some reason only seemed alive for 1s (exactly at the same time when Main thread was going to sleep) where for majority of the time it was also sleeping as shown in the below screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MS8bbqXmasUn5pcQkD-Idg.jpeg" /><figcaption><strong>Sampling Profiler</strong> thread being alive and sleeping for 1s at the same time as <strong>Main</strong> thread goes to sleep</figcaption></figure><p>Checking the traces for Sampling Profiler thread I found that it was doing mainly two operation which were <strong>AttachCurrentThread</strong> &amp; <strong>DetachCurrentThread</strong> as shown below<strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iiic5NdtLrzMZotEO2Ea4A.jpeg" /><figcaption>Trace logs of <strong>Sampling Profiler</strong> thread</figcaption></figure><p>I also tried moving a lot of code here and there to see if there was some specific condition which can lead to start this Sampling Profiler thread, one very loose correlation that I saw was whenever Main thread seemed free for few hundreds of millis the Sampling Profiler was spawning to do it’s work.</p><p>As the name “Sampling Profiler<strong>”</strong> suggests it seemed doing some work related to profiling, so we concluded that it should not be affecting actual User sessions. But since we still wanted to be sure about it I removed the <strong>&lt;</strong>profileable<strong>&gt;</strong> element from the Manifest file to ensure that the app is not even profileable when capturing the traces. And since I removed the &lt;profileable&gt; element I was no longer able to run benchmarking tests properly so I ended up using <strong>Capture/Record Trace</strong> option present in <strong>Developer Options</strong> to capture the trace file. And after looking at the trace files we confirmed that the 1s Main thread sleep issue was finally gone 🙌.</p><h4>Conclusion</h4><p>Even though <strong>&lt;profileable&gt;</strong> was adding 1s delay in most of the macro timing metrics i.e. TTID &amp; TTFD it’s not possible to keep it removed as it’s very much needed to run the benchmarking tests. So we finally concluded that before using any kind of macro timing metric on low end devices we will remove 1s from the reported time (after analyzing the trace files).</p><p>Hope this post saves you guys few hours if not days time in debugging an issue which doesn’t even affect actual Users 🙂.</p><h4><strong>Reference Material Links and Credits:</strong></h4><ul><li><a href="https://developer.android.com/studio/profile">https://developer.android.com/studio/profile</a></li><li><a href="https://developer.android.com/guide/topics/manifest/profileable-element">https://developer.android.com/guide/topics/manifest/profileable-element</a></li><li><a href="https://android.googlesource.com/platform/libcore-snapshot/+/refs/heads/ics-mr1/dalvik/src/main/java/dalvik/system/profiler/SamplingProfiler.java">https://android.googlesource.com/platform/libcore-snapshot/+/refs/heads/ics-mr1/dalvik/src/main/java/dalvik/system/profiler/SamplingProfiler.java</a></li></ul><p>Hope you liked reading the article. Please feel free to reach me on <a href="https://twitter.com/akash_mercer">Twitter</a> or <a href="https://www.linkedin.com/in/akash-khunt-7690ba95/">LinkedIn</a>. Thank You!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54baf646611b" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/sampling-profiler-rogue-case-of-app-profiling-54baf646611b">Sampling Profiler &amp; Rogue Case of App Profiling</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fixing Derailed App Cold Start Metrics]]></title>
            <link>https://proandroiddev.com/fixing-derailed-app-cold-start-metrics-5e05c1a9ab4a?source=rss-40ca87650612------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e05c1a9ab4a</guid>
            <category><![CDATA[performance-testing]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Akash Khunt]]></dc:creator>
            <pubDate>Sat, 11 Feb 2023 11:19:47 GMT</pubDate>
            <atom:updated>2023-04-20T13:24:26.922Z</atom:updated>
            <content:encoded><![CDATA[<h3>Fixing Derailed App Cold Start Metric</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zSNPoUfqXmYK77LQ" /><figcaption>Photo by <a href="https://unsplash.com/@bartchristiaanse?utm_source=medium&amp;utm_medium=referral">Bart Christiaanse</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>For last few weeks I’ve been working for a client and one of the major issue that we were facing was the <strong>Slow Cold Start</strong> or <strong>Slow TTID</strong> (Time to initial Display). You can see the Slow Cold Start Metric for your app in Play Console’s <strong>Android Vitals</strong> section.</p><p><strong>Definition taken directly from the Play Console:</strong></p><blockquote><strong>Slow Cold Start</strong> - The percentage of daily sessions in which users experienced at least one cold start-up time of more than five seconds. This is measured as the time taken from when a user launches your app, to when the first frames appear on the screen. A daily session refers to a day during which your app was used.</blockquote><h3>Some History</h3><p>Before we start looking at the issue let’s revise some of the history. Before Android 12 there was no unified way of implementing Splash screen. Developers used to have dedicated activity/fragment with custom theme having background, or custom theme having background applied to the application or in worst case just an activity/fragment without a theme having background (this leads to blank screen being visible before the app draws it’s first frame).</p><p>But with Android 12 Google introduced <a href="https://developer.android.com/develop/ui/views/launch/splash-screen"><strong>Splash Screen API</strong></a> which provided a uniform way of implementing the Splash Screen so every single app on your device shows similar experience on launching the app. Also there is no way for you to avoid this migration as starting Android 12, the system always applies the new Splash Screen for all apps.</p><p>If you look at the migration part in the <a href="https://developer.android.com/develop/ui/views/launch/splash-screen/migrate"><strong>official docs</strong></a> it seems like a very simple process but there is a catch which is not visible unless you read the docs very carefully or you understand the internal implementation.</p><h3>The Issue</h3><p>In our case before migrating to this Splash Screen API our Slow Cold Start metric was very similar to our peers (as reported by Play Console). But after migrating to the Splash Screen API our Slow Cold Start metric spiked up by a huge margin 😢.</p><blockquote><strong>NOTE</strong>: Based on your selection of the app category, Play Console shows you the relative comparison of most of the metrics like ANR, App Size &amp; App Startup issues with your peers in the <strong>Android Vitals</strong> section.</blockquote><p>After we saw the results on the Play Console there was a Panic among the developers as even during the release testing we didn’t found any issues. So to verify the metric we took all the devices we had in our inventory and started measuring the time taken to render the Home Screen, but even after that we didn’t see any problem and that is where we were wrong.</p><p>What we were measuring was the TTFD (Time to full Display) and not the TTID. What Play Console reports is TTID, which is captured by the Android OS automatically. For an example Android OS prints below log for actual <strong>Play Store</strong> app.</p><pre>Displayed com.android.vending/.AssetBrowserActivity: +1s39ms</pre><p>So we also started looking at the logs for our app on different devices and verified that the metrics reported by Play console were correct. This made us think that we must have done some mistake in our migration to Splash Screen API and the metrics got derailed.</p><h3>The Analysis</h3><p>After this we re-looked at all the steps mentioned on the official documentation multiple times to see if we missed something but we found no issue in our implementation. Then we started looking at the docs even more carefully and we caught a glimpse of a very important clue i.e. A SplashScreen is a <a href="https://developer.android.com/reference/android/view/Window">Window</a> and therefore occludes an <a href="https://developer.android.com/reference/android/app/Activity">Activity</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yO56sLRcb6Hn0ijEas9tbw.png" /><figcaption>The clue hinting that <strong>SplashScreen</strong> uses Window directly</figcaption></figure><p>This helped us in connecting the dots as for TTID the app has to draw it’s first frame but since the Splash Screen API directly uses a Window the first frame draw is essentially delayed till some View rendering happens using Activity, Fragment or Dialog.</p><p>To give you some background, earlier we had a dedicated SplashActivity where we were rendering our brand logo and tagline which ensured that the first frame gets rendered on the SplashActivity itself. So even if we do some network call or some other setup before User reaches HomeActivity the time TTID time is very short because SplashActivity has started rendering view via <strong>setContentView()</strong>. But after the migration our first frame rendering was happening on the HomeActivity, which becomes visible after the SplashActivity finishes its job, which made TTID time a lot longer. This was happening because we were not calling <strong>setContentView()</strong> on SplashActivity anymore as the SplashScreen API already renders the content directly on the window.</p><p>We also checked the API implementation to know how exactly it works and we found that first of all it has 2 implementations, one fore API 31+ (Android 12+) and other for the lower Android APIs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lTFFssIOOaP6CB5860MPjA.png" /><figcaption><strong>SplashScreen</strong> implementations</figcaption></figure><p>Another very important implementation detail is the <strong>setKeepOnScreenCondition()</strong> which acts as a boundary toggle between the <strong>SplashScreen</strong> and your own UI rendering via Activity, Fragment or Dialog, as this blocks UI rendering as long as the <strong>condition</strong> predicate evaluates to true.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mFjiYcM210s0PTbEtDyL3g.png" /><figcaption><strong>setKeepOnScreenCondition()</strong> implementation</figcaption></figure><p>Finally having the knowledge of the internals of SplashScreen API we refactored our code such that our <strong>TTID</strong> metric reverted back to previous value 🙂.</p><p><strong>Reference Material Links and Credits:</strong></p><ul><li><strong>Improving App Startup: Facebook App - </strong><a href="https://android-developers.googleblog.com/2021/11/improving-app-startup-facebook-app.html">https://android-developers.googleblog.com/2021/11/improving-app-startup-facebook-app.html</a></li><li><strong>Official Documentation of Splash Screen API</strong> - <a href="https://developer.android.com/develop/ui/views/launch/splash-screen">https://developer.android.com/develop/ui/views/launch/splash-screen</a></li><li><strong>Splash Screen API Migration Guide</strong> - <a href="https://developer.android.com/develop/ui/views/launch/splash-screen/migrate">https://developer.android.com/develop/ui/views/launch/splash-screen/migrate</a></li></ul><p>Hope you liked reading the article. Please feel free to reach me on <a href="https://twitter.com/akash_mercer">Twitter</a> or <a href="https://www.linkedin.com/in/akash-khunt-7690ba95/">LinkedIn</a>. Thank You!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e05c1a9ab4a" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/fixing-derailed-app-cold-start-metrics-5e05c1a9ab4a">Fixing Derailed App Cold Start Metrics</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Baseline Profile, Where Art Thou?]]></title>
            <link>https://proandroiddev.com/baseline-profile-where-art-thou-7d995d9e86f2?source=rss-40ca87650612------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d995d9e86f2</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[baseline-profiles]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Akash Khunt]]></dc:creator>
            <pubDate>Fri, 03 Feb 2023 12:05:28 GMT</pubDate>
            <atom:updated>2023-04-20T13:25:07.871Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pki5DMzgtRrT7SJsdhp4Ow.png" /><figcaption><a href="https://labs.openai.com/">DALL·E</a> generated image (shakespeare searching for something in vaporwave world)</figcaption></figure><blockquote><strong>NOTE</strong>: While not being an actual continuation of my <a href="https://proandroiddev.com/dont-scratch-your-head-scratch-the-files-instead-3a00743fdded"><strong>previous</strong></a> medium post, it’ll be great if you read that as well to get an info on other issues that you might face while measuring the impact of Baseline Profiles on <strong>OPPO</strong>, <strong>OnePlus</strong> or <strong>Xiaomi</strong> devices. <br>Also as there are already many articles and documentation about different app startup states and Baseline Profiles I’m not planning to cover it here, instead if you’re curious you can scroll to the bottom of this post to check the reference links.</blockquote><p>Recently I was on a mission to improve App Cold Start performance for one of my client. I was able to generate the Baseline Profiles without any issues as I have done similar exercises a few times already in the past. I check the impact of it on my <strong>iQOO 7</strong> (specs: SD870G + 8GB RAM + 128GB &amp; Android 13) device and I was able to see a decent improvement where the time spent by <strong>Jit thread pool</strong> during app cold start got reduced to <strong>41ms</strong>, which was <strong>212ms</strong> earlier i.e. <strong>80%</strong> reduction 🙂.</p><p>Then I was very eager to do the same exercise on a budget device <strong>OPPO A15</strong> (specs: Helio P35 + 2GB RAM + 32GB &amp; Android 10) as here the time spent by <strong>Jit thread pool</strong> was <strong>2180ms</strong> (i.e. ~2.2s) so I was expecting to save atleast <strong>1000ms</strong> (i.e. 1s). So I did the benchmarking with a baseline profile build and to my surprise, I saw no reduction in app cold start time 🤔. So I opened one of the systrace generated during the profiling using <a href="https://developer.android.com/studio/profile/macrobenchmark"><strong>macrobenchmark</strong></a> and checked the time spent by <strong>Jit thread pool</strong> which was still very similar i.e. <strong>~2048ms</strong>.</p><p>My first thought was that maybe there was an issue in the test execution so I ran the tests 2 more times but still there was no improvement. Then I thought maybe because Android 10 it’s not working properly, so I checked the <a href="https://developer.android.com/topic/performance/baselineprofiles/overview#compilation-behaviors">documentation</a> and found that it should work on all <strong>Android API24+</strong> devices. Finally, I came to the conclusion that it was time to put the Sherlock hat and get the magnifying glass ready to investigate the issue. 🕵</p><blockquote><strong>Note</strong>: I used AGP version 7.3.1, MacroBenchmark version 1.1.1 &amp; ProfileIntsaller bersion 1.2.2 for measuring Baseline Profile impact.</blockquote><h3>Investigation</h3><p>As I can’t show the actual project that I’m working on for many reasons I’m going to use <a href="https://github.com/android/nowinandroid"><strong>Now in Android App</strong></a> to demonstrate the same issue. I ran Cold Start tests with both with and without Baseline Profile on the same <strong>Oppo A15 </strong>device. As you can see in the below screenshots the time spent by <strong>Jit thread pool </strong>with and without Baseline Profiles was nearly same i.e. <strong>367ms</strong> and <strong>337ms</strong> respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T1WB_lkw7MV7DOsN0CvKZg.png" /><figcaption><strong>Jit thread pool</strong> spending <strong>367ms</strong> on <strong>Oppo A15</strong> device on the tests <strong>w/o Baseline Profiles</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DRZhQouFoYjNGEuQAoJrGg.png" /><figcaption><strong>Jit thread pool</strong> spending <strong>337ms</strong> on <strong>Oppo A15 </strong>device even on the tests <strong>with Baseline Profiles</strong></figcaption></figure><p>For reference you can also see the result of the same tests on iQOO 7 device below where the time spent by <strong>Jit thread pool </strong>with and without Baseline Profiles was <strong>75ms</strong> and <strong>0.6ms</strong> 😲 respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bboU5wBvllG-X3pVPqlKew.png" /><figcaption><strong>Jit thread pool</strong> spending 75<strong>ms</strong> on <strong>iQOO 7 </strong>device on the tests <strong>w/o Baseline Profiles</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZbERNEmZMRo6f_IHNrs9UQ.png" /><figcaption><strong>Jit thread pool</strong> spending <strong>~0.1ms </strong>on <strong>iQOO 7 </strong>device on the tests <strong>with Baseline Profiles</strong></figcaption></figure><p>Then I started digging into the logs generated during the BaselineProfile tests to see if I can find some clue. After spending few hours I found few statements (same count as the test iteration count) saying <strong>“Skipping profile installation for com.google.samples.apps.nowinandroid.benchmark”</strong> as shown below, which made it concrete that for some reason Baseline Profiles were not being installed properly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kvu18nDbeviWC-nayvnydA.png" /><figcaption>Logs indicating that profile installation was skipped for some reason on tests with <strong>Baseline Profiles</strong></figcaption></figure><p>Then I checked all the <a href="https://developer.android.com/topic/performance/baselineprofiles/overview#known-issues"><strong>known issues</strong></a> with Baseline Profiles and finalized two of the points mentioned there that can interfere with Baseline profile installation.</p><ul><li>Battery optimizations may interfere with profile installation. To ensure that your profiles are installed effectively, disable any battery optimizations on your benchmark devices.</li><li>Android Studio Profilers don’t install Baseline Profiles when profiling the app (<a href="https://issuetracker.google.com/issues/232145374">issue</a>).</li></ul><p>I verified that there was no battery optimization enabled on Oppo A15 and battery was also at 100%. About the second issue mentioned above, from the good UX perspective, I thought I should’ve gotten an error if it was the case, similar to the ones we get when doing profiling on device with low battery or an emulator. Finally, I thought about trying latest releases of <a href="https://developer.android.com/jetpack/androidx/releases/benchmark"><strong>macrobenchmark</strong></a> (i.e. <strong>1.2.0-alpha09</strong>) and <a href="https://developer.android.com/jetpack/androidx/releases/profileinstaller"><strong>profileinstaller</strong></a> (<strong>1.3.0-alpha03</strong>) to verify that it’s not an issue with the dependencies that I was using.</p><p>I bumped the versions and then ran the tests again but this time the test threw an error saying “<strong>Check failed”</strong>. This at least made me happy as now I know that there is an issue with baseline profile tests, unlike earlier where if the User doesn’t check the logs then they don’t get to know why the baseline profiles were not working. Then I followed the stacktrace, which led me to <strong>cmdPackageCompile()</strong> function where the result of <strong>“cmd package compile -f -m $compileArgument $packageName”</strong> was being matched to <strong>“Success”</strong> string as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fBLPo2AvsjIZd177TES20g.png" /><figcaption>Tests with Baseline Profiles failing at <strong>CompilationMode.cmdPackageCompile()</strong></figcaption></figure><p>This made me wonder why I this error didn’t happen earlier so I reverted the version bump and checked the same <strong>cmdPackageCompile() </strong>function and saw that in earlier versions the result of the same package compile command was not being asserted 💡, which made it clear why there was no error earlier. For reference you can see the source code of <strong>cmdPackageCompile()</strong> function till <strong>androidx.benchmark:benchmark-*:1.2.0-alpha06 </strong>&amp; above in below screenshots<strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EFVncE7KXSeEvMKDg7qWaA.png" /><figcaption><strong>CompilationMode.cmdPackageCompile()</strong> source code till <strong>androidx.benchmark:benchmark-*:1.2.0-alpha06</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Cvsxul5NQTqMGxHpYf0LA.png" /><figcaption><strong>CompilationMode.cmdPackageCompile()</strong> source code for <strong>androidx.benchmark:benchmark-*:1.2.0-alpha07+</strong></figcaption></figure><p>To verify if this was an OEM i.e. Oppo specific issue, I ran same tests on both Xiaomi and OnePlus devices. On Xiaomi device the tests ran fine but faced a similar issue on the OnePlus device (owned by Oppo now), so finally I concluded that it’s OEM specific issue.</p><p>After this investigation now I know that in case I don’t see any improvement in benchmarks with Baseline Profiles (i.e. JIT is still running at full throttle) then I can either execute below command to verify that if Baseline Profile is even supported on the device or check the logs in the BaselineProfile test. 🙂</p><pre>&quot;adb shell cmd package compile -f -m speed-profile $YOUR_PACKAGE_NAME&quot;</pre><p>Hope this post saves some time while debugging in case the Baseline Profiles are not showing any improvement on Oppo &amp; OnePlus devices atleast.</p><p><strong>Reference Material Links and Credits:</strong></p><ul><li><strong>App Startup Time</strong> - <a href="https://developer.android.com/topic/performance/vitals/launch-time">https://developer.android.com/topic/performance/vitals/launch-time</a></li><li><strong>Baseline Profiles</strong> - <a href="https://developer.android.com/topic/performance/baselineprofiles/overview">https://developer.android.com/topic/performance/baselineprofiles/overview</a></li><li>Rahul Ravikumar from Google does detailed discussion on Baseline Profiles - <a href="https://www.youtube.com/watch?v=m7oRRdud-mY">https://www.youtube.com/watch?v=m7oRRdud-mY</a></li><li>ADS 2022 talk on Baseline Profiles - <a href="https://www.youtube.com/watch?v=yJm5On5Gp4c">https://www.youtube.com/watch?v=yJm5On5Gp4c</a></li><li>Baseline Profile article published on Google Developer’s Blog - <a href="https://android-developers.googleblog.com/2022/01/improving-app-performance-with-baseline.html">https://android-developers.googleblog.com/2022/01/improving-app-performance-with-baseline.html</a></li></ul><p>Hope you liked reading the article. Please feel free to reach me on <a href="https://twitter.com/akash_mercer">Twitter</a> or <a href="https://www.linkedin.com/in/akash-khunt-7690ba95/">LinkedIn</a>. Thank You!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d995d9e86f2" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/baseline-profile-where-art-thou-7d995d9e86f2">Baseline Profile, Where Art Thou?</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Don’t scratch your head, scratch the files instead]]></title>
            <link>https://proandroiddev.com/dont-scratch-your-head-scratch-the-files-instead-3a00743fdded?source=rss-40ca87650612------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a00743fdded</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Akash Khunt]]></dc:creator>
            <pubDate>Sat, 24 Dec 2022 05:43:05 GMT</pubDate>
            <atom:updated>2023-04-20T13:25:14.448Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1oQpGVQJwCPe4jwGLRyysQ.png" /><figcaption><a href="https://labs.openai.com/"><strong>DALL·E</strong></a><strong> generated image</strong> (panda scratching his head in front of laptop in office)</figcaption></figure><p>How many times you’ve faced this issue where you wanted to verify some Java/Kotlin code in your Android app and you ended up putting that code on launch activity to verify that it works properly and spent minutes waiting for code to get deployed on the device/emulator? 🙈</p><h4>Why people do it?</h4><p>Not sure about you, but I’m guilty of doing this a lot of times earlier in my career. Now some of you might be thinking that why not just have a pet Java/Kotlin project for these kind of cases? You’re definitely correct but having Android Studio as my main weapon of choice, doesn’t help much here as it doesn’t provide an option to create/view standalone Java/Kotlin project 😕. And if your argument is to use another IDE (e.g. Intellij IDEA or VS Code) for this then again it doesn’t help here as context switch via opening/switching to different IDE is again a pain.</p><blockquote>Context switching is particularly destructive because it takes a lot of time and effort to pick up where you left off and get back in the zone.</blockquote><h4>Intellij’s Scratch File feature</h4><p>But fret not you don’t need to take any of the above routes as most (maybe all) of the JetBrains IDEs (also applies to Android Studio) already has a really neat feature called <a href="https://www.jetbrains.com/help/idea/scratches.html">Scratch Files</a>, and as the name suggested you can use it to create temporary notes or draft up some code outside the project context.</p><p>You can create scratch files using <strong>⇧ ⌘ N</strong> (on mac) and <strong>Ctrl+Alt+Shift+Insert</strong> (on windows/linux).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FGap_8-UwtoE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGap_8-UwtoE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FGap_8-UwtoE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/624165851fc4337c7a2b3054bdcf5f85/href">https://medium.com/media/624165851fc4337c7a2b3054bdcf5f85/href</a></iframe><h4><strong>Few points to note:</strong></h4><ul><li>Scratch files supports <strong>multiple</strong> languages like HTML, Java, JavaScript, SQL, YAML etc</li><li>These files are not linked to any project and they are present in a common global directory so every scratch file that you will create will be accessible no matter which project you might be working on.</li><li>You can use <strong>Use classpath of module</strong> selection dropdown in case you want to use some code present in your current opened project</li><li>Enable/Check the <strong>Interactive Mode</strong> to execute the code without explicitely executing it using the <strong>Run Scracth File</strong> option present on the top left of the editor window</li><li>One important point to note is that even though you can write some code dependent on Android platform, you won’t be able to execute it using scratch files as you need an Android OS to provide platform functionality.</li><li>There is really nice feature in Intellij IDEA using what you can create scratch file from the selected code as shown in below screenshot. You just need to select the code and hit <strong>⇧ ⌘ N</strong> (on mac) and <strong>Ctrl+Alt+Shift+Insert</strong> (on windows/linux) and use the top most option.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e70sYT_dT2AYvIWaLtkxqw.png" /><figcaption><strong>Scratch File From selection</strong> feature</figcaption></figure><p>You can see a small demo of the Scratch file in action in below gif</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wysCLzE9pmSrocjTU9nrEg.gif" /><figcaption>Scratch File code demo</figcaption></figure><p>And that is it 🙂. I got introduced to this feature roughly 2.5 years back and since then I’ve saved ton of time by not waiting for code deployment to heppen on an device just to verify some basic JAVA/Kotlin code. BTW you might need this rarely atleast for Kotlin/Java code if you’re following TDD where you end up writing unit test cases anyways. I’ve seen these problem mainly in companies where there is no culture of TDD or writing unit tests.</p><p>Hope you liked reading the article. Please feel free to reach me on <a href="https://twitter.com/akash_mercer">Twitter</a> or <a href="https://www.linkedin.com/in/akash-khunt-7690ba95/">LinkedIn</a>. Thank You!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a00743fdded" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/dont-scratch-your-head-scratch-the-files-instead-3a00743fdded">Don’t scratch your head, scratch the files instead</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s new in Modifiers — Notes from ADS’22]]></title>
            <link>https://proandroiddev.com/whats-new-in-modifiers-notes-from-ads-22-e7ace5a85138?source=rss-40ca87650612------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7ace5a85138</guid>
            <category><![CDATA[api-design]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Akash Khunt]]></dc:creator>
            <pubDate>Fri, 04 Nov 2022 10:42:52 GMT</pubDate>
            <atom:updated>2023-04-20T13:25:23.263Z</atom:updated>
            <content:encoded><![CDATA[<h3>What’s new in Modifiers — Notes from ADS’22</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ydgjJ7SBPnm-dOTyHizU9w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@darwiiiin">Darwin Vegher</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This year’s <a href="https://developer.android.com/events/dev-summit"><strong>Android Dev Summit</strong></a> (ADS) got kicked off on October 24 with keynote and Modern Android Development track. They covered a lot of topics ranging from Jetpack Compose, App Architecture, App Performance, Android Studio Tooling support (for both Jetpack Compose &amp; Crashlytics), Relay — a tool for Design handoff (I highly recommend this talk) and much more. In case you haven’t watched it yet I highly suggest you to go through them via <a href="https://www.youtube.com/watch?v=Og2p9LczE3A&amp;list=PLWz5rJ2EKKc_L3n1j4ajHjJ6QccFUvW1u&amp;ab_channel=AndroidDevelopers">this link</a>.</p><blockquote>NOTE: ADS is not yet over. This event is going to have more tracks like <strong>Form Factors (November 9 in London)</strong> &amp; <strong>Platform (November 14)</strong> and later in December in Asia as well. So Stay Tuned. <em>🙂</em></blockquote><p>Even though all the things covered very important and insightful, the topic that got my attention was <a href="https://www.youtube.com/watch?v=BjGX2RftXsU&amp;list=PLWz5rJ2EKKc_L3n1j4ajHjJ6QccFUvW1u&amp;index=25&amp;ab_channel=AndroidDevelopers">Compose Modifiers deep dive</a> by Leland Richardson where he covers the history of how Modifiers came into existence (along with some of the things to consider when designing/building a new UI system), the problems associated with their current state and how they’re evolving (thankfully without any changes on the API surface unless you’re using <strong>Modifier.composed{ }</strong>). Since this was a complex topic I decided to take notes on the same in case I need to refer something in future then I don’t have to scrimmage through the YouTube video (still I highly recommend people to watch the talk atleast once). So the remaining post is my notes on the same and some of the commentary from my end to understand the things covered in the talk.</p><h4>How Modifiers Came into Existence</h4><ul><li>One of the approach to provide paddings (all directions), background color, gradient, border and other properties to each Compose UI Node can be via class variables but that can quickly get out of hand because of the sheer number of properties that an UI component can support.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B5tvy7I5V-7jNEuCuIaTFg.png" /><figcaption>Hypothetical implementation of Compose UI Node</figcaption></figure><ul><li>Then another approach can be to make each of these properties i.e. padding, background color, clickable as standalone Composable but this approach requires each of this composable to have a composable lambda parameter which can accept children, which leads to a problem that Clickable/Padding needs to know about some sort of Layout Policy (which will be utilizied during the <strong>Layout</strong> phase to place the children composables)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ew-mDNbNzZg4_G-LTSrH8Q.png" /><figcaption>Hypothetical implementation of a Composable</figcaption></figure><ul><li>Then came the <strong>Modifiers</strong> which we are using these days which can be chained/cascaded to provide multiple properties to Composables e.g. padding, background color, border, shape, click listeners or even gestures.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ajMvBNpRH-I35jaKasNPlw.png" /><figcaption>Using Modifiers to provide padding, background color &amp; click listener to a Row composable</figcaption></figure><ul><li>Using Modifiers is neat but it could cause a problem if a modifier with some state (e.g. Clickable which has ripple effect animation) is stored as a variable and then passed to two or more different Composables, as each composable needs to have their own animation state. These issue was tackled by using a Modifier.composed { } &amp; materialize() API (which is one of the first thing that gets called in Layout() composable) so that even if same modifier is passed to multiple Composables each of them will get their own state.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vCtSnHsTwoxJLRjichy74A.png" /><figcaption><strong>Modifier.composed {}</strong> &amp; <strong>materialize()</strong> API usage</figcaption></figure><ul><li>Modifier.composed { } API along with materialize() solved the issue of having separate states even if same Modifier is used for multiple Composables but this ended up causing a performance issue because of following reasons.</li></ul><blockquote>- Because Modifier.composed { } has a return type i.e. Modifier and since Composables with return type can’t be skipped during Recomposition.</blockquote><blockquote>- Also since Modifier.composed() is not a composable we can’t even use the all mighty Compose compiler to cache the lambda used earlier to compose a new Modifier which results in the new Modifier composed to be not equal to the one generated earlier even if there was no change.</blockquote><blockquote>- This also causes many remember calls internal to the composed Modifiers to be called unnecessary.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6XYR-8uleV7M1WH2HZCVHA.png" /><figcaption>Here we <strong>can’t</strong> skip composition because clickable function has a return type i.e. Modifier</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3UyBEqclBFnDdJMhjXXixw.png" /><figcaption>since <strong>composed</strong> is <strong>not</strong> a Composable function we can’t memorize the lambda using remember API</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k0tkwFXaiZG5c3EimDf65w.png" /><figcaption>To enable unique state per composable the returned Modifier from composed lambda is never same</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A_AweQuGfwvwPHDbDZiIPA.png" /><figcaption>As <strong>composed</strong> API is used to store some kind of state by Modifiers, remember calls required to cache the state</figcaption></figure><blockquote>Even though it seemed like a big problem, the assumption was that <strong>Modifier.composed {}</strong> API will be required only in very few special cases, but it ended up being wrong. <em>😅</em></blockquote><h4>Modifiers in Practice &amp; the problems associated with it</h4><ul><li>The Text composable with just a Modifier.clickable{} seems very simple but Modifier.clickable{} internally cascades to more modifiers like semantics(), onKeyEvent(), indication(), pointerInput() and so on plus the Text Composable which might look very innocent, uses TextController internally which also creates it’s own Modifiers (check <a href="https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt;l=498?q=TextController">TextController.modifiers</a> for better understanding) which are responsible for rendering the text, semantics &amp; selections (i.e. which facilitates the Cut, Copy functions that we get on selecting a text). So for a simple Text Composable with just clickable modifiers leads to having some 20+ cascaded Modifiers 😲. Check below screenshots for reference:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7NocJo8_oYnFpOwq0kizKQ.png" /><figcaption>Column with two Text composables</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nX3qP_n6N-xD_Ao-OWel_g.png" /><figcaption>UI tree having a Layout with two Text composables with one of them having clickable Modifier</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kHh0h0wjFwLdQhuv7x0weg.png" /><figcaption>Mental model of the Modifier chain generated for a Text composable with clickable Modifier</figcaption></figure><ul><li>If we aggregate the the contents of Modifier.clickable{} then we can see the result having (below Compose 1.3.0-beta01 at least): <br>- <strong>13 Modifier.composed calls<br>- 34 remember calls<br>- 11 Side Effects<br>- 16 Leaf Modifier.Elements</strong></li></ul><blockquote>What above point essentially means is that when we apply clickable {} modifier to a Composable</blockquote><blockquote>- On composition it’ll end up calling materialize() for all of the 13 <br>Modifier.composed calls then all the remember calls held inside also gets called</blockquote><blockquote>- Which then allocates memory for Entity objects (i.e. objects that manage behaviours between different subsystems and dispatch things to these Modifiers 😵‍💫😵‍💫…🤷) for each modifier</blockquote><blockquote>- On Recomposition we end up allocating new Modifiers which calls materialize() for all composed Modifiers then the old Entity objects gets disposed and new ones gets allocated</blockquote><ul><li>The key takeaway here is that many of the Modifiers needs to have their own state and that state is applied per layout node. And these was only possible by Modifier.composed{} API before Compose 1.3.0-beta01 release where experimental support for Modifier.Node got implemented</li></ul><h4>Evolution of Modifiers staring Compose 1.3.0-beta01</h4><ul><li>In Compose 1.3.0-beta01 experimental support <strong>Modifier.Node</strong> got implemented as an alternative to Modifier.composed{} which is more performant (<strong>NOTE</strong>: This migration will happen over multiple releases and is still WIP)</li><li>With the introduction of Modifier.Node all the modifiers like padding, background, even clickable will be treated as a new type of lightweight immutable Modifier.Element which knows how to maintain an instance of a corresponding Modifier.Node class.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AqXkMB81HH1FKPTSK5Pl-g.png" /><figcaption>On first composition Modifier chain creates their own <strong>Modifier.Element</strong> instance</figcaption></figure><ul><li>These Modifier.Element classes also gets a create() function which then creates/allocates Modifier.Node instances. These Node instances are directly part of the UI hierarchy and they have the same lifecycle as the layouts they are applied to, which makes them ideal owners of the state for the modifiers that need it like clickable.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y0zsCB3QVJlOVwUcC1CPmQ.png" /><figcaption><strong>Modifier.Element</strong> calling <strong>create()</strong> to instantiate <strong>Modifier.Node</strong> instances</figcaption></figure><ul><li>Now talking about the earlier scenario when the recomposition happens, we don’t need to create new modifiers for the whole modifier chain because these <strong>Modifier.Element are immutable and can be compared easily</strong>. So we end up creating and applying Modifier.Element &amp; Modifier.Node only for the changed modifiers in the whole chain. So in current case since on only the <strong>padding</strong> Modifier value changed from <strong>10.dp -&gt; 16.dp</strong>, only <strong>padding Modifier.Element </strong>calls <strong>update()</strong> to update PaddingNode and the remaining Modifier.Element don’t do any unnecessary computation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QXmLXxSwZaYuHGfo6ClLYA.png" /><figcaption>On recomposition Modifier chain gets evaluated again</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fp4eAv7vFo7IKWg22WENlg.png" /><figcaption>On recomposition <strong>only padding</strong> Modifier.Element calls update() to update the PaddingNode</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pc46dPnk7fLrbDm2Yf9yyQ.png" /><figcaption>Benefits of the new <strong>Modifier.Element</strong> &amp; <strong>Modifier.Node</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZlSnKWhGCPVM5OY1u75u7w.png" /><figcaption>Takeaways of the new <strong>Modifier.Element</strong> &amp; <strong>Modifier.Node</strong></figcaption></figure><p>Alas, we’ve reached the end! 🙌 By this point you might be thinking that this seems a bit more complex and might not be needed to know as well since it’s an internal implementation (as mentioned earlier unless you’re using <strong>Modifier.composed {}</strong> API directly just updating to <strong>Compose 1.3.0-beta01</strong> version should be sufficient to get the performance benefits of the internal changes) but it’s always better to get an idea about how things are working internally and the challenges faced in designing them. 🙂</p><p>Hope you liked reading the article. Please feel free to reach me on <a href="https://twitter.com/akash_mercer">Twitter</a> or <a href="https://www.linkedin.com/in/akash-khunt-7690ba95/">LinkedIn</a>. Thank You!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7ace5a85138" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/whats-new-in-modifiers-notes-from-ads-22-e7ace5a85138">What’s new in Modifiers — Notes from ADS’22</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The missing pieces of text alignment in Compose Text]]></title>
            <link>https://proandroiddev.com/the-missing-pieces-of-text-alignment-in-compose-text-50efec9bc387?source=rss-40ca87650612------2</link>
            <guid isPermaLink="false">https://medium.com/p/50efec9bc387</guid>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Akash Khunt]]></dc:creator>
            <pubDate>Mon, 10 Oct 2022 02:17:32 GMT</pubDate>
            <atom:updated>2023-04-20T13:25:29.282Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fRwy1Ig_Q2jz88pa" /><figcaption>Photo by <a href="https://unsplash.com/@rosssneddon?utm_source=medium&amp;utm_medium=referral">Ross Sneddon</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I’ve been reading and learning about Jetpack Compose since June 2021 but because of my work on KMM side of things, I wasn’t able to spend time or write Jetpack Compose code actively. But things have changed since last month and now I’m focusing a lot more on Jetpack Compose.</p><p>Recently I was developing some UI and I had to create a bordered Text composable where the text will be in the center. It sounded very straightforward at the start coming from old View system but it made me spend more than an hour in figuring out that it’s doesn’t work the same way as it used to work with TextView in old View System.</p><blockquote><strong>Edit</strong>: After doing a bit more research I found that there is a modifier function called Modifier.wrapContentHeight(align: Alignment.Vertical) which allows us to center align the text content inside a Text composable of any height. Although with this we can achieve our goal of centering the text but it still seems somewhat disjoint as <strong>Horizontal</strong> alignment is taken care by <strong>textAlign</strong> (which is a property in Text composable) and <strong>Vertical</strong> alignment is taken care by <strong>wrapContentHeight</strong> (which is a Modifier function)<strong>.</strong></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9fdb22dab5c09882054b13b19887d39/href">https://medium.com/media/d9fdb22dab5c09882054b13b19887d39/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*dRwZiUAxiblE0qlr6sPnxA.png" /><figcaption>Preview generated using <a href="https://gist.github.com/bastionkid/13f96f3cdda00d0210827b5f39eddfdf">CenterAlignedText</a></figcaption></figure><h3>The Issue</h3><p>To understand the issue I faced let’s go through a very small example first as shown in the below screenshot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZphJBARXDd0EBwlEETd6Dg.png" /><figcaption>Jetpack Compose example showing a Row having <strong>Text</strong> components</figcaption></figure><p>As you can see in the above screenshot, I needed to have bordered <strong>Text</strong> composables with the height same as the parent <strong>Row</strong> and wanted to center align the text. So to achieve the desired alignment I first tried with <strong>TextStyle.textAlign</strong> property along with <strong>TextAlign.Center</strong> value. But after the preview refreshed I saw that the text content was only horizontally center aligned and not center aligned in both directions 🤔 i.e. (horizontal &amp; vertical) as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H9JiKm663DUSXJ5BgRJVpg.png" /><figcaption>Result after applying <strong>textAlign = TextAlign.Center</strong> to <strong>TextStyle</strong></figcaption></figure><p>Maybe some of you might already be thinking that I could’ve used <strong>Modifier.align()</strong> to achieve the desired behaviour, but it doesn’t work in current use-case because the Text composable is already having max width &amp; height so the Modifier.align doesn’t help here. 😅</p><p>This made me re-think how I could’ve achieved the same in old View system. So I ended up writing a sample code as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A9Yq8G9XsO6jndOlZJwBcA.png" /><figcaption>Implementation of somewhat desired behaviour in old View system</figcaption></figure><p>As you might already be knowing that achieving the same in View system just requires <strong>android:gravity</strong> attribute with <strong>center</strong> flag. If you’re curious below is the list of all the flags that you can use as a value for <strong>gravity</strong> attribute. And the best part of this attribute was that you can use <strong>bitwise or “|” </strong>operator to use multiple flags in conjunction as well e.g. <strong>“top|center”</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RH7NDCyprKuGQmlNLpXSkQ.png" /><figcaption>list of supported flags for <strong>gravity</strong> attribute</figcaption></figure><p>Looking at all the above flags I though about checking the all the supported <strong>TextAlign</strong> values. So I opened the <strong>TextAlign</strong> class and the listed options seems very few which seemed like <strong>1-D alignments</strong> and the comment above <strong>Center</strong> was definitely misleading 😅 (as it just does <strong>center aligning in only horizontal direction</strong>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2LnZCkW1xHPsvcDWiPqHqw.png" /><figcaption><strong>TextAlign</strong> supported values</figcaption></figure><p>After looking at the content of this I finally realized that I wasn’t doing something wrong from my end but there is a bit of an issue in the documentation i.e. <strong>center alignment feature doesn’t work the same as way as you might expect</strong>. This also made me curious about all the supported values in <strong>Modifier.align()</strong>. So I checked <strong>Alignment</strong> class file and was pleased to see that they even divided different supported values into different sections like <strong>2D Alignments, 1D Vertical &amp; 1D Horizontal</strong> which must be related to 1D alignment support in <strong>ColumnScope</strong> &amp; <strong>RowScope 🙂</strong>. Ideally I would’ve liked to see all the values supported in <strong>Alignment</strong> in <strong>TextAlign</strong> as well but sadly that’s not the case atleast at the moment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C8bguHcEir7ei186rjEaAg.png" /><figcaption><strong>Alignment</strong> supported values</figcaption></figure><p>Finally to achieve the desired result I ended up wrapping my <strong>Text composable in a parent Box composable</strong> which will take care of both the alignment and drawing the border. The fix was simple but the wrapping it in another composable seemed redundant even though in the penalty of doing it in compose world might be negligible compared to the old View System.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FxqtkDiZUtxquv53EmZ_vA.png" /><figcaption>Wrapping the Text in Box composable to achieve the desired behaviour</figcaption></figure><h3>Fun Fact</h3><p>When I was digging into how exactly the gravity attribute works for <strong>TextView</strong>, I ended up looking into the contents of <strong>TextView.setGravity()</strong> and saw an interesting constant named <strong><em>UNKNOWN_BORING</em></strong><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4BMqkOXGhYJuQNSSfT8X0Q.png" /><figcaption><strong>TextView.SetGravity()</strong> implementation and <strong>UNKNOWN_BORING</strong> usage</figcaption></figure><p>The first thought that came to my mind was Elon Musk’s <strong>The Boring Company</strong>, which sounded very weird at first when I heard it a few years back but after learning what they are into it made sense. So it made me curious what might be the reason in this context. So after a little bit of digging, I landed on a class named BoringLayout and looking at the comment made me laugh a bit. 😂</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IA7Kd8hnzcHxvsQM_cXuNw.png" /><figcaption><strong>BoringLayout</strong> class in <strong>android.text </strong>package</figcaption></figure><p>This made me remember the quote that I read few years back on <a href="https://martinfowler.com/bliki/TwoHardThings.html">https://martinfowler.com/bliki/TwoHardThings.html</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dO2R_jIWacPYqAffxny-BA.png" /><figcaption>TwoHardThings quote on <a href="https://martinfowler.com/bliki/TwoHardThings.html">https://martinfowler.com</a></figcaption></figure><p><strong>BoringLayout</strong> name proves that naming things in software development is a tough job indeed. 😂</p><p>Hope you liked reading the article. Please feel free to reach me on <a href="https://twitter.com/akash_mercer">Twitter</a> or <a href="https://www.linkedin.com/in/akash-khunt-7690ba95/">LinkedIn</a>. Thank You!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50efec9bc387" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/the-missing-pieces-of-text-alignment-in-compose-text-50efec9bc387">The missing pieces of text alignment in Compose Text</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>