<?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 Nikhil Bhople on Medium]]></title>
        <description><![CDATA[Stories by Nikhil Bhople on Medium]]></description>
        <link>https://medium.com/@NikhilBhople?source=rss-5bda1c8b36a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*2X15u7C05hj6-l7xF-um3w.jpeg</url>
            <title>Stories by Nikhil Bhople on Medium</title>
            <link>https://medium.com/@NikhilBhople?source=rss-5bda1c8b36a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 11:00:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@NikhilBhople/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[Building and installing release .apk on multiple devices using the shell script]]></title>
            <link>https://medium.com/@NikhilBhople/building-and-installing-release-apk-on-multiple-devices-using-the-shell-script-a78de319b8af?source=rss-5bda1c8b36a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a78de319b8af</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[shell-script]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[apk]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Nikhil Bhople]]></dc:creator>
            <pubDate>Sat, 29 Sep 2018 16:01:04 GMT</pubDate>
            <atom:updated>2018-10-23T05:05:07.138Z</atom:updated>
            <content:encoded><![CDATA[<p>Creating an app directly from its source code and installing it on a device can often seem like a daunting task. Take a look at how we clone, build and install our Android applications with a few easy steps in the shell script!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NznD5FKKF5D2ARS6fLgOtg.jpeg" /></figure><p><strong>Prerequisite:</strong><br>1. Latest Android SDK<br>2. Latest Java SDK<br> <br> Simply you just need installed android studio and OpenJDK on your system and you are good to go.</p><p>Following are the simple steps<br>1. Cloning or pulling our latest repository <br>2. Building debug or release apk using gradlew<br>2. And installing it on single or multiple devices using adb</p><p>Now by using a shell script, we are doing it step by step<br><strong>Step 1:</strong> Clone your repository and if the repository is already existed then pull it.</p><pre>FOLDER_PATH=&quot;/home/buzzybrains/Build&quot;<br>APP_NAME = &quot;test-app&quot;</pre><pre>if [ -d &quot;$FOLDER_PATH/${APP_NAME}&quot; ]<br>   then<br>       echo &quot;— Pulling $APP_NAME git repo — &quot;<br>       cd ${FOLDER_PATH}/${APP_NAME}<br>       git pull<br>       wait<br>   else <br>       echo &quot;— Creating build folder — &quot;<br>       mkdir Build<br>       cd Build<br>       git clone <a href="https://nikhilbhople@bitbucket.org/mygitrepo/$%7BAPP_NAME%7D.git">https://nikhilbhople@bitbucket.org/mygitrepo/${APP_NAME}.git</a><br>       wait<br>       cd ${APP_NAME}<br>fi</pre><p>The above code is straightforward if a folder exists then pull the repo else create a folder and clone the repo. Now “wait” is used to wait for previous instruction to complete.</p><p><strong>Step 2: </strong>Creating and adding “local.propertices” file to your project folder. Which include your android sdk location, it is used by gradlew for building apk</p><pre>ANDROID_SDK_LOCATION=&quot;/home/buzzybrains/Android/Sdk&quot;</pre><pre>echo &quot;--creating local.properties--&quot;<br>echo &quot;sdk.dir=$ANDROID_SDK_LOCATION&quot; &gt; local.properties</pre><p><strong>Step 3: </strong>Now for building apk, Gradle provides two commands-</p><pre><br>./gradlew assembleDebug =&gt; for building debug apk<br>./gradlew assembleRelease =&gt; for building release apk</pre><p>For building release apk, we need “keystore.jks” file and have to set its configuration in build.gradle(app level).</p><p>Follow the below steps<br>3.1: You can create keystore.jks file by using Android studio<br>3.2: Store a file in your app folder of the project<br>3.3: Now create keystore.properties file in the root folder of your project and paste the following details</p><pre>storePassword=yourKeystorePassword<br>keyPassword=yourKeyAliasPassword<br>keyAlias=yourKeyAlias<br>storeFile=keystore.jks</pre><p>where<br>storePassword =&gt; represent your keystore password<br>keypassword =&gt; represent your key alias <br>passwordkeyAlias =&gt; represent your key alias name<br>storeFile =&gt; represent your keystore file name</p><p>3.4: Now make the following changes in your build.gradle(app level)</p><pre>apply plugin: &#39;com.android.application&#39;</pre><pre>def keystorePropertiesFile = rootProject.file(&quot;keystore.properties&quot;)<br>def keystoreProperties = new Properties()<br>keystoreProperties.load(new FileInputStream(keystorePropertiesFile))</pre><pre>android {<br>// Encapsulates signing configurations.<br>signingConfigs {<br> config {<br>    keyAlias keystoreProperties[&#39;keyAlias&#39;]<br>    keyPassword keystoreProperties[&#39;keyPassword&#39;]<br>    storeFile file(keystoreProperties[&#39;storeFile&#39;])<br>    storePassword keystoreProperties[&#39;storePassword&#39;]<br>  }<br> buildTypes {<br>  release {<br>     minifyEnabled false<br>     proguardFiles getDefaultProguardFile(&#39;proguard-android.txt&#39;),     &#39;proguard-rules.pro&#39;<br>     signingConfig signingConfigs.config<br>   }<br>  }<br> }<br>}</pre><p>You can get more details here</p><p><a href="https://developer.android.com/studio/publish/app-signing">Sign your app | Android Studio | Android Developers</a></p><p><strong>Step 4: </strong>Now we can build the project using ./gradlew command</p><pre>chmod +x gradlew<br>./gradlew assembleRelease<br>wait</pre><p>above step, you may get an error like JavaSdk/Android SDK path not found, then you suppose to give correct path. Other errors are related to your<br>compilation.</p><p><strong>Step 5: </strong>Now your release apk is ready and it’s location “app/build/outputs/apk/release”. So move</p><pre>cd app/build/outputs/apk/release</pre><p><strong>Step 6: </strong>Now we are installing apk using adb install command</p><p><strong>adb install</strong> will install to only one device if you connect two or more devices then it will throw an error.<br>So for installing two or more devices, the following command is useful<br><strong>adb devices</strong> which gives us list of device</p><pre>echo &quot;--installing apk--&quot;<br># adb install app-release.apk  # for installing in single device<br> for SERIAL in $(adb devices | grep -v List | cut -f 1);<br>    do adb -s $SERIAL install -r app-release.apk</pre><pre>done<br>echo &quot;--installation complete--&quot;</pre><p>where, -s =&gt; represent the serial no <br>-r =&gt; represent apk is existed then replace it</p><p>The script will look like below-</p><pre>FOLDER_PATH=&quot;/home/buzzybrains/build&quot;<br>ANDROID_SDK_LOCATION=&quot;/home/buzzybrains/Android/Sdk&quot;<br>PACKAGE_NAME=&quot;nikhil.bhople.apps&quot;<br>APP_NAME = “test-app”</pre><pre># STEP 1: Pull or clone app repo</pre><pre>if [ -d &quot;$FOLDER_PATH/${APP_NAME}&quot; ]<br> then<br>   echo &quot;--Pulling $APP_NAME git repo--&quot;<br>   cd ${FOLDER_PATH}/${APP_NAME}<br>   git pull<br>   wait<br> else<br>   echo &quot;--Creating build folder--&quot;<br>   mkdir build<br>   cd build<br>   git clone <a href="https://nikhilbhople@bitbucket.org/mygitrepo/$%7BAPP_NAME%7D.git">https://nikhilbhople@bitbucket.org/mygitrepo/${APP_NAME}.git</a><br>   wait<br>   cd ${APP_NAME}<br>fi</pre><pre><br># STEP 2: Creating local.properties</pre><pre>echo &quot;--creating local.properties--&quot;<br>echo &quot;sdk.dir=$ANDROID_SDK_LOCATION&quot; &gt; local.properties</pre><pre><br>#STEP 3 and 4: Permission for gradlew and building release apk</pre><pre>cd ${FOLDER_PATH}/${APP_NAME}<br>chmod +x gradlew<br>./gradlew assembleRelease<br>wait</pre><pre><br>#STEP 5: Move to build location</pre><pre>echo &quot;--apk location $APP_NAME/app/build/outputs/apk/release --&quot;<br>cd app/build/outputs/apk/release</pre><pre><br># STEP 6: Installing APK to multiple devices</pre><pre>echo &quot;--installing apk--&quot;<br># adb install app-release.apk  # for installing in single device<br> for SERIAL in $(adb devices | grep -v List | cut -f 1);<br>    do adb -s $SERIAL install -r app-release.apk</pre><pre>done<br>echo &quot;--installation complete--&quot;</pre><p>Thanks for reading, hope you like it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a78de319b8af" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>