<?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 Oussama Hafferssas on Medium]]></title>
        <description><![CDATA[Stories by Oussama Hafferssas on Medium]]></description>
        <link>https://medium.com/@oussama.haff?source=rss-90f7b34be612------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Q24QHqQ4TTN8DRqK8vb_oA.jpeg</url>
            <title>Stories by Oussama Hafferssas on Medium</title>
            <link>https://medium.com/@oussama.haff?source=rss-90f7b34be612------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 00:49:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@oussama.haff/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[Hunting a bug — A True App Bundle Debugging Story]]></title>
            <link>https://proandroiddev.com/hunting-a-bug-a-true-app-bundle-debugging-story-b8898767f8e3?source=rss-90f7b34be612------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8898767f8e3</guid>
            <category><![CDATA[bundletool]]></category>
            <category><![CDATA[android-app-bundle]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[google-play-store]]></category>
            <dc:creator><![CDATA[Oussama Hafferssas]]></dc:creator>
            <pubDate>Sat, 27 Jul 2019 18:49:20 GMT</pubDate>
            <atom:updated>2019-07-29T07:27:37.879Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hunting a bug — A True App Bundle Debugging Story</h3><p>As Android developers, we tend to write about best practices, trending architectures, new libraries and so on, but we rarely find detailed articles about bugs despite of having them all the time ! Therefore, in this article I will focus on the problem-solving mindset behind resolving a mysterious bug that we have faced when trying to publish our Android App using the new format App Bundle instead of APK for the first time. I will share all the steps of the investigation, and especially the reason behind every step.</p><blockquote>I have successfully reproduced the bug with the same symptoms in a<a href="https://github.com/hfrsoussama/TestingAndroid"> small demo project</a> which I’ll be using in this article.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EW8ik9NYuGmS4T8-yD5O7A.png" /><figcaption>Eagles can see their targets from 3 kilometers away (2 miles) [Photo taken by <a href="https://www.flickr.com/photos/jtoreli/">jim toreli</a> — CC0]</figcaption></figure><h3>Summary</h3><ul><li>What is Android App Bundle ?</li><li>What was the problem that we have faced ?</li><li>How did we drive the investigation ?</li><li>The — Eurêka ! — moment</li><li>Final thoughs</li></ul><h3>What is Android App Bundle ?</h3><p>Since the beginning of Android, we had only one format as a result of assembeling Android Apps, called APK (for Android Package). This package can be installed directly on a device and can be also uploaded on the Google Play Console to be delivered to the users.</p><p>Android App Bundle (<strong><em>.aab</em></strong> file extension) is the new format to be used when uploading apps to the Play Store. The Play Store will use this Bundle to generate small signed APKs and dynamically deliver them to the users respecting their device’s CPU architecture, screen density and even language.</p><blockquote>[read] The official Android Doc <a href="https://developer.android.com/guide/app-bundle/">here</a><br>[watch] The Android Dev Summit presentation <a href="https://www.youtube.com/watch?v=QdoEcfibG-s">here</a></blockquote><h3>What was the problem that we have faced ?</h3><p>Just like in our real app, I added support for App Bundle in our demo app, and I have restricted the generation of the small APKs by device architecture and by screen density by adding this block to our app’s <em>build.gradle</em> file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/35e3a1c45ec3bcd3b3b95156ebc03543/href">https://medium.com/media/35e3a1c45ec3bcd3b3b95156ebc03543/href</a></iframe><p>I’ve generated a signed release App Bundle (<em>.aab</em> file) with Android Studio and I tried to upload it to the Google Play Console for internal testing. The uploading of the file passed successfully, and then the console started generating APKs from the bundle that I have uploaded.</p><p>Strangely, the process of generating APKs stops and the Play Console shows this error :</p><blockquote>Upload failed<br>Your APK cannot be analyzed using aapt. Error output:<br>Failed to run aapt dump badging:<br>W/ResourceType(163870): No known package when getting value for resource number 0x010c00a1<br>AndroidManifest.xml:26: error: ERROR getting ‘android:label’ attribute: attribute value reference does not exist</blockquote><h3>How did we drive the investigation ?</h3><h4>Attempt 1 : Verifying the installation via a normal APK</h4><p>Hypothesis — Maybe there were some code added accidentally before generating the bundle.</p><p>I generated a normal signed release APK with Android Gradle Plugin and installed it on a device, the build passes without warning and the app is installed and works perfectly.</p><p>— Hypothesis dismissed ❌</p><h4>Attempt 2 : Generating the bundle with the Android Gradle Plugin</h4><p>Hypothesis — May be it’s a bug affecting Android Studio.</p><p>It’s possible — and recommended — to generate the app bundle using the Android Gradle Plugin via the dedicated Gradle task by running the command <strong><em>./gradlew bundleRelease</em></strong>. The app build script contains the signing key configurations. Therefore, the generated bundle will be signed properly.</p><blockquote>You must have at least version 3.2.0 of AGP to be able generate App Bundles</blockquote><p>When I uploaded the new generated bundle I had the same issue..</p><p>— Hypothesis dismissed ❌</p><h4>Attempt 3 : Testing the generated bundle with “Bundletool”</h4><p>Hypothesis — May be it’s a bug affecting the Google Play Console !</p><p>As explained before, when Google Play Console receives the bundle file, it startes generating small signed APKs depending on the split type that we have activated (in our case it’s screen density and CPU architecture).</p><p>Behind the scenes, Google Play Console uses an open source tool called <strong><em>Bundletool</em></strong> to generate and sign these deployable APKs. So, I have downloaded the tool (<a href="https://github.com/google/bundletool/releases"><em>from here</em></a>), and I started by generatings signed APKs using the command :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9AnyPBvmv26Ca8lG_O2NJg.png" /></figure><p>The result of this command will be a file having <strong><em>.apks</em></strong> as extension. Which is in fact a zip file having multiple signed APKs inside, split by screen density and architecture.</p><p>At this level, I was convinced Bundletool is working properly because it could generate APKs without having any error. But in order to remove any doubt, I tried to install the app from this <em>.apks</em> file on a connected device using this command :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_pMw7bnDJDuSCYcTKPOxPw.png" /></figure><p>When checking the device, I found that the app was successfully installed and it works like a charm ! I have repeated the test for both bundles : the one generated with Android Studio and the one generated with Android Gradle Plugin. Conclusion : the tool works fine on my machine.</p><blockquote>[read] the official doc about Bundletool <a href="https://developer.android.com/studio/command-line/bundletool">here</a></blockquote><p>- Hypothesis dismissed ❌</p><h4>Attempt 4 : Verifying the resource value</h4><p>Hypothesis — May be the String resource used for the attribute android:label in the application declaration has been deleted accidentally.</p><p>Using Android Studio’s shortcut (<em>shift + cmd + F</em>) I’ve searched for all declarations that matches <strong><em>android:label=”</em></strong><a href="http://twitter.com/string/app_name"><strong><em>@string/app_name</em></strong></a><strong><em>”</em></strong>. Knowing that each module can bring is own application label, I’ve checked the presence of the string in each module’s <em>strings.xml</em> file.</p><p>In our demo app, we will find two usages, one for each module (<strong><em>app</em></strong> module and <strong><em>mybugsourcelib</em></strong> modules), the strings used for the declaration are properly declared in the two modules (Defined as “<em>Testing Android</em>” for app module and “<em>MyBugSourceLib</em>” for the second module).</p><p>— Hypothesis dismissed ❌</p><h4>Attempt 5 : Verifying the merged Manifest</h4><p>Hypothesis — May be there have been an error when merging Manifests coming from the project libraries and modules.</p><p>When building the app the Gradle build merges all manifest files into a single Android Manifest file which will be packaged into the final APK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*risIGrQt_0LHXMa8y9OgUQ.png" /><figcaption><a href="https://developer.android.com/studio/build/manifest-merge#merge_priorities">The process</a> to merge three manifest files, lowest priority (left) into highest priority (right)</figcaption></figure><p>After finishing the merge, Gradle build generates a report about the merge operation and put it in a text file named<strong><em> manifest-merger-release-report.txt</em></strong> under<em> app/build/outputs/logs</em>. I opened this file and I searched for <em>android:label</em> to see if I can find some clues. I have found 02 matches.</p><ul><li>The first match —</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bSFKlUWXv8s48oZg4OrcsA.png" /><figcaption>Part from the manifest-merger-release-report.txt file</figcaption></figure><p>As we can see, the log says that the manifest merger has added an <em>android:label</em> value from the main Manifest but has rejected the value coming from the library’s Manifest. Is this normal ? well, it is.</p><p>If we go back to verify the main <em>AndroidManifest.xml</em> we will find that there is an attribute called <strong><em>tools:replace</em></strong> having the value<em> android:label</em>, what does that mean ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*3u2s_5m5M3fXavpXortXTA.png" /><figcaption>The main app AndroidManifest.xml file</figcaption></figure><p>This is called a <strong><em>Merge Rule</em></strong>, it tells the Manifest merger : when it comes to the <strong>application</strong>, refuse any <strong>application</strong> <em>android:label</em> value coming from another Manifest, and replace it with the main app’s Manifest value which is in this case the String <em>app_name</em>.</p><blockquote>[Read] how manifest merge work in Android <a href="https://developer.android.com/studio/build/manifest-merge">here</a></blockquote><p>So, in our case everything is OK, and there is no clue to be extracted from this first match unfortunately.</p><ul><li>The second match —</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tmgjTpfIfgY85sDVbGB4YQ.png" /><figcaption>Part from the manifest-merger-release-report.txt file</figcaption></figure><p>For this second match, the log says that there is an <em>android:label</em> that has been <strong>added</strong> ! But this time, it’s coming from an <strong>activity</strong> called <em>MyLibActivity</em>, an activity that has been added from a library.</p><p>It has been added because the Merge Rule that we have seen in the first match applies only on the <strong>application</strong> node not the <strong>activity</strong> node.</p><p>Well, this is defiantly a clue ! We should verify the actual value that has been added to the Manifest.</p><p>— Hypothesis gives a clue 🧐</p><h3>The — Eurêka ! — moment</h3><p>The clue leads us to check the Manifest file that will be included in the generated bundle which os the result of merging all Manifests. In order to do so, I went to the <strong><em>build</em></strong> menu in Android Studio and selected the option <strong><em>Analyze APK…</em></strong> and then selected the <strong><em>.aab</em></strong> file. The good thing is that Analyzing APKs works fine with bundle files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s6VgfLVvzpUocyAJhYq8mw.png" /><figcaption>APK Analyzer in Android Studio analyzing the app bundle file (.aab)</figcaption></figure><p>When everything is OK when it comes to the <strong>application</strong> label value, it’s clear that the <strong>Activity</strong> label value is not good, as it has a<strong><em> style resource</em></strong> as value instead of having a string resource !</p><p>The Activity comes from a third party library. Therefore, and in order to make sure, I have decompiled the library, fixed the declaration and recompiled the library (for the demo project you’ll need only to fix the declaration). Then, I have build a new bundle with the new compiled library, upload it on the Play Store Console .. and it passes the APKs generation <strong>successfully</strong> !</p><h3>Final thoughts</h3><p>As you can see, it was not trivial to find the cause of the bug. This is the kind of situations when it’s essential to have a problem-solving-mindset and avoid getting angry in order to do a proper investigation.</p><p>These are my thoughts that I want to share with you :</p><ul><li>Error messages are not 100% correct. In our case, you may think that I should have checked the result <em>AndroidManifest.xml</em> since the beginning ! I actually did, but the aapt error message wasn’t correct about the type of the error nor the line number :/</li><li>When you add a third party library or SDK to your app, you are adding its features and also its bugs.</li><li>The Android Asset Packaging (<em>aapt</em>) must become type-safe, otherwise it’s very difficult to spot and avoid such scenarios in big apps.</li><li>Reading carefully the Android documentation is not easy but it’s very important so you can understand the relation between different actors of the app when it comes to build, delivery and runtime.</li><li>With Android App Bundle, the Android team is doing a great job trying to improve the experience for both developers (No more <a href="https://developer.android.com/studio/build/configure-apk-splits">multiple APKs</a> having different app versions) and Android users (downloading only what they need) — Thank you Android team !</li><li>Final thought —</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nrgjw7nWCH3c-X1xXjftHA.png" /></figure><p>If you made it til the end, please don’t forget to give your feedback, it would be more than welcome. Thank you, you are awesome !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8898767f8e3" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/hunting-a-bug-a-true-app-bundle-debugging-story-b8898767f8e3">Hunting a bug — A True App Bundle Debugging Story</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[Migrating Android build scripts from Groovy to Kotlin DSL]]></title>
            <link>https://proandroiddev.com/migrating-android-build-scripts-from-groovy-to-kotlin-dsl-f8db79dd6737?source=rss-90f7b34be612------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8db79dd6737</guid>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[kotlin-dsl]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[groovy]]></category>
            <dc:creator><![CDATA[Oussama Hafferssas]]></dc:creator>
            <pubDate>Sat, 08 Dec 2018 10:21:00 GMT</pubDate>
            <atom:updated>2018-12-08T10:21:00.855Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://gradle.org/whats-new/gradle-5/">Gradle 5.0</a> has been released with lots of features and especially with the support of production-ready Kotlin DSL 🎉 In this article I’ll be sharing with you the process I’ve followed to migrate Gradle build scripts from Groovy to Kotlin DSL in one of my <strong>Android</strong> side projects, and also my personal opinion on this process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-e1sXhna9mPONIwZpGVAQ.jpeg" /></figure><h3>Summary</h3><ul><li>What is Kotlin DSL ?</li><li>Promises made by Kotlin DSL</li><li>Why should I even care ?</li><li>Migration —Step By Step</li><li>Evaluating promises</li><li>Personal opinion</li></ul><h3>What is Kotlin DSL ?</h3><p>If you’ve ever used SQL before or Groovy with Gradle, it means that you’ve used a DSL language before. DSL stands for Domain Specefic Language, which is a type of programming language that cares mainly about the readability by enforcing the use of declarative code with minimal boilerprate (declare to use) instead of imperative code (explaining how to solve a problem) but as a drawback, it can be used only inside a specific context or domain.</p><p>Kotlin is already proven to be a very powerful and a safe production-ready programming language especially. As a GPL (General Purpose Langage) Kotlin has some great features that enables writing very clean code with minimal syntax, things like <a href="https://kotlinlang.org/docs/reference/lambdas.html#function-literals-with-receiver"><strong>Lambdas with receivers</strong></a><strong> that can be used </strong><a href="https://kotlinlang.org/docs/reference/lambdas.html#passing-a-lambda-to-the-last-parameter"><strong>outside of method parentheses</strong></a> and <a href="https://kotlinlang.org/docs/reference/functions.html#infix-notation"><strong>infix function notation</strong></a><strong>. </strong>These<strong> </strong>features<strong> </strong>permit to write DSL-like code with minimal effort (<a href="https://medium.com/u/fa533fdfc06e">Fré Dumazy</a>’s <a href="https://proandroiddev.com/writing-dsls-in-kotlin-part-1-7f5d2193f277">article in ProAndroidDev explains this in details</a>)</p><p>Jetbrains’ <a href="https://github.com/Kotlin/anko">Anko</a> library brought the power of Kotlin DSL to clean verbose Android API especially XML layouts. This is one example :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b7d41eb8d051f001ee88fe667c688cf9/href">https://medium.com/media/b7d41eb8d051f001ee88fe667c688cf9/href</a></iframe><p>The Gradle team liked it a lot and decided to use it for Gradle 🙌</p><blockquote>Gradle’s <a href="https://docs.gradle.org/current/userguide/kotlin_dsl.html">Kotlin DSL Primer</a> is a good entry point to the world of Kotlin DSL scripts</blockquote><h3>Promises made by Kotlin DSL</h3><p>Being built on top of the core langage, makes Kotlin DSL considered as an <a href="https://en.wikipedia.org/wiki/Domain-specific_language#Usage_patterns"><em>Internal DSL</em></a> which means that it does not have a syntax on its own, rather being a library that offers DSL readability by exploiting the mother GPL language features, in this case Kotlin.</p><p>What we should end up having is :</p><ul><li>A statically typed and a type-safe DSL (inherited from Kotlin)</li><li>An enhanced IDE editing experience (inherited from Kotlin)</li><li>Interoperability with existing scripts (as a JVM language)</li><li>Maximum readability (as any DSL)</li><li>Consistency and super power (by using the same language across the project — source code and configuration 💯 Kotlin)</li></ul><h3>Why should I even care ?</h3><p>Shortly, because Groovy is a dynamically typed language, and because it’s very likely that you have come across one of these problems when dealing with build script files for Android :</p><ul><li>Very poor IDE assistant when writing a Groovy DSL script</li><li>Performance issues*</li><li>Errors at build runtime instead of compile time</li><li>Painful build script debugging experience</li><li>Refactoring is a pain in 🤬</li></ul><blockquote>Enough said ! let’s try migrating…</blockquote><h3>Migration — Step By Step</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*Pff2-8Uo4ayFMVnsDIAEdA.gif" /><figcaption>It will not be that easy !</figcaption></figure><p>The migration from Groovy DSL scripts to Kotlin DSL is a like a battle, the more you’ve prepared yourself the more you increase your chances to win !</p><p>So, this is out strategy : Groovy DSL and Kotlin DSL have lots of similarities, therefor we will not re-write build scripts from scratch, in fact we will be transforming the existing Groovy scripts into Kotlin DSL by applying minimum amount of modification, once finished, we rename build scripts file extension and by then we will be done !</p><p>Sounds cool.. yeah.. <strong>only, and only if</strong> you have well prepared your build files, because after renaming files to <em>.gradle.kts</em> the IDE will not be able to offer support, the lights will go off and you’ll be alone against build scripts in your battle — so be prepared !</p><blockquote>..After renaming files to <em>.gradle.kts</em> the IDE will not be able to offer support, the lights will go off and you’ll be alone against build scripts in your battle — so be prepared !</blockquote><h4><strong>Chapter I / Preparation</strong></h4><p>This is where you should really invest time and effort.</p><ul><li><strong>The right (and the latest) IDE —</strong> Because it doesn’t make sense to use Kotlin DSL with unsupported IDE, make sure that you use one of <a href="https://docs.gradle.org/5.0/userguide/kotlin_dsl.html#sec:ide_support">these IDEs</a> (I prefer IntelliJ IDEA CE for Android)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WPEnZztGt7_vXLnagxEF3Q.jpeg" /></figure><ul><li><strong>Update to Gradle Wrapper 5.0 or higher</strong></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bfe6fb9d3c5c1b0ee354f19892dc6ebe/href">https://medium.com/media/bfe6fb9d3c5c1b0ee354f19892dc6ebe/href</a></iframe><blockquote><strong>Tip</strong> : use gradle-5.0-<strong>all </strong>instead of gradle-5.0-<strong>bin. </strong>The<strong> “all” </strong>distribution contains sources that provides IDE with Gradle API and Groovy DSL documentation.</blockquote><p>⚠️ On Android projects, it is recommended to use Gradle 5.0 with Android Gradle Plugin 3.4 (not released yet)</p><p>⚠️ Gradle 5.0 is compatible only with Java 8 or higher ! Yess !</p><ul><li><strong>Update all your Gradle plugins — </strong>As they may bring support for Kotlin DSL if they are not already supporting it.</li><li><strong>Stop Gradle auto-sync (optional) —</strong> in the upcoming steps you’ll start disambiguating build scripts, we will apply small changes practically in every line of the script’s source code. Having Gradle syncing each time can cause you high blood pressure 😉</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YaWfYsyuEzEqFFitgSq4uQ.png" /><figcaption>Disabling Gradle auto-import in IntelliJ’s preferences</figcaption></figure><ul><li><strong>Fix ALL String quotes —</strong> In Groovy it’s possible to use both single quotes or double quotes for strings which is not the case in Kotlin DSL. You’ll need to put<strong> every-single-string</strong> in double quotes, otherwise it will be very tedious to finalize migration after renaming files.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9eb0b40e0d56f30c483fb902b4c8de86/href">https://medium.com/media/9eb0b40e0d56f30c483fb902b4c8de86/href</a></iframe><p>⚠️ Dont forget the <strong><em>settings.gradle</em></strong> file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/691efe8712f5e67734f0262ad90fad84/href">https://medium.com/media/691efe8712f5e67734f0262ad90fad84/href</a></iframe><ul><li><strong>Disambiguating Groovy DSL — </strong>Without knowing the context, the expression of type “<strong><em>xx zzzz”</em></strong> in Groovy can represent a property assignment or a function invocation. These two cases will have different syntax for each in Kotlin DSL. Therefor we need to distinguish them by being more explicit. Actually, the explicit format is the same format that will be used by Kotlin DSL !</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c872b7c553378b84cc31b2e0e4727be/href">https://medium.com/media/7c872b7c553378b84cc31b2e0e4727be/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8c98e5d535a24bf930c96d12cbab694/href">https://medium.com/media/e8c98e5d535a24bf930c96d12cbab694/href</a></iframe><blockquote><strong>Tip</strong> : use the IDE assistant to tell the difference, if you <strong>cmd+click</strong> on the word on the left a.e <strong>implementation</strong>, the IDE will open a source file which means that it’s a function but when you try to cmd+click on <strong>applicationId</strong> you will get nothing which means that it’s a property <em>😉</em></blockquote><ul><li><strong>Respect patterns — </strong>The goal of DSL is to be as declarative as possible, one of the anti-patterns of that is to use <strong><em>apply plugin</em></strong> instead of the <strong><em>plugins</em></strong> bloc. The Kotlin DSL will need this bloc to generate static extension functions to make use of these plugins. Therefor we need to move all apply plugin into one plugins bloc.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c81eb7b20374a76778af511970fad286/href">https://medium.com/media/c81eb7b20374a76778af511970fad286/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8a58d34214b40f1c22c605f9f6ef12f/href">https://medium.com/media/c8a58d34214b40f1c22c605f9f6ef12f/href</a></iframe><h4>Chapter II / Conversion</h4><p>Now we will proceed to the conversion of existing build scripts into Kotlin DSL by renaming them from <strong><em>xx.gradle</em></strong> to <strong><em>xx.gradle.kts</em></strong></p><blockquote>Mixing Groovy scripts and Kotlin DSL scripts in the same project is possible <em>👌</em></blockquote><ul><li>It’s better to start by renaming <strong><em>settings.gradle</em></strong> files to <strong><em>settings.gradle.kts</em></strong> and re-syncing the project just after (Do this for all of your build settings files) Your IDE should show this :</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TcgPR6QdMLgXh26hOHu1iQ.jpeg" /><figcaption>IDE hints in Kotlin DSL 🙌</figcaption></figure><blockquote>Because we have already prepared the <strong>settings.gradle</strong> file we didn’t need to do anything to make it compile after converting it to Kotlin DSL !</blockquote><ul><li>Now let’s do the same thing for the top level <strong><em>build.gradle</em></strong> file and add the extension <strong><em>.kts</em></strong> — Try to spot the differences 🔍</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w0MBj9VHeq3URzwOp0yeDg.jpeg" /><figcaption>IDE view of a standard Gradle Groovy root build script file before conversion</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SSHXh48uKzJUgBu5S_JTIQ.jpeg" /><figcaption>The IDE view of the script after converting it to Kotlin DSL</figcaption></figure><p>As you can see in terms of syntax, in this file the only difference between the Groovy DSL and Kotlin DSL version is the declaration of <strong><em>clean</em></strong> task which you can read as : <strong><em>clean is registerd as a Delete task that deletes the buildDir when executed</em></strong><em>.</em></p><p>In terms of IDE assistant, we have way more better assistant. The IDE shows hints for all scopes of the script 👌 It provides also more assistant when writing the actual Kotlin DSL script. Let’s see..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*b734oVusbdLvmYnnmAbzHg.gif" /><figcaption>IDE assistant with Kotlin DSL</figcaption></figure><blockquote><strong>Tip</strong> : take a look at this<a href="https://github.com/gradle/kotlin-dsl/blob/master/samples/task-dependencies/build.gradle.kts"> Gradle sample </a>for an in depth look.</blockquote><ul><li>We still need to convert the last file which is in our case the app module’s <em>build.gradle</em> file. The screenshot bellow is what the IDE shows just after renaming the file to <strong><em>build.gradle.kts</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xavBcDJtQL2LAESgpMuffw.png" /><figcaption>app module build gradle file after renaming to file to .kts</figcaption></figure><p>As you can see, after syncing the project there are parts that have been compiled properly and others not.</p><p>⚠️ Sometimes the IDE indicated visually a lot of errors whereas Gradle indicates much more less in the sync logs. <strong>Always use the log errors</strong></p><blockquote><strong>Tip :</strong> The best thing to do is to look to the sync error logs and fix them one by one. To make sure that your fix is good, run the command ./gradlew tasks</blockquote><p>In our case we have mainly three erros in the log :</p><ul><li>The release build type error — under the hood, release is just a string passed to a function invoked by Groovy therefor Kotlin will not be able to invoke it as a function. We need to use the actual function invoked behind which is getByName(String)</li><li>The minifyEnabled<em> </em>error — minifyEnabled is not the actual name of the property therefor Kotlin can’t find it. We need to use its original name for assignment which is isMinifyEnabled.</li><li>The fileTree error — before trying to fix it, it’s better to take a look at its declaration (This is why we imported <strong><em>all</em></strong> sources and docs of Gradle 😉). fileTree(Map&lt;String, ?&gt; args)The method accepts args of map of string keys. We will pass this as <strong><em>Tuples</em></strong> the Kotlin way.</li></ul><p>The result after applying these fixes will look like this..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6RcpUIjtvjSeANTg01AAgw.jpeg" /><figcaption>An app module build script file in Kotlin DSL that actually compiles 🎉</figcaption></figure><p>If your build scripts still can’t compile, please keep runing ./gradlew tasks<em> </em>command and fix issues indicated in the log, and double check if your Gradle plugins are fully compatible with Kotlin DSL. If it compiles then..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*xfX3JcmrLIpc1MiGZofSUA.gif" /><figcaption><strong>Congratulations</strong> 🎉</figcaption></figure><blockquote><strong>Note on organizing Gradle project dependency wise — </strong>In the case of Android, it was recommended to use Gradle extra properties to store versions of dependencies in order to use them across the project modules. This solution has been crippled with the lack of IDE assistance do navigate to these versions declaration and properly refactor them. <a href="https://docs.gradle.org/current/userguide/organizing_gradle_projects.html#sec:build_sources">Gradle now recommends</a> declaring them in a dedicated folder <em>buildSrc</em> that contains imperative build code to be shared between modules (I personally find it an over-kill for my small project)</blockquote><blockquote><a href="https://medium.com/u/55d3c15694bb">Sam Edwards</a> explained it <a href="https://caster.io/lessons/gradle-dependency-management-using-kotlin-and-buildsrc-for-buildgradle-autocomplete-in-android-studio">here</a>.</blockquote><h3>Evaluating promises</h3><ul><li>A Type-safe DSL<strong> — ✓ — </strong>Because it’s statically typed, Kotlin DSL provides more safety on passed parameters when invoking Gradle build functions.</li><li>An enhanced IDE editing experience <strong>— ✓ —</strong> In terms of IDE assistance, it’s much more pleasant to write build scripts in Kotlin DSL</li><li>Interoperability with existing scripts<strong> — ⚠︎—</strong>because both are JVM languages (and because Jetbrains has done great job) Kotlin DSL scripts are compatible with Groovy but <strong>not fully</strong> because of Groovy’s dynamic types. Some Gradle plugins will need to be modified in order to be used in Kotlin DSL</li><li>Maximum readability<strong>— ✓ —</strong> As any DSL, I think that Kotlin DSL is very readable even if it’s semi-declarative.</li><li>Consistency and super power <strong>— ✓ —</strong> Having a declarative type-safe language for build is very promising. Gradle plugins authors will be 10 times more creative and productive using such a language. For the years to come, I think we will see a lot of 100% Kotlin Android projects.</li></ul><h3>Personal opinion</h3><p>I’ve always believed in the proverb : <em>you’ve got to crack a few eggs to make an omelette</em>, but for this kind of migrations it would be better to have some kind of assistant to indicate to developers at least where they probably should modify script files in order to make them Kotlin DSL-conversion-ready.</p><p><strong>*</strong>Performance issues — for now, Kotlin DSL falls short in terms of build speed because of compile time needed to resolve that extra type safety. It’s indicated clearly <a href="https://github.com/gradle/kotlin-dsl/issues/902">here</a> and I noticed it even in my small project. I may benchmark it on a big test project before using it in a big production project.</p><p>If Null Pointer Exception is the Billion dollar mistake, build waiting time is easily the Trillion Dollar mistake !</p><p>Before even thinking about a migration to Kotlin DSL, it’s mantadory to be already <strong>applying</strong> build best practices otherwise it will be very tedious.</p><p>I agree with <a href="https://medium.com/u/72bd5082d8aa">Christina Lee</a> when she said, <a href="https://youtu.be/-lVVfxsRjcY?t=1211">strings are danger</a>. I think it’s time to find a solution for those horrible strings that represent dependencies and buildTypes (release, debug..). Why not making a Gradle plugin that gathers all maven dependencies by package name and exposes them as type-safe Kotlin constants for build scripts !?</p><p>Thanks for the Gradle team and for the community for trying always to make build smoother, safer and healthier 🙏</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8db79dd6737" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/migrating-android-build-scripts-from-groovy-to-kotlin-dsl-f8db79dd6737">Migrating Android build scripts from Groovy to Kotlin DSL</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[Exploring the Android land  #io18]]></title>
            <link>https://medium.com/@oussama.haff/exploring-the-android-land-io18-6715e521faba?source=rss-90f7b34be612------2</link>
            <guid isPermaLink="false">https://medium.com/p/6715e521faba</guid>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[google-io-2018]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Oussama Hafferssas]]></dc:creator>
            <pubDate>Sun, 13 May 2018 09:34:26 GMT</pubDate>
            <atom:updated>2018-05-16T20:07:10.743Z</atom:updated>
            <content:encoded><![CDATA[<p>As any passionate Android developer, I was very excited for the annual Google I/O which covers new stuff from Google in the software and the hardware department. This year’s I/O added many new marks in the Android land — by many.. I mean <strong>a lot !</strong> Let’s explore them 🙌</p><blockquote>You may find this article TL;DR ¯\_(ツ)_/¯ well, I made sure to Keep It Simple, Stupid (<a href="https://en.wikipedia.org/wiki/KISS_principle">KISS</a> <em>😘</em>) So keep calm and read it on your own pace :)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QgEbzt4bM5f0WvvgMY1ykw.jpeg" /></figure><h3>Kotlin.. Just Do It !</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*AooVdt0snD9TqctD_I-Hew.gif" /><figcaption>¯\_(ツ)_/¯</figcaption></figure><p>Actually this year, there was no real big announcement regarding Kotlin like the year before. However, something marks almost all presentations, 99% of code examples were given in Kotlin sending indirect message, and sometimes a very direct one, Google recommends using Kotlin instead of Java for Android.</p><blockquote>..That’s what we are encouraging people to do, as their primary programming langage for Android.. (on Kotlin) — <a href="https://medium.com/u/d2cb9c480c2">Reto Meier</a></blockquote><p>So if you didn’t start using or learning Kotlin, you should do it (Internet is full of resources), and if you are already using it, please make sure that you are doing it the Kotlin way not the Java’ish way ! Lead Kotlin Language Designer at Jetbrains <a href="https://medium.com/u/e821c45acf49">Andrey Breslav</a> explained how to Kotlin <a href="https://www.youtube.com/watch?v=6P20npkvcb8"><em>here</em> 🍿</a></p><h3>Android Jetpack (🚀x4)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*7wg_FWZKrSQIjaUbR55mGw.gif" /><figcaption>Start refactoring ⚠️</figcaption></figure><p><a href="https://developer.android.com/jetpack/">Android Jetpack</a> represents an official Google guidance for modern Android development. It offers a set of recommended libraries and tools to accelerate development and unify and optimize the way we build apps.</p><p>Jetpack has 4 packs : 🚀Architecture 🚀 Foundation 🚀 UI and 🚀 Behavior</p><h3>Android Jetpack (1/4) :: 🚀 Architecture</h3><p>Google started pushing last year (2017) and for the first time, official libraries with components that give explicit guidence on how to architecture Android apps (Data Binding, Lifecycles, ViewModel, LiveData, Room) <br>3 new components have made it this year to the Architecture category : say hello to Navigation, Paging and WorkManager 🤘 An overview in <a href="https://medium.com/u/41d9e1a9dbdb">Lukas Bergstrom</a> &amp; <a href="https://medium.com/u/55a38e86cfa7">Yigit Boyar</a>’s session <a href="https://www.youtube.com/watch?v=BE5bsyGGLf4"><em>here</em> 🍿</a></p><ul><li><strong>Navigation</strong> — A brand new architecture component comes to simplify navigation implementation in Android — Because let’s face it, a lot of the navigation code is just boilerplate error-prone hard to maintain code ⚠️ It can handle navigation between Activities, safe Fragment transactions, back stack and up stack, deeplink navigations complexity, passing arguments while navigation and even conditional navigation 👏 All this can be done either programmatically or in XML or with the new Android Studio tool called Navigation Editor that shows different screens and navigation path between them 👌</li></ul><blockquote>On Navigation : <a href="https://www.youtube.com/watch?v=8GCXtCjtg40">watch session</a> <em>🍿</em>— <a href="https://developer.android.com/topic/libraries/architecture/navigation/navigation-implementing">read doc</a> <em>📖</em> — <a href="https://github.com/googlesamples/android-architecture-components/tree/master/NavigationBasicSample">see code sample</a> <em>👨🏻‍💻</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AlyOo6UlpZORPgU1Kt1pdA.jpeg" /><figcaption>Android Studio’s new Navigation Graph Editor — <a href="https://github.com/googlesamples/android-architecture-components/tree/master/NavigationBasicSample">the sample app</a></figcaption></figure><ul><li><strong>Paging</strong> — An architecture component aims to handle the complexity of getting data lazily from a data source. For example, when showing very long or infinite list of data on one screen, sometimes it’s inefficient or impossible to load all the data at once. A common work around is to load a chunk of data, show this data, and when the user starts scrolling down we load another chunk of data. Implementing this in the context of an activity lifecycle can be a nightmare. Paging is all about making this effortless even when using multiple data sources (Network and local database)👌</li></ul><blockquote>On Paging : <a href="https://www.youtube.com/watch?v=BE5bsyGGLf4">watch session</a> <em>🍿</em> — <a href="https://developer.android.com/topic/libraries/architecture/paging/">read doc</a> <em>📖</em> — <a href="https://github.com/googlesamples/android-architecture-components/tree/master/PagingSample">basic sample</a>, <a href="https://github.com/googlesamples/android-architecture-components/tree/master/PagingWithNetworkSample">network sample</a> <em>👨🏻‍💻</em></blockquote><ul><li><strong>WorkManager (Alpha)</strong> — As we all know, in Android it’s not that easy to make scheduled asynchronous tasks correctly especially when we have a lot of conditional triggers like battery state, network state, specific launch time adding to that targeting old SDKs.. Sometimes it really is a pain in the 🍑. WorkManager is all about abstracting this complexity away. It guarantees constraint-aware execution, respecting system background restrictions and most importantly, it guarantees backwards compatibility <strong>with or without Google Play Services</strong> 🎉. Happily, WorkManagers are queryable so checking their state is always possible, they are chainable so triggering tasks that depends on other tasks is a breeze and they are opportunistic which means that the system will execute them as soon as constraints are met.</li></ul><blockquote>On WorkManager : <a href="https://www.youtube.com/watch?v=IrKoBFLwTN0">watch session</a> <em>🍿</em> — <a href="https://developer.android.com/topic/libraries/architecture/workmanager">read doc</a> <em>📖</em> — <a href="https://github.com/googlesamples/android-architecture-components/tree/master/WorkManagerSample">see code sample</a><em>👨🏻‍💻</em></blockquote><h3>Android Jetpack (2/4) :: 🚀 Foundation</h3><p>Google has been listening to developers, they tried this time to handle serious pain points in Android by providing a strong foundation to make Android development up for more sustainable growth, better modularity, and smaller code size — Google.</p><ul><li><strong>AndroidX (preview)</strong>— Android extension libraries is the new name of Android Support Libraries and it’s actually the big long awaited refacto of these libraries. Naming for packages and Maven artifacts has been modified to use androidx.@ package name instead of android.support.** And it will use a new strict semantic versioning to indicate interoperability replacing the old pattern for having multiple support libraries with the same version number. The Architecture Components libraries have also been moved under <em>androidx</em> packages. A new tool was added to Android Studio Preview to facilitate migration to <em>androidx</em>. (There is even CSV files for those who do not use Android Studio, to perform migration MANUALLY 😱)</li></ul><blockquote>On AndroidX : <a href="https://www.youtube.com/watch?v=jdKUm8tGogw">watch session</a> <em>🍿</em> — <a href="https://android-developers.googleblog.com/2018/05/hello-world-androidx.html">read article</a> <em>📖</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*SI598MvNwpgI5p2rFd6uww.jpeg" /><figcaption>New option in Android Studio to migrate from Support Libraries to AndroidX</figcaption></figure><ul><li><strong>Kotlin Extension KTX (alpha) </strong>— was announced in earlier time this year, Google has invested more in Kotlin by providing a set of Kotlin extension functions on top of Android APIs in order to maximize the benefit from Kotlin language features like operators, inline functions and reified type parameters, default and named method parameters and many others. So it’s not about fixing Android APIs, it’s more about providing pleasant development experience for Android developers who are already using Kotlin. The result is an even cleaner code and happier developers 😌</li></ul><blockquote>On Kotlin Extentions KTX : <a href="https://youtu.be/st1XVfkDWqk">watch session</a> <em>🍿</em> — <a href="https://developer.android.com/kotlin/ktx">read doc</a> <em>📖</em> — <a href="https://github.com/android/android-ktx">see code</a> <em>👨🏻‍💻</em></blockquote><ul><li><strong>Building apps with D8 and R8</strong> — D8 is the new Android Dexer (converts Java bytecode to Dalvik bytecode) it will be activated by default in Android Studio 3.1. Google promesses to have smaller Dex files and better error messages when using D8. On the other hand, R8 is the new optimizer, it still in preview. R8 aims to replace ProGuard for optimization and shrinking tasks, it can de-sugar Java 8 Bytecode to old version bytecode and it was optimized also for Bytecode generated by the Kotlin compiler which is a little bit different than Javac’s generated Bytecode. R8 will have two modes for shrinking apps normal and agressive and can use proguard rules for shrinking.</li></ul><blockquote>On D8 and R8 : <a href="https://android-developers.googleblog.com/2018/04/android-studio-switching-to-d8-dexer.html">read article</a> <em>📖</em> — <a href="https://r8.googlesource.com/r8/">see project repo</a><em>👨🏻‍💻 —</em><a href="https://pca.st/34mU">listen to podcast</a><em> 🎤</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/1*JJoFO53_dh8GgSN3UhrXcA.gif" /><figcaption>When build takes a lot of time..</figcaption></figure><ul><li><strong>Publishing with App Bundle</strong> — App bundle is a new build artifact that will be used to publish apps to Google Play Store instead of uploading an APK file. Once uploaded, Google will use a new and open source dynamic delivery system to generate multiple APKs called <em>Split APKs</em> for the app bundle, each APK contains only portions of your app that users need : specific language resources, proper image density resources and ABI resources (Application Binary Interfaces) 👏 With App Bundle it will be possible to have Dynamic Features (bêta), which are features that are not required when the app is first installed, but may be downloaded and installed later 👌👌👌.</li></ul><blockquote>On App Bundle : <a href="https://www.youtube.com/watch?v=bViNOUeFuiQ">watch session</a> <em>🍿</em> — <a href="https://developer.android.com/guide/app-bundle/">read doc</a> <em>📖</em></blockquote><h3>Android Jetpack (3/4) :: 🚀 UI</h3><p>Android Jetpack UI is about animations and transition, system UI APIs like Fragments, layouts, palettes and so on, and other Android flavors (Wear OS, Android Auto and Android TV, I’ll speak about them later). Google has also published a major update for material design. These changes will be included in the Design Support Library.</p><ul><li><strong>New Material Design guidelines and tools</strong>— Google announced officially new Material Design guidelines, tools and components for designer and developers to enable more enhanced UI. The new guidelines are well explained in the dedicated website. Designer (and even developer) will be able to incorporate more easily brands’ visual identity to Android Material theme via a new Sketch plugin called Theme Editor.</li></ul><blockquote>On MD Tools &amp; Guidelines : <a href="https://www.youtube.com/watch?v=3VUMl_l-_fI">watch session</a> <em>🍿</em> — <a href="https://material.io/design/introduction/#principles">read doc</a> <em>📖</em> — <a href="https://material.io/tools/theme-editor/">Theme Editor</a> <em>👨🏻‍💻</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*sW7AXi050HYXI2N71p6CKg.gif" /><figcaption>The new Theme Editor plugin for Sketch</figcaption></figure><ul><li><strong>Material Theming </strong>— We have a new app theme in Android called <em>Theme.MaterialComponents</em> with new attributes respecting the new guidelines. New components have made it to the design library like : <em>Material Chips</em>, <em>Bottom Action Bar</em> and others.</li></ul><blockquote>On MD Theming : <a href="https://youtu.be/3VUMl_l-_fI?t=17m8s">watch session</a> <em>🍿</em> — <a href="https://material.io/develop/android/">read doc</a> <em>📖</em>— <a href="https://material.io/collections/developer-tutorials/#android-kotlin">code labs</a><em>👨🏻‍💻</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*opt2ljgqJ1BWQ8m1PSfduA.jpeg" /><figcaption>New Material Components : Bottom Action Bar and Chips</figcaption></figure><h3>Android Jetpack (4/4) :: 🚀 Behavior</h3><p>A collection of libraries that help you design more robust apps. This includes things like : DownloadManager, Permissions, Notifications, Media playback.. a bunch of stuff that we already use and also new things like :</p><ul><li><strong>Android Slices </strong>— Slices are a portion from your app exposed and shown in Google Search or Google Assistant (Like launcher widgets but with more restrictions) so user can have interactive results for Google Search and can perform tasks faster by enabling engagement outside of the fullscreen app experience. Slices must be build using Templates that Jetpack API offers, and they handle URIs as they are build on top of ContentProvider (Basically, Slices are like widgets but with more restriction). Slices can be tested with a <em>SliceViewer</em> App that can be launched with an ADB command.</li></ul><blockquote>On Android Slices : <a href="https://www.youtube.com/watch?v=a7IVH5aNwwc">watch session</a> <em>🍿</em> — <a href="https://developer.android.com/guide/slices/">read doc</a> <em>📖</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tpfsxggNwl_DeZc4fx23Ag.jpeg" /><figcaption>Example use cases for Android Slices</figcaption></figure><ul><li><strong>Android App Actions </strong>—App Actions are an other more sampler approach to expose apps in Google Search and Google Assistant results, with a very minimal UI and one simple action that user can trigger. Slices can be build on top of one or more App Actions.</li></ul><blockquote>On Android App Actions : <a href="https://developer.android.com/guide/actions/">read doc</a> <em>📖</em></blockquote><h3>Android.. UI on steroids 💪</h3><p>Android Studio has its share of updates, especially the design tools.</p><ul><li><strong><em>SampleData</em></strong> — Android Studio supports now <em>Sample Data</em>, which are data than can be used for visualisation inside the editor and not at runtime. Using design time <em>tools</em> attribute in XML we can provide data like images, text, lists and even JSON files that can be populated for previewing views like RecyclerView 👌.</li><li><strong><em>ConstraintHelpers —</em></strong> Comes in ConstraintLayout 2.0, the aim is to keep reference for a group of views without touching views Hierarchy, a view can be referenced by multiple Helper. Essentially, ConstraintHelpers allow to tag views to apply a shared behavior which is very useful especially when doing animations.</li><li><strong><em>States</em></strong> — A cleaner way to handle UI in ContraintLayout by describing all layout states in <em>ContraintLayouStates</em> in XML, and then we can switch states easily from code, the animation when changing states can be handled automatically by the system. (Personally, states are my favorite approach for handling UI 😉)</li><li><strong><em>MotionLayout &amp; MotionScene —</em></strong><em> In ContraintLayout 2.2</em> we will be able to personalize the automatic animation between ContraintSets (States). MotionScene will support animating custom views attributes and it will also interpolate motion using the user’s gesture inputs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*CHMAfwKovUqyJVDK2Uotvw.gif" /><figcaption>MotionScene animating a transaction between two Contraint States</figcaption></figure><ul><li><strong><em>MotionEditor</em> (My Favorite) </strong>— An Android studio tool that makes doing Animation in Android great again. We start by defining ContraintSets for the start and the end of the animation, and then we add keyframes in the animation timeline to personalize a view’s position or velocity. We can visualize this in the preview area to test things on the fly 🙌.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*1J2bZQZhBz2uPJnnYDoPMg.gif" /><figcaption>Android Motion Editor in action (Available only in preview)</figcaption></figure><blockquote>On ConstraintLayout : <a href="https://www.youtube.com/watch?v=ytZteMo4ETk">watch session</a> <em>🍿</em></blockquote><h3>Conclusion</h3><p>This years’ Google I/O was full of announcements for Android. It seem like the main drive for all these changes was mainly the direct feedback of the Android community which actually very good.</p><p>If you have made it to the end of this article thank you, you are awesome 👏 However, it’s always better to get your hands dirty and try for yourself what you think is the most important for you in your Android terminator developer life 👾</p><p>Any comments, questions or suggestions are very welcome 🙂</p><blockquote>Special thanks for Montpellier Android Users Group for the great Google I/O Extended session <em>🙏</em></blockquote><h3>Next article — soon : Android things, Machine learning, Android Auto, AR and more ..</h3><blockquote>See ya !</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6715e521faba" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>