<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Victor Rattis</title>
    <description>The latest articles on DEV Community by Victor Rattis (@victorrattis).</description>
    <link>https://dev.to/victorrattis</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F229682%2F1e0feb10-2e2d-40b6-82dc-31ba90885cbc.png</url>
      <title>DEV Community: Victor Rattis</title>
      <link>https://dev.to/victorrattis</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/victorrattis"/>
    <language>en</language>
    <item>
      <title>Tip: How to avoid duplicating Gradle codes in Multi Android modules</title>
      <dc:creator>Victor Rattis</dc:creator>
      <pubDate>Sun, 28 Feb 2021 19:07:42 +0000</pubDate>
      <link>https://dev.to/victorrattis/tip-how-to-avoid-duplicating-gradle-codes-in-multi-android-modules-1g19</link>
      <guid>https://dev.to/victorrattis/tip-how-to-avoid-duplicating-gradle-codes-in-multi-android-modules-1g19</guid>
      <description>&lt;p&gt;Let's assume the following code is added in more than one Android Gradle module on a project which has multiple Gradle modules.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 30
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To avoid duplicating this code in more than one module Gradle and avoid making mistakes, you could use the following solution:&lt;/p&gt;

&lt;p&gt;Create a Gradle Script file in the root project, and for this code, you could create for example &lt;code&gt;android.gradle&lt;/code&gt; and add the code common in it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 30
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and in &lt;code&gt;build.gradle&lt;/code&gt; of each Gradle module you can include it using &lt;code&gt;apply from:'../android.gradle'&lt;/code&gt;. For example, including it into &lt;code&gt;app/build.gradle&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apply from:'../android.gradle'

android {
    defaultConfig {
        applicationId "com.my.application"
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>android</category>
      <category>gradle</category>
      <category>tip</category>
    </item>
    <item>
      <title>The Price of using AndroidX.</title>
      <dc:creator>Victor Rattis</dc:creator>
      <pubDate>Tue, 19 May 2020 01:53:27 +0000</pubDate>
      <link>https://dev.to/victorrattis/the-price-of-using-androidx-in-an-app-3j4f</link>
      <guid>https://dev.to/victorrattis/the-price-of-using-androidx-in-an-app-3j4f</guid>
      <description>&lt;p&gt;Currently, It is recommended by Google to use AndroidX in our project to make it compatible with many Android versions.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"AndroidX is a major improvement to the original Android Support Library, which is no longer maintained. &lt;code&gt;androidx&lt;/code&gt; packages fully replace the Support Library by providing feature parity and new libraries." (&lt;a href="https://developer.android.com/jetpack/androidx"&gt;link&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Is there a price for that? Let's consider the following points...&lt;/p&gt;

&lt;h3&gt;
  
  
  Simple Hello World with 'androidx"
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KR1l8bvG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uy2bmrtklras1ngtngb6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KR1l8bvG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uy2bmrtklras1ngtngb6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;APK Size: 1.6 MB;&lt;/li&gt;
&lt;li&gt;AndroidX Size has ~1.5 MB;&lt;/li&gt;
&lt;li&gt;It has &amp;gt;10K methods (remembering in enabling the multi-dex if your app exceeds over 64K methods).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Simple Hello world without 'androidx'
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5ji1yFkL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sv07esc6hsnxx4c7r6cl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5ji1yFkL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sv07esc6hsnxx4c7r6cl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;APK Size has 102.7 KB.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Keep in mind:&lt;/strong&gt; A dependency always has a price in a project and I think this should be taken into consideration before using it.&lt;/p&gt;

&lt;p&gt;Just think about!&lt;/p&gt;

</description>
      <category>android</category>
    </item>
    <item>
      <title>Good Practices: Can I use synchronized in the Main Thread of an Android application?</title>
      <dc:creator>Victor Rattis</dc:creator>
      <pubDate>Mon, 23 Sep 2019 14:52:31 +0000</pubDate>
      <link>https://dev.to/victorrattis/good-practices-can-i-use-synchronized-in-the-main-thread-of-an-android-application-2je0</link>
      <guid>https://dev.to/victorrattis/good-practices-can-i-use-synchronized-in-the-main-thread-of-an-android-application-2je0</guid>
      <description>

</description>
      <category>android</category>
      <category>thread</category>
      <category>synchronize</category>
      <category>anr</category>
    </item>
  </channel>
</rss>
