<?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 Sripadraj K R on Medium]]></title>
        <description><![CDATA[Stories by Sripadraj K R on Medium]]></description>
        <link>https://medium.com/@sripadrajkr?source=rss-7e604e96c0b7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*bFpLR-v05ajbNGUL.</url>
            <title>Stories by Sripadraj K R on Medium</title>
            <link>https://medium.com/@sripadrajkr?source=rss-7e604e96c0b7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 07:34:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sripadrajkr/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[How to make your apk slim?]]></title>
            <link>https://medium.com/@sripadrajkr/how-to-make-your-apk-slim-46e718f77b7f?source=rss-7e604e96c0b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/46e718f77b7f</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[proguard]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Sripadraj K R]]></dc:creator>
            <pubDate>Thu, 09 Aug 2018 12:59:24 GMT</pubDate>
            <atom:updated>2018-08-10T10:09:06.608Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever checked your apk before publishing to Google Play or before sharing it to whoever you want? 🤔 I always thought that the apps size would be insignificant. Earlier I never used to care how big the app’s size used to be. Over the years, I realized that the users do care about the size of the app before installing 😅. I have tried to list down the steps I took to reduce the apk size.</p><p>Let’s see how we can bring down the size of the apk. 😃</p><ol><li><strong>Remove Unwanted Classes and Layout Files</strong></li></ol><p>Unused classes, layout files and other unused files add up to the size of the apk. It is always better to remove them.</p><p><strong>2. Use vector images instead of png.</strong></p><p>Use vector images as they are scalable through out all screen sizes and you can also change the color of the vector through their fillColor property. Where as PNG images are not scalable and images need to be of different sizes for different resolutions. There are chances that the png images could get distorted at different screen sizes.</p><p>Android Studio provides a handful of icons where you can use them in your projects. You can add them by <strong>right click </strong>on drawable folder and <strong>New&gt;Vector Asset. </strong>A window pops up to select the icon of your choice and configure it. You could select from the stock icons or you could import a PSD or SVG file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kc4weQdICfQ5jcRsJUQzfA.png" /><figcaption>Asset Studio window</figcaption></figure><p>Click on the <strong>Icon </strong>to select from the stock icons.</p><p><strong>3. Use WEBP images instead of JPEG/PNG</strong></p><p>Android now supports WEBP images which take up very less space than their JPEG/PNG versions. Android Studio has a tool where you can convert your images to WEBP.</p><p>Right click on the image you want to convert to WEBP and click on the last <strong>Convert to WebP </strong>option like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*0aO5iXbjRuFnJ99kVGJyKg.png" /></figure><p>A window opens up to compare the size of the original image and webp. There had been few instances that the webp image size was slightly higher than their original ones. In that case you can use the original.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1-rTtdvms4CH5kPLnRKxbg.png" /><figcaption>546KB to 11KB!! Now that’s the power of WebP. 😎</figcaption></figure><blockquote>Do not keep your hefty images in the resource folders. You should keep them in the cloud and load them on demand.</blockquote><p><strong>4. Enable </strong><strong>shrinkResources</strong></p><p>You could reduce the resources size in your build. You just need to add below line in your build.gradle file’s release block.</p><blockquote>shrinkResources true</blockquote><p><strong>5. Use Proguard 💂</strong></p><p>Proguard is a very effective tool to bring down the size of your app. Proguard strips down unused classes, unused methods. <strong>The resulting apk will be 50–60% less than your original apk.</strong></p><p>Another benefit of Proguard is that it obfuscates the code so that it slows down the hacker to reverse engineer your apk. To enable proguard add the below line in your release block of build.gradle</p><blockquote>minifyEnabled true</blockquote><p>Be sure about the classes you want to obfuscate. You can add the classes you want to white list from obfuscation in proguard-rules.pro file. You can do so using the -keep followed by the class name.</p><blockquote>-keep class com.example.SampleClass</blockquote><p>You may come across some warnings/errors while using proguard. Those could be of the libraries that you’re using. You can tell the proguard not to warn from such classes. You can do that by using -dontwarn following by the class name or the package name.</p><blockquote>-dontwarn com.example.**</blockquote><p>It will take few trials to get a hang of proguard tool to get it right. The app might crash. But play around with dontwarn and keep key words with the classes and you should be able to crack it.</p><p>All these steps helped me to bring down my apk from ~5MB to ~1.9MB. 😎</p><p>Do try the above steps in your projects as well and give feedback if it worked out for you 👍. Do let me know if there are other methods which I might have missed out. And don’t forget to give some claps 👏😉</p><p>Also do read my previous post on Why I love Kotlin. 😄</p><p><a href="https://medium.com/@sripadrajkr/why-i-started-loving-kotlin-extension-functions-and-higher-order-functions-db099d493147">Why I started loving Kotlin : Extension Functions and Higher Order Functions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46e718f77b7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I started loving Kotlin : Extension Functions and Higher Order Functions]]></title>
            <link>https://medium.com/@sripadrajkr/why-i-started-loving-kotlin-extension-functions-and-higher-order-functions-db099d493147?source=rss-7e604e96c0b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/db099d493147</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Sripadraj K R]]></dc:creator>
            <pubDate>Mon, 23 Jul 2018 10:04:41 GMT</pubDate>
            <atom:updated>2018-07-23T10:23:17.415Z</atom:updated>
            <content:encoded><![CDATA[<p>I had been always keen to use Kotlin while developing android apps. I had been following Kotlin since it came out. But somewhere in the corner I was scared to try it. And finally the day came where I took the dare to start writing code in Kotlin and till day I’ve never stopped loving it.</p><p>IMO Kotlin is all about writing concise code.</p><p>Kotlin is feature abundant. Some features are :</p><ul><li>Interoperability with Java</li><li>Extension Functions</li><li>Higher order Functions</li><li>Null safety</li><li>Smart Casting etc.</li></ul><p>The feature I loved is writing the Extension Functions and Higher order Functions.</p><p>Extension functions is adding extended functionality to existing classes without editing the native code. There was a case in a group of 15 checkboxes where I had to return “Y” when a checkbox was checked and return “N” when checkbox was unchecked. Then I thought <em>Why not use a common function which can return a string on checked and unchecked?</em></p><p>Enter Extension Function: The Class I wanted to extend was CheckBox. So my extension function would look like:</p><pre>fun CheckBox.isCheckedEx(): String{<br>    return if(this.isChecked){<br>        &quot;Y&quot;<br>    }else{<br>        &quot;N&quot;<br>    }<br>}</pre><p>And I could use this function like:</p><pre>var cb1Val = cb_something.isCheckedEx() // cb_something is the id of the checkbox in the XML layout.<br>var cb2Val = cb_something2.isCheckedEx()</pre><p>I was wondering how I could write this in Java. but I was like <em>meh, nevermind.</em></p><p><strong>Higher order Functions:</strong></p><p>Higher order functions are such functions which can take functions as param or can return a function.</p><p>It happened to implement to do various things on text change event and I was too lazy to write individual text watchers to EditTexts or Implementing it on the Activity or Fragment I thought it would make my class messy and hard to read. So I decided to <em>pass functions as parameter to another function.</em> Something like this:</p><pre>fun EditText.onTextChanged(doStuff:()-&gt;Unit){<br>    this.addTextChangedListener(object :TextWatcher{<br>        override fun afterTextChanged(p0: Editable?) {}<br><br>        override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {}<br><br>        override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {<br>                doStuff()<br>        }<br>    })<br>}</pre><p>Now I can pass any function to the above function as param in the place of doStuff and that function is called onTextChanged event of the EditText. I could use this function as</p><pre>//et_pincode is view id in XML layout<br>et_pincode.onTextChanged( <strong>{<br>    </strong>hideKeyBoard()<br><strong>}</strong>)</pre><p>I hope I could convince you <strong>Why I love Kotlin.</strong></p><p><strong>Bonus points: </strong>Oh and yes, we can avoid using findViewById and there’s no ; in Kotlin. 😇</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db099d493147" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>