<?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>Forem: Erick Navarro</title>
    <description>The latest articles on Forem by Erick Navarro (@cutiko).</description>
    <link>https://forem.com/cutiko</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%2F53800%2F5dbaeebe-6be1-442e-ac29-72d62b1df310.jpeg</url>
      <title>Forem: Erick Navarro</title>
      <link>https://forem.com/cutiko</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/cutiko"/>
    <language>en</language>
    <item>
      <title>How to create a Kotlin project using Gradle and run it with Android Studio</title>
      <dc:creator>Erick Navarro</dc:creator>
      <pubDate>Mon, 08 Jul 2019 01:52:45 +0000</pubDate>
      <link>https://forem.com/cutiko/how-to-create-a-kotlin-project-using-gradle-and-run-it-with-android-studio-4hac</link>
      <guid>https://forem.com/cutiko/how-to-create-a-kotlin-project-using-gradle-and-run-it-with-android-studio-4hac</guid>
      <description>&lt;p&gt;Working on Android has plenty of facets, one of them is &lt;code&gt;gradle&lt;/code&gt;, configuring it can be hard sometimes but it is very rewarding, in most serious companies there are people specialized in the gradle build. So I want to learn more about gradle and challenge myself to create a simple Kotlin project using and then running in Android Studio to leverage the power of the IDE.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Install Kotlin
&lt;/h2&gt;

&lt;p&gt;Use the installer of your choice, &lt;a href="https://kotlinlang.org/docs/tutorials/command-line.html"&gt;see the manual&lt;/a&gt; (brew, sdk, ports)&lt;/p&gt;

&lt;p&gt;Using brew it would be&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install kotlin
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If the only things you want to do is to create a hello world, then you can just do this and run it using the terminal following the above documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Install Gradle
&lt;/h2&gt;

&lt;p&gt;This should not mess with your Android Studio projects because Android projects use a dynamic gradle online, that is why you can configure offline on Android Studio. If offline Android Studio peak your interest &lt;a href="https://hackernoon.com/speed-up-gradle-build-in-android-studio-80a5f74ac9ed"&gt;this article&lt;/a&gt; should help you (I have mixed experiences using offline, not a recommendation neither discourage, find your flavor).&lt;/p&gt;

&lt;p&gt;Again use the installer of your choice for installing gradle, &lt;a href="https://gradle.org/install/"&gt;see the manual&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With brew it will be&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install gradle
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;You need to have Java before this&lt;/strong&gt;, if you are coming from Android Studio this shouldn't be a problem.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Create a Gradle project
&lt;/h3&gt;

&lt;p&gt;We are now gonna create a gradle project using the cli, there is some info on the Gradle and official Kotlin but I was confused, so I rather give you my own recipe based on those.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create the project&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir devDotTo
cd devDotTo
gradle init
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That will trigger the interactive CLI, is literally reading what it says and following it, but since I'm clueless I got tons of mistake, so let me spare you the trial and error.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select Library (number 3 and enter)&lt;/li&gt;
&lt;li&gt;Select Kotlin (number 4 and enter)&lt;/li&gt;
&lt;li&gt;This last selection is the language used for the gradle files, so choose the one you are more comfortable. I'm used to Android, so I like groovy, and I won't change to the Kotlin extension until I deeply understand what am doing.&lt;/li&gt;
&lt;li&gt;The next 2 options are naming so you can type whatever suits you and your standards or just press enter twice.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This creates a template project with one default class and a default test, we will have to modify that a little on Android Studio.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Run it using Android Studio
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open Android Studio and open the project, click on the directory and click on open&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zqwVv-dW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/18umeey0f07b8b4q1bzs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zqwVv-dW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/18umeey0f07b8b4q1bzs.png" alt="open on android studio"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Let Android Studio do the thingy... blow some air on your computer if you need to cool it, xD Seriously, if you are used to Android projects, you can select the "Android" vision on the pane A.K.A. the left tab with the files&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open the file &lt;code&gt;Library.kt&lt;/code&gt; is gonna be the only file there. We are going to add the &lt;strong&gt;main method&lt;/strong&gt; so we can configure our IDE to run it. There is a default method, if you remove it, make sure to remove it on test folders as well. Your file should look like this:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Library {

    companion object {

        @JvmStatic
        fun main(args: Array&amp;lt;String&amp;gt;) {
            println("DEV DOT TO")
        }
    }

    fun someLibraryMethod(): Boolean {
        return true
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As you can see we have to add it inside the &lt;code&gt;companion object&lt;/code&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now we are going to configure Android Studio to run it. Click on "Add Configuration" on the top bar&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Rwo00brj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9456kg7in7hgzybzaocv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Rwo00brj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9456kg7in7hgzybzaocv.png" alt="add configuration button"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the dialog that shows up, don't click the templates, click the plus button (you don't want to edit a template, you want to use a template to create a configuration). Select the Kotlin template:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ditE_np3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7jmw0x20oo3f7y5tgac0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ditE_np3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7jmw0x20oo3f7y5tgac0.png" alt="add configuration kotlin"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you have to select the Main class, if you press on the 3 dots, you will see it right away because it has the &lt;code&gt;main method&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kia4bInq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/gps2rv8w1ooz8ejvug2n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kia4bInq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/gps2rv8w1ooz8ejvug2n.png" alt="3 dots"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yeWYahkD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9fwtwpkeskiqdylrg5mx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yeWYahkD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9fwtwpkeskiqdylrg5mx.png" alt="main class"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now the only thing you have to do is &lt;strong&gt;save the configuration&lt;/strong&gt;. The default name is "Unnamed" I like naming it "Run".&lt;/p&gt;

&lt;p&gt;You can click on the run button or &lt;code&gt;ctrl + r&lt;/code&gt; on Mac and in Windows &lt;code&gt;shift+F10&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sgO-pM36--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/o7rjz7iqbwovqmnn7pbf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sgO-pM36--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/o7rjz7iqbwovqmnn7pbf.png" alt="run"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hooray! We have our logs in the console&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q-7XcBpp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zkmzwrvyp4rqhxgavhel.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q-7XcBpp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zkmzwrvyp4rqhxgavhel.png" alt="DEV DOT TO"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>gradle</category>
      <category>androidstudio</category>
      <category>kotlin</category>
    </item>
    <item>
      <title>Working with React Native feels like Malcolm in the Middle father's changing a lightbulb</title>
      <dc:creator>Erick Navarro</dc:creator>
      <pubDate>Wed, 03 Jul 2019 17:56:36 +0000</pubDate>
      <link>https://forem.com/cutiko/working-with-react-native-feels-like-malcolm-in-the-middle-father-s-changing-a-lightbulb-4ni8</link>
      <guid>https://forem.com/cutiko/working-with-react-native-feels-like-malcolm-in-the-middle-father-s-changing-a-lightbulb-4ni8</guid>
      <description>&lt;p&gt;I have been an Android developer for 5 years, lately, I'm getting my hands on React Native. This is how I feel about it&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Flearningfirebase-77a34.appspot.com%2Fo%2Fdev_dot_to%252Fhall_ligth_bulb.gif%3Falt%3Dmedia%26token%3D50528c75-60b0-4609-9bbf-50ecfcbe906a" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Flearningfirebase-77a34.appspot.com%2Fo%2Fdev_dot_to%252Fhall_ligth_bulb.gif%3Falt%3Dmedia%26token%3D50528c75-60b0-4609-9bbf-50ecfcbe906a" alt="malcom ligthbulb"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To be honest, at first, glance seemed to me like an oversimplified layer for building apps. I did keep learning &lt;em&gt;don't judge a book by its cover&lt;/em&gt;. So eventually I found out that native code can be used. That is my current endeavor by the way.&lt;/p&gt;

&lt;p&gt;The way I see it, a long term project could &lt;strong&gt;benefit from shared code&lt;/strong&gt; and anything troublesome due to the OSS &lt;strong&gt;should be native&lt;/strong&gt;. You don't have to have 2 projects for creating a list of results, but you could benefit from the native implementation if you want to get the user location when the app is closed (I'm thinking on Android here).&lt;/p&gt;

