<?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: Alen</title>
    <description>The latest articles on DEV Community by Alen (@alencengic).</description>
    <link>https://dev.to/alencengic</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%2F626720%2F0c6c9733-098d-448c-bfa1-65658f45577b.png</url>
      <title>DEV Community: Alen</title>
      <link>https://dev.to/alencengic</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alencengic"/>
    <language>en</language>
    <item>
      <title>Generating Android APK file with React Native</title>
      <dc:creator>Alen</dc:creator>
      <pubDate>Fri, 07 May 2021 10:59:54 +0000</pubDate>
      <link>https://dev.to/alencengic/generating-android-apk-file-with-react-native-20c2</link>
      <guid>https://dev.to/alencengic/generating-android-apk-file-with-react-native-20c2</guid>
      <description>&lt;p&gt;Let's be honest, even if you really like React Native, you were frustrated with it at least once. Especially if you have just started working with it.&lt;/p&gt;

&lt;p&gt;So I hope this post will help at least some of you :D.&lt;/p&gt;

&lt;p&gt;This are 7 steps how to generate your Android APK file so you can test your app on a real phone and share it with your friends or testers. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Currently tested and working with latest version today 0.64&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Generate private signing key using keytool. How to do that you can find it &lt;a href="https://reactnative.dev/docs/signed-apk-android#generating-an-upload-key"&gt;here&lt;/a&gt;. If you are using OpenJDK, then your keytool is probably in C:\Program Files\OpenJDK\openjdk-xxxxx-xxx\bin.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make sure to copy signing key to /android/app/ folder of your react native app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Edit gradle.properties file in your android folder by adding following (make sure to replace ***** with a password that you want to use, my-upload-key and my-key-alias with the names you want):&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore&amp;lt;br&amp;gt;
 MYAPP_UPLOAD_KEY_ALIAS=my-key-alias&amp;lt;br&amp;gt;
 MYAPP_UPLOAD_STORE_PASSWORD=*****&amp;lt;br&amp;gt;
 MYAPP_UPLOAD_KEY_PASSWORD=*****&amp;lt;br&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add signing config in Gradle config file. Edit the build.gradle file in your android/app/ folder:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="nx"&gt;android&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="p"&gt;...&lt;/span&gt;
 &lt;span class="nx"&gt;defaultConfig&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="nx"&gt;signingConfigs&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="nx"&gt;release&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;project&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hasProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MYAPP_UPLOAD_STORE_FILE&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
             &lt;span class="nx"&gt;storeFile&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MYAPP_UPLOAD_STORE_FILE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
             &lt;span class="nx"&gt;storePassword&lt;/span&gt; &lt;span class="nx"&gt;MYAPP_UPLOAD_STORE_PASSWORD&lt;/span&gt;
             &lt;span class="nx"&gt;keyAlias&lt;/span&gt; &lt;span class="nx"&gt;MYAPP_UPLOAD_KEY_ALIAS&lt;/span&gt;
             &lt;span class="nx"&gt;keyPassword&lt;/span&gt; &lt;span class="nx"&gt;MYAPP_UPLOAD_KEY_PASSWORD&lt;/span&gt;
         &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="nx"&gt;buildTypes&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="nx"&gt;release&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="p"&gt;...&lt;/span&gt;
         &lt;span class="nx"&gt;signingConfig&lt;/span&gt; &lt;span class="nx"&gt;signingConfigs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;release&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check if the file my-release-key.keystore ("my-release-key" is the key you entered earlier) is located in path /android/app/ (if it is not there, make sure to copy it there from the folder where your key was created).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create assets folder in /android/app/src/main/&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open your terminal and position yourself to root folder. Run command:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;react-native bundle --platform android --dev false --entry-file 
index.js --bundle-output 
android/app/src/main/assets/index.android.bundle --assets-dest 
android/app/src/main/res
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open one more terminal and position yourself into android folder. Run command: &lt;br&gt;
&lt;code&gt;gradlew clean&lt;/code&gt; &lt;br&gt;
or &lt;br&gt;
&lt;code&gt;./gradlew clean&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After previous command is finished run: &lt;br&gt;
&lt;code&gt;gradlew assembleRelease -x bundleReleaseJsAndAssets&lt;/code&gt; &lt;br&gt;
or &lt;br&gt;
&lt;code&gt;./gradlew assembleRelease -x bundleReleaseJsAndAssets&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If everything goes well, you can find your signed apk file in &lt;code&gt;android/app/build/outputs/apk/&lt;/code&gt;&lt;br&gt;
or &lt;br&gt;
&lt;code&gt;android/app/build/outputs/apk/release/&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>reactnative</category>
      <category>react</category>
      <category>ios</category>
      <category>android</category>
    </item>
  </channel>
</rss>