&lt;p&gt;Now to the funny thing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ok, I'm gonna install my dependencies... everything fails because my node install was made with &lt;code&gt;sudo&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Ok, now I have uninstalled node and re-install it without &lt;code&gt;sudo&lt;/code&gt;  (nvm actually)... I have to reinstall everything now&lt;/li&gt;
&lt;li&gt;Ok so in Android Studio I had this plugin for restarting the app using keyboard shortcuts... and there is none for WebStorm&lt;/li&gt;
&lt;li&gt;Ok so now I figure a couple of &lt;a href="https://gist.github.com/cutiko/dd9d0b3facb34a61dc0b2b9cf4c91cc0" rel="noopener noreferrer"&gt;commands&lt;/a&gt; that will solve this, and now... how do I change the package name?&lt;/li&gt;
&lt;li&gt;Ok so now I changed the package name for Android and IOS to the standard &lt;em&gt;com.subdomain.appname&lt;/em&gt; now I'm gonna work... wait typescript seems to have a problem&lt;/li&gt;
&lt;li&gt;Ok so now I have typescript working on my project and now I can work!&lt;/li&gt;
&lt;li&gt;Ok so that last dependency is telling me that &lt;code&gt;npm audit fix&lt;/code&gt;, sure... wait that update react-native version?&lt;/li&gt;
&lt;li&gt;Ok so now I have to solve this new problem with AndroidX (I saw it coming from &lt;a href="https://twitter.com/CutikoLive/status/1146453755589734403" rel="noopener noreferrer"&gt;miles away&lt;/a&gt;)... sure let's add the right dependency and then let's add jetifier and...&lt;/li&gt;
&lt;li&gt;Ho! So now I found another error and &lt;a href="https://github.com/facebook/react-native/issues/12289" rel="noopener noreferrer"&gt;I can't run my app...&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ok so, now I'm going to rollback everything and now I'm sure I'm gonna be able to work.... (I'll let you know, I guess)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Regarding the latest problem, I didn't give up and had to figure a way to use the &lt;code&gt;react-native-cli&lt;/code&gt; so you can see my &lt;a href="https://stackoverflow.com/a/56892669/4017501" rel="noopener noreferrer"&gt;SO answer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PS: I know about live reloading, I'm just improving my dev environment. And yes I know about &lt;code&gt;--typescript template&lt;/code&gt; from the react-native cli, but I forgot about it... mistakes happen ¯_(ツ)_/¯&lt;/p&gt;

&lt;p&gt;UPDATE: this was updated shortly after publishing, and then 2 days later&lt;/p&gt;

</description>
      <category>reactnative</category>
    </item>
    <item>
      <title>Interactive commit using terminal</title>
      <dc:creator>Erick Navarro</dc:creator>
      <pubDate>Fri, 25 Jan 2019 19:21:56 +0000</pubDate>
      <link>https://forem.com/cutiko/interactive-commit-using-terminal-60</link>
      <guid>https://forem.com/cutiko/interactive-commit-using-terminal-60</guid>
      <description>&lt;p&gt;Hello Everybody! My first post here was looking forward to having something adequate to share :)&lt;/p&gt;

&lt;h3&gt;
  
  
  icommit
&lt;/h3&gt;

&lt;p&gt;I create a simple script for having an interactive commit using the terminal, you can see the instructions here&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/ORTSU6rH3XxonpcV5z/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/ORTSU6rH3XxonpcV5z/giphy.gif" alt="icommit demo gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/cutiko/1a1f5c43daa0e4b14c740b56710f0cf2"&gt;Instructions for icommit&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  The problem
&lt;/h4&gt;

&lt;p&gt;Usually, a commit will be something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit -am 'ADD: new feature'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then the next commit will be something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit -am 'FIX: the feature was broken'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In every commit always the same pattern is repeated &lt;code&gt;git commit -am 'THE_MESSAGE'&lt;/code&gt; so I was wondering how to do it faster.&lt;/p&gt;

&lt;p&gt;My first attempt was to press up arrow and delete, but it was tedious, then it hit me:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It would be really cool if I could have something like &lt;code&gt;scanner.readline&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Like in the text base adventure games, the interaction was basically writing lines, the program read the input and then do something.&lt;/p&gt;

&lt;p&gt;So there you have a bonus, now your version control is an adventure game as well!&lt;/p&gt;

</description>
      <category>git</category>
      <category>bash</category>
    </item>
  </channel>
</rss>
