<?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 Umesh Kumar on Medium]]></title>
        <description><![CDATA[Stories by Umesh Kumar on Medium]]></description>
        <link>https://medium.com/@umesh.bsa?source=rss-6207b076907e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0nnZyLMetujTAj1tOmof4A.png</url>
            <title>Stories by Umesh Kumar on Medium</title>
            <link>https://medium.com/@umesh.bsa?source=rss-6207b076907e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 14:22:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@umesh.bsa/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[android-pdf-creation-from-xml-layout]]></title>
            <link>https://medium.com/@umesh.bsa/android-pdf-creation-from-xml-layout-d81625237167?source=rss-6207b076907e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d81625237167</guid>
            <category><![CDATA[xm-layout]]></category>
            <category><![CDATA[pdf]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Umesh Kumar]]></dc:creator>
            <pubDate>Sun, 03 Feb 2019 15:42:46 GMT</pubDate>
            <atom:updated>2019-02-03T15:42:46.282Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*RnNDh4Kynk1x6eeIHd9mnA.png" /></figure><h4>Background</h4><p>PDF creation from xml layout is not big deal. I am introduce a new protocol to create a very simple way to create PDF file from android xml layout. XML layout have contain list item, some item may be visible and also invisible. In this technique, We have no matter to see xml layout on device, we have create pdf file from invisible xml layout.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*Fn62USK7QIGoShiPC6nQKQ.gif" /></figure><p>Let’s start main game.</p><h4>Main Terminology</h4><p>Create PDF file from XML layout which contain list item.</p><h4>Key Point</h4><ul><li><strong>XML Layout :</strong> Create xml layout in layout directory with item which you want to see pdf page and create one extra layout to set all item as recycler view and this adapter.</li><li><strong>Bitmap Cache :</strong> Store all bitmap in cache directory. This bitmap created from xml layout.</li></ul><h4>Implementation</h4><ul><li><strong>Step 1:</strong> Create xml layout item. `item_pdf_creation.xml`</li></ul><pre>&lt;<strong>TextView<br>    android:id=&quot;@+id/tv_received&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:background=&quot;@color/color_winter&quot;<br>    android:paddingLeft=&quot;@dimen/dp_10&quot;<br>    android:paddingTop=&quot;@dimen/dp_8&quot;<br>    android:paddingBottom=&quot;@dimen/dp_8&quot;<br>    android:text=&quot;Received&quot;<br>    android:textColor=&quot;@color/color_white&quot;<br>    android:textSize=&quot;@dimen/dp_10&quot; </strong>/&gt;</pre><ul><li><strong>Step 2 :</strong> Create xml layout to set list item. `pdf_creation_view.xml`</li></ul><pre><em>&lt;?</em><strong>xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;</strong><em>?&gt;<br></em>&lt;<strong>LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    android:id=&quot;@+id/scroll&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    android:background=&quot;#ffffff&quot;<br>    android:orientation=&quot;vertical&quot;<br>    android:paddingTop=&quot;10dp&quot;</strong>&gt;<br><br>    &lt;<strong>android.support.v7.widget.RecyclerView<br>        android:id=&quot;@+id/recycler_view&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;match_parent&quot;<br>        android:layout_marginLeft=&quot;10dp&quot;<br>        android:layout_marginRight=&quot;10dp&quot;<br>        android:background=&quot;#ffffff&quot; </strong>/&gt;<br>&lt;/<strong>LinearLayout</strong>&gt;</pre><ul><li><strong>Step 3: </strong>Create bitmap caching to cache xml layout bitmap</li></ul><pre><strong>public static void </strong>addBitmapToMemoryCache(Integer key, Bitmap bitmap) {<br>    <em>memoryCache</em>.put(key, bitmap);<br>}<br><br><strong>public static </strong>Bitmap getBitmapFromMemCache(Integer key) {<br>    <strong>return </strong><em>memoryCache</em>.get(key);<br>}</pre><ul><li><strong>Step 4:</strong> Set data into list item of xml layout</li></ul><pre>Map&lt;Integer, List&lt;PDFModel&gt;&gt; listMap = createFinalData();<br><strong>for </strong>(<strong>int </strong>PAGE_INDEX = 1; PAGE_INDEX &lt;= <strong>NUMBER_OF_PAGE</strong>; PAGE_INDEX++) {<br>    List&lt;PDFModel&gt; list = listMap.get(PAGE_INDEX);<br>    <strong>bitmapOfView </strong>= AppUtils.<em>findViewBitmap</em>(list, <strong>deviceWidth</strong>, <strong>deviceHeight</strong>, <strong>pdfRootAdapter</strong>, <strong>mPDFCreationRV</strong>, <strong>mPDFCreationView</strong>);<br>    PdfBitmapCache.<em>addBitmapToMemoryCache</em>(PAGE_INDEX, <strong>bitmapOfView</strong>);<br>}<br>createPdf();</pre><ul><li><strong>Step 5:</strong> Get all bitmap related to view.</li></ul><pre><strong>public static </strong>Bitmap findViewBitmap(<strong>final </strong>List&lt;PDFModel&gt; currentPDFModels, <strong>int </strong>deviceWidth, <strong>int </strong>deviceHeight, PdfCreateAdapter pdfRootAdapter, RecyclerView mPDFCreationRV, View mPDFCreationView) {<br>    pdfRootAdapter.setListData(currentPDFModels);<br>    mPDFCreationRV.setAdapter(pdfRootAdapter);<br>    <strong>return </strong><em>getViewBitmap</em>(mPDFCreationView, deviceWidth, deviceHeight);<br>}</pre><ul><li><strong>Step 6:</strong> Create PDF file from given xml layout bitmap.</li></ul><pre><strong>final </strong>Bitmap b = PdfBitmapCache.<em>getBitmapFromMemCache</em>(PAGE_INDEX);<br>PdfDocument.PageInfo pageInfo = <strong>new </strong>PdfDocument.PageInfo.Builder(b.getWidth(), b.getHeight(), PAGE_INDEX).create();<br>PdfDocument.Page page = <strong>document</strong>.startPage(pageInfo);<br>Canvas canvas = page.getCanvas();<br>Paint paint = <strong>new </strong>Paint();<br>paint.setColor(Color.<em>parseColor</em>(<strong>&quot;#ffffff&quot;</strong>));<br>canvas.drawPaint(paint);<br>canvas.drawBitmap(b, 0, 0, <strong>null</strong>);<br><strong>document</strong>.finishPage(page);</pre><ul><li><strong>Step 7 :</strong> Final pdf file path</li></ul><pre>PDFMergerUtility ut = <strong>new </strong>PDFMergerUtility();<br><strong>for </strong>(String s : <em>filePath</em>) {<br>    ut.addSource(s);<br>}<br><strong>final </strong>FileOutputStream fileOutputStream = <strong>new </strong>FileOutputStream(<strong>new </strong>File(createFinalPdfFilePath()));<br><strong>try </strong>{<br>    ut.setDestinationStream(fileOutputStream);<br>    ut.mergeDocuments(MemoryUsageSetting.<em>setupTempFileOnly</em>());<br>} <strong>finally </strong>{<br>    fileOutputStream.close();<br>}</pre><h4>Code</h4><ul><li>Github url for <a href="https://github.com/umeshbsa/pdf-creation-by-xml-android">https://github.com/umeshbsa/pdf-creation-by-xml-android</a></li></ul><p>Have a nice day…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d81625237167" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Splash Login Sign Up with validation]]></title>
            <link>https://medium.com/@umesh.bsa/flutter-splash-login-sign-up-with-validation-29d709600554?source=rss-6207b076907e------2</link>
            <guid isPermaLink="false">https://medium.com/p/29d709600554</guid>
            <category><![CDATA[splash]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[sign-up]]></category>
            <category><![CDATA[login]]></category>
            <dc:creator><![CDATA[Umesh Kumar]]></dc:creator>
            <pubDate>Sat, 02 Feb 2019 06:46:48 GMT</pubDate>
            <atom:updated>2019-02-02T07:50:38.783Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*RKNwkQTRa85KcqN1ux_x3g.png" /></figure><h4>Background</h4><p>Flutter is most interactive material theme design for ui. I have intro about how to create a very simple splash, login and sign up screen with most valid validation as android ui.</p><p>Let’s start coding point…</p><h4>Key Point</h4><ul><li><strong>Splash Screen:</strong> Create a very simple splash screen with progress bar. This progress bar indicated to API calling time and after done progress bar, we will navigate to Home Screen.</li><li><strong>Login Screen:</strong> We have intro a very simple login screen with email and password.</li><li><strong>Sign Up Screen:</strong> In Sign Up screen, we have set up most valid validation during the sign up creation.</li></ul><p>Now let’s start main game…</p><h4>Implementation</h4><ul><li><strong>Splash Screen: </strong>In main.dart, create logic with async to navigate another screen.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*Yg_NPxTnwpxIiEB37hC-XA.gif" /></figure><p>Set up time duration with async protocol.</p><pre>startTime() async {<br>  <strong>var </strong>_duration = <strong>new </strong>Duration(seconds: 3);<br>  <strong>return new </strong>Timer(_duration, navigationPage);<br>}</pre><p>Now call navigationPage this function from startTime to navigate HomeScreen</p><pre><strong>void </strong>navigationPage() {<br>  Navigator.<em>of</em>(<strong>context</strong>).pushReplacementNamed(<strong>&#39;/HomeScreen&#39;</strong>);<br>}</pre><ul><li><strong>Login Screen: </strong>Let’s start login screen creation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*wlDsfj7VTvK989_2v5nfUA.gif" /></figure><pre><strong>class </strong>_LoginScreenState <strong>extends </strong>State&lt;LoginScreen&gt; {<br>  @override<br>  Widget build(BuildContext context) {<br>    <strong>return new </strong>MaterialApp(<br>      theme: <strong>new </strong>ThemeData(<br>          primaryColor: Colors.<em>brown</em>,<br>          primarySwatch: Colors.<em>red</em>,<br>          accentColor: Colors.<em>blue</em>),<br>      title: <strong>&quot;Login Screen&quot;</strong>,<br>      home: LoginPageUI(),<br>      debugShowCheckedModeBanner: <strong>false</strong>,<br>    );<br>  }<br>}</pre><p>For view scrolling used this.</p><pre>child: <strong>new </strong>SingleChildScrollView(<br>  child: <strong>new </strong>Container(<br>    padding: EdgeInsets.fromLTRB(30, 110.0, 30, 20),<br>    child: <strong>new </strong>Column(<br>      children: &lt;Widget&gt;[<br>        <strong>new </strong>CircleAvatar(<br>          radius: 60.0,<br>.......</pre><ul><li><strong>Sign Up Screen: </strong>In sign up screen we have intro with validation as email, mobile and password.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*X58r8ZifczQWs5ZXNSjRxg.gif" /></figure><p>To use validation in TextFormField call function with validator</p><pre><strong>new </strong>TextFormField(<br>  controller: <strong>_mobileController</strong>,<br>  textInputAction: TextInputAction.<strong>next</strong>,<br>  decoration: <strong>const </strong>InputDecoration(<br>    labelText: <strong>&#39;Mobile Number&#39;</strong>,<br>    labelStyle: TextStyle(<br>        fontSize: 17, color: Colors.<em>black</em>, fontWeight: FontWeight.<em>bold</em>),<br>    icon: Icon(Icons.<em>add_call</em>),<br>  ),<br>  keyboardType: TextInputType.<em>phone</em>,<br>  validator: validateMobile,<br>  onSaved: (String val) {<br>    <strong>_mobile </strong>= val;<br>  },<br>),</pre><p>Validator code here.</p><pre>String validateMobile(String value) {<br>  <strong>if </strong>(value.<strong>length </strong>!= 10)<br>    <strong>return &#39;Mobile mumber must be of 10 characters&#39;</strong>;<br>  <strong>else<br>    return null</strong>;<br>}</pre><p>Click on Sign Up button and fire onSave function to call validate function</p><h4>Code</h4><ul><li><em>Github url for Splash Screen </em><a href="https://github.com/umeshbsa/flutter-splash-screen"><em>https://github.com/umeshbsa/flutter-splash-screen</em></a></li><li><em>Github url for Login Screen </em><a href="https://github.com/umeshbsa/flutter-login-screen"><em>https://github.com/umeshbsa/flutter-login-screen</em></a></li><li><em>Github url for Sign Up Screen </em><a href="https://github.com/umeshbsa/flutter_sign_up_screen"><em>https://github.com/umeshbsa/flutter_sign_up_screen</em></a></li></ul><p>Have a nice day…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29d709600554" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android library publish maven jCenter]]></title>
            <link>https://medium.com/@umesh.bsa/android-library-publish-maven-jcenter-5a933994f66c?source=rss-6207b076907e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a933994f66c</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-libraries]]></category>
            <category><![CDATA[bintray]]></category>
            <category><![CDATA[jfrog]]></category>
            <category><![CDATA[gradlew]]></category>
            <dc:creator><![CDATA[Umesh Kumar]]></dc:creator>
            <pubDate>Sat, 05 Jan 2019 16:46:23 GMT</pubDate>
            <atom:updated>2019-01-05T16:57:35.910Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*YmBbe36gENyySXvXjNDb9Q.png" /></figure><h4><strong>Background</strong></h4><p>JFrog bintray is a mechanism to publish android library on maven or jCenter. This is very simple technique. We make sure have a some knowledge about gradlew command. This command insure about to build apk and also publish a new android library on jCenter console. We will see how to use many android library as gradle dependency. Now, let’s start to learn to creation of own android library as a dependency as many user used.</p><p>I have given better opportunity to learn quickly by click on this <a href="https://github.com/umeshbsa/android-library-publish-maven-jcenter"><em>url</em></a>.</p><p>So what we wait, let’s have a fun to integrate maven/jCenter of android library.</p><h4><strong>Main Terminology</strong></h4><p>Create a android studio project with simple android library and publish on maven/jCenter.</p><h4><strong>Key Point</strong></h4><ul><li><strong>JFrog Bintray: </strong>This is website where we upload android library as very simple way.</li><li><strong>Android Library:</strong> We have create one simple android library which we want to upload.</li><li><strong>./gradlew:</strong> This is command to upload android library on maven/jCenter.</li><li><strong>Maven/jCenter:</strong> This is organization to manage all repository.</li></ul><p>Now let’s start main game…</p><h4>Implementation</h4><p>The overall implementation is very simple, we must have some basic knowledge about android library creation, gradlew command and JFrag console. So we overall implementation as define step vise.</p><p><strong>Step 1: Create JFrog bintray account</strong></p><ul><li>Go to bintray site and open this url on web.<br><a href="https://bintray.com/">https://bintray.com/</a></li><li>Click on this link<br>&#39;For an Open Source Account&#39;<br>&#39;Sign Up Here&#39;</li><li>Please make sure we do not create account from &#39;START YOUR FREE TRIAL&#39;</li></ul><p><strong>Step 2: Create repository and package on bintray console</strong></p><ul><li>After create your account, create a repository on bintray with package.</li><li>Please follow this <a href="https://github.com/umeshbsa/android-library-publish-maven-jcenter"><strong><em>url</em></strong></a> to quick learn how to create account, repository and package on bintray console.</li></ul><p>After create repo and package we have all done on bintray. Now let’s move on android library creation.</p><p><strong>Step 3: Set up Android Library Project</strong></p><ul><li>Now go to Android Studio and create android project with android library(resume-file-upload) as you know and as you want to publish on bintray. Here android library name is ‘resume-file-upload’, It must be same as package name on bintray.</li><li>Go to android library gradle(build.gradle) and paste it.</li></ul><pre>apply <strong>plugin</strong>: <strong>&#39;com.android.library&#39;<br></strong>apply <strong>plugin</strong>: <strong>&#39;com.github.dcendents.android-maven&#39;<br></strong>apply <strong>plugin</strong>: <strong>&#39;com.jfrog.bintray&#39;<br><br></strong>android {<br>    compileSdkVersion rootProject.COMPILE_SDK_VERSION<br>    defaultConfig {<br>        minSdkVersion rootProject.MIN_SDK_VERSION<br>        targetSdkVersion rootProject.COMPILE_SDK_VERSION<br>        versionCode 1<br>        versionName <strong>&quot;1.0&quot;<br>    </strong>}<br>    buildTypes {<br>        release {<br>            minifyEnabled <strong>false<br>            </strong>proguardFiles getDefaultProguardFile(<strong>&#39;proguard-android.txt&#39;</strong>), <strong>&#39;proguard-rules.pro&#39;<br>        </strong>}<br>    }<br>}<br><br>dependencies {<br>    implementation fileTree(<strong>dir</strong>: <strong>&#39;libs&#39;</strong>, <strong>include</strong>: [<strong>&#39;*.jar&#39;</strong>])<br>    implementation <strong>&quot;com.android.support:appcompat-v7:</strong>$rootProject.ANDROID_SUPPORT_VERSION<strong>&quot;<br></strong>}<br><br>task sourcesJar(<strong>type</strong>: Jar) {<br>    from android.sourceSets.main.java.srcDirs<br>    classifier = <strong>&#39;sources&#39;<br></strong>}<br><br>task javadoc(<strong>type</strong>: Javadoc) {<br>    source = android.sourceSets.main.java.srcDirs<br>    classpath += project.files(android.getBootClasspath().join(File.<strong><em>pathSeparator</em></strong>))<br>}<br><br>task javadocJar(<strong>type</strong>: Jar, <strong>dependsOn</strong>: javadoc) {<br>    classifier = <strong>&#39;javadoc&#39;<br>    </strong>from javadoc.destinationDir<br>}<br><br>artifacts {<br>    archives <strong>javadocJar<br>    </strong>archives <strong>sourcesJar<br></strong>}<br><br>group = <strong>&#39;com.app.resume&#39; </strong><em>// library package name<br></em>version = <strong>&#39;1.0.5&#39;<br><br></strong>install {<br>    repositories.<strong>mavenInstaller </strong>{<br>        pom.project {<br>            name <strong>&#39;Umesh Kumar&#39;<br>            </strong>description <strong>&#39;A library for finding out whether someone is on the list or the nice list&#39;<br>            </strong>url <strong>&#39;https://github.com/umeshbsa/android-library-publish-maven-jcenter&#39;<br>            </strong>inceptionYear <strong>&#39;2019&#39;<br><br>            </strong>packaging <strong>&#39;aar&#39;<br>            </strong>groupId <strong>&#39;com.app.resume&#39; </strong><em>//package name of your library<br>            </em>artifactId <strong>&#39;resume-file-upload&#39; </strong><em>//Library name and must   be same as package name on bintray<br>            </em>version <strong>&#39;1.0.5&#39;<br><br>            </strong>licenses {<br>                license {<br>                    name <strong>&#39;The MIT License (MIT)&#39;<br>                    </strong>url <strong>&#39;https://opensource.org/licenses/MIT&#39;<br>                </strong>}<br>            }<br>            scm {<br>                connection <strong>&#39;https://github.com/umeshbsa/android-library-publish-maven-jcenter.git&#39;<br>                </strong>url <strong>&#39;https://github.com/umeshbsa/android-library-publish-maven-jcenter&#39;<br><br>            </strong>}<br>            developers {<br>                developer {<br>                    id = <strong>&#39;bsaumesh&#39; </strong><em>//bintray username<br>                    </em>name <strong>&#39;Umesh Kumar&#39;<br>                </strong>}<br>            }<br>        }<br>    }<br>}</pre><pre><em>// Bintray<br></em>Properties properties = <strong>new </strong>Properties()<br>properties.load(project.rootProject.file(<strong>&#39;local.properties&#39;</strong>).newDataInputStream())<br><br><br>bintray {<br>    <em>// Fetch from local.properties file<br>    // Please follow this step<br>    /*<br>     sdk.dir=/home/umesh/Android/Sdk<br>     user=umeshbsa// bintray username<br>     key=dd3e540bf673436cee35fc839607fe6252c117cc // Bintray profile key<br>     // To find this key follow this step-<br>      1. Go to Edit Profile and click on &#39;Api Key&#39; from list<br>      2. Fill your account password and show key, copy and paste on local.properties file.<br>      Note- Please do not this.<br>     user=&quot;umeshbsa&quot;<br>     key=&quot;dd3e540bf673436cee35fc839607fe6252c117cc&quot; this is not accepted by bintray.<br>     */<br>    </em>user = properties.getProperty(<strong>&#39;user&#39;</strong>)<br>    key = properties.getProperty(<strong>&#39;key&#39;</strong>)<br>    <strong>configurations </strong>= [<strong>&#39;archives&#39;</strong>]<br>    pkg {<br>        repo = <strong>&#39;maven&#39; </strong><em>// must be same as on bintray repo name<br>        </em>name = <strong>&#39;resume-file-upload&#39; </strong><em>// must be same of library name as bintray<br>        </em>userOrg = <strong>&#39;bsaumesh&#39; </strong><em>// this is username of bintray account<br>        </em><strong>licenses </strong>= [<strong>&#39;MIT&#39;</strong>]<br>        vcsUrl = <strong>&#39;https://github.com/bsaumesh/umesh-jcenter-androidlib.git&#39;<br>        </strong>publish = <strong>true<br>        </strong>version {<br>            name = <strong>&#39;1.0.5&#39;<br>            </strong>desc = <strong>&#39;This is updated version 1.0.5&#39;<br>            released </strong>= <strong>new </strong>Date()<br>            vcsTag = <strong>&#39;v1.0.5&#39;<br>        </strong>}<br>    }<br>}</pre><ul><li>Add this code in Root gradle</li></ul><pre>buildscript {</pre><pre>    repositories {<br>        google()<br>        jcenter()<br>    }<br>    dependencies {<br>        classpath &#39;com.android.tools.build:gradle:3.1.1&#39;<br>        classpath &#39;com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7&#39;<br>        classpath &#39;com.github.dcendents:android-maven-gradle-plugin:1.5&#39;<br>    }<br>}</pre><pre>allprojects {<br>    repositories {<br>        google()<br>        jcenter()<br>    }<br>}</pre><pre>task clean(type: Delete) {<br>    delete rootProject.buildDir<br>}<br></pre><pre>ext {<br>    COMPILE_SDK_VERSION = 27<br>    MIN_SDK_VERSION = 15<br>    ANDROID_SUPPORT_VERSION = &#39;27.1.1&#39;<br>    VERSION_CODE = 1<br>    VERSION_NAME = &#39;1.0&#39;<br>}</pre><p><strong>Step 4: Clean build and publish on Maven</strong></p><ul><li>Open Android Studio Terminal and write this command</li></ul><pre>./gradlew clean build bintrayUpload</pre><p><strong>Step 5: Add to jCenter:</strong></p><ul><li>After publish android library on maven. We have to add on jCenter repository to access on gradle dependency.</li><li>Click on ‘Add to jCenter’. Please fill all required field and finish it.</li><li>After 1 day, you will be get email for success of publish android library.</li><li>You can search your android library by this way <a href="https://bintray.com/bintray/jcenter?filterByPkgName=resume-file-upload">https://bintray.com/bintray/jcenter?filterByPkgName=resume-file-upload</a></li></ul><h4><strong>Conclusion</strong></h4><p>This is very simple way to upload android library on maven/jCenter. To use of this library put in app.gradle dependency file like this.</p><pre>implementation <strong>&quot;com.app.resume:resume-file-upload:1.0.5&quot;</strong></pre><h4>Code</h4><ul><li><a href="https://github.com/umeshbsa/android-library-publish-maven-jcenter">Github url for publish android library on maven/jCenter</a>.</li></ul><p>Have a nice day…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a933994f66c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[android-jenkins-with-gradle-task]]></title>
            <link>https://medium.com/@umesh.bsa/android-jenkins-with-gradle-task-f8f610bb9d17?source=rss-6207b076907e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8f610bb9d17</guid>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[android-gradle]]></category>
            <category><![CDATA[tasks]]></category>
            <dc:creator><![CDATA[Umesh Kumar]]></dc:creator>
            <pubDate>Thu, 03 Jan 2019 16:34:36 GMT</pubDate>
            <atom:updated>2019-01-05T09:12:54.601Z</atom:updated>
            <content:encoded><![CDATA[<h3>Jenkins Job with Android Gradle Task</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*NgabeuOxvfhAIkhK6J3vVA.png" /></figure><h4>Background</h4><p><strong>Jenkins</strong> script by using android studio gradle with task. We can create simple task in app.gradle file in android project and this task will be accessed from Jenkins console. If we want to change app name, app theme color, app icon at runtime, we can do all of via Jenkins script. Before starting this point, make sure we have some basic knowledge about bash scripting .sh and simple setup of Jenkins.</p><p>We can follow this <a href="https://github.com/umeshbsa/android-setup-jenkins-automation"><em>url</em></a> to learn simple setup of Jenkins with Hockey app integration.</p><p>If we want learn quickly to setup Jenkins Job with task, please follow this <a href="https://github.com/umeshbsa/android-jenkins-with-gradle-task"><em>url</em></a>.</p><p>Now let’s start overall integration…</p><p><strong>Main Focus</strong></p><p>Change app name, app color, api url, primary color, app icon as white labeling project.</p><p><strong>Key Point</strong></p><ul><li><strong>Jenkins: </strong>Jenkins is an automation tools for building automatically build like iOS, android and so on platform.</li><li><strong>Bash Script: </strong>Bash script is a simple scripting language used for jenkins console.</li><li><strong>Gradlew: </strong>Gradlew is command line used for creation android build as debug or release apk with given task.</li><li><strong>Task: </strong>This is very important point in this blog. Task is define to manage at runtime from Jenkins console. Task is created in app.gradle file which we want to change in app.</li></ul><p><strong>Simple Bash Script Example</strong></p><p>Create a simple text file name as ‘simple_example.sh’ and save on ‘Desktop’ path. Copy below of content into ‘simple_example.sh file.</p><pre>#!/bin/bash</pre><pre>echo &quot;Simple Bash Scripting Example&quot;<br>APP_NAME=&quot;Jenkins_Gradle_Task&quot;<br>echo $APP_NAME</pre><p>Run the bash script file. Go to terminal and follow this step.</p><blockquote><strong>user@user:~/Desktop$</strong> ./simple_example.sh<br>bash: ./simple_example.sh: Permission denied<br><strong>user@user:~/Desktop$</strong> sudo chmod 777 ./simple_example.sh<br>[sudo] password for umesh: <br><strong>user@user:~/Desktop$</strong> ./simple_example.sh<br>Simple Bash Scripting Example<br>Jenkins_Gradle_Task</blockquote><p>Now comes to main target point……</p><h4><strong>Implementation</strong></h4><ul><li><strong>Write Task: </strong>We have write task in app.gradle file which we want change from Jenkins console. In this example suppose we want to change app version code and primary color from Jenkins script. But we can change any thinks by help of Jenkins bash script. Jenkins bash script define in future, make some patience in your heart.</li></ul><p>Example: How to write task in app.gradle file.</p><pre>// Gradle task for app version code<br>   def appVersionCode = 1<br>   task(versionCodeTask) {<br>       if (project.hasProperty(&quot;versioncode&quot;)) {<br>           appVersionCode = Integer.parseInt(versioncode); ;<br>       }<br>   }<br><br>   // Gradle task for promary color<br>   def primaryColor = &#39;&quot;#FF00FF&quot;&#39;<br>   task(primaryColorTask) {<br>       if (project.hasProperty(&quot;primarycolor&quot;)) {<br>           primaryColor = primarycolor;<br>       }<br>   }</pre><pre>// Gradle task for splash logo<br>def splashLogo = &#39;@drawable/splash_logo&#39;    <br>task(splashLogoTask) {        <br>    if (project.hasProperty(&quot;splashlogo&quot;)) { <br>           splashLogo = splashlogo;        <br>    } <br>}</pre><p>Now, we have to remember task name ‘versionCodeTask’ and property value ‘versioncode’ because it is used in Jenkins bash script.</p><ul><li><strong>Write Product Flavor: </strong>As we see, the write of task is very simple as now product flavor is very simple. We can write two or more product flavor. In this example we write only two product flavor one for prod(as release apk) and second for qa(as debug apk).</li></ul><p>Example: How to write product flavor.</p><pre>productFlavors {<br>      prod { // as release apk<br>          applicationId appApplicationId<br>          signingConfig signingConfigs.releaseConfig<br>          buildConfigField &quot;String&quot;, &quot;BASE_URL&quot;, baseUrl<br>          buildConfigField &quot;String&quot;, &quot;PRIMARY_COLOR&quot;, primaryColor<br>          manifestPlaceholders = [<br>                  appName: appName,<br>                  appIcon: appIcon<br>          ]<br>          resValue &quot;drawable&quot;, &quot;splash_logo&quot;, splashLogo<br>          versionCode appVersionCode<br>          versionName appVersionName<br>      }<br><br>      qa { // as debug apk<br>          applicationId appApplicationId<br>          signingConfig signingConfigs.debugConfig<br>          buildConfigField &quot;String&quot;, &quot;BASE_URL&quot;, baseUrl<br>          buildConfigField &quot;String&quot;, &quot;PRIMARY_COLOR&quot;, primaryColor<br>          manifestPlaceholders = [<br>                  appName: appName,<br>                  appIcon: appIcon<br>          ]         <br>          resValue &quot;drawable&quot;, &quot;splash_logo&quot;, splashLogo<br>          versionCode appVersionCode<br>          versionName appVersionName<br>      }<br>  }</pre><p>As we can see there are many task such as applicationId, base url, splash logo. We have to see first github task <a href="https://github.com/umeshbsa/android-jenkins-with-gradle-task"><em>url</em></a> for better understanding about creation of task and used in product flavor.</p><ul><li><strong>Jenkins Job: </strong>Create a simple Jenkins job with the help of this <a href="https://github.com/umeshbsa/android-setup-jenkins-automation"><em>url</em></a>.</li><li><strong>Jenkins Script: </strong>This is main fundamental of this blog. Jenkins script is just like to bash script as we learnt before. We have to more command on bash script to better understanding on Jenkins script.</li></ul><p>Example of Jenkins Script.</p><pre>#!/bin/bash</pre><pre>#Step 1:<br>APP_NAME=&quot;Jenkins_Gradle_Task&quot; // As your wish<br>APPLICATION_ID=&quot;com.app.gradle&quot; // As your wish<br>VERSION_NAME=&quot;1.0.0&quot; // As your wish<br>VERSION_CODE=1 // As your wish<br>BASE_URL=&#39;&quot;https://com.app/&quot;&#39; // As your wish<br>PRIMARY_COLOR=&#39;&quot;#ff00ff&quot;&#39; // As your wish<br>APP_ICON=&quot;/home/umesh/Desktop/icon.png&quot; // As your wish<br>SPLASH_LOGO=&quot;/home/umesh/Desktop/splash_logo.png&quot; // As your wish. #Image name must be splash_logo<br><br>SRC=&quot;/var/lib/jenkins/workspace/icon.png&quot;</pre><pre>#Step 2:<br>DEST1=&quot;/var/lib/jenkins/workspace/android-jenkins-with-gradle-task/app/src/main/res/mipmap-xhdpi&quot;</pre><pre>DEST2=&quot;/var/lib/jenkins/workspace/android-jenkins-with-gradle-task/app/src/main/res/mipmap-xxhdpi&quot;</pre><pre>DEST3=&quot;/var/lib/jenkins/workspace/android-jenkins-with-gradle-task/app/src/main/res/mipmap-xxxhdpi&quot;</pre><pre>DEST4=&quot;/var/lib/jenkins/workspace/android-jenkins-with-gradle-task/app/src/main/res/drawable-xxxhdpi&quot;<br><br>FILE_NAME_EXT_ICON=$(basename &quot;$APP_ICON&quot;)<br>FILE_NAME_ICON=&quot;${FILE_NAME_EXT_ICON%.*}&quot;<br><br>FILE_NAME_EXT_SPLASH=$(basename &quot;$SPLASH_LOGO&quot;)<br>FILE_NAME_SPLASH=&quot;${FILE_NAME_EXT_SPLASH%.*}&quot;</pre><pre>#Step 3:<br>convert $APP_ICON -resize &quot;96x96&quot; $SRC<br>cp  $SRC $DEST1<br><br>convert $APP_ICON -resize &quot;144x144&quot; $SRC<br>cp  $SRC $DEST2<br><br>convert $APP_ICON -resize &quot;192x192&quot; $SRC<br>cp  $SRC $DEST3<br><br>cp  $SPLASH_LOGO $DEST4</pre><pre>#Step 4:<br>#Start for prod release apk</pre><pre>// As your wish in jks file setup<br>KEY_STORE_FILE=&quot;/home/Documents/key1.jks&quot; <br>KEY_STORE_PASSWORD=&quot;654321&quot; // As your wish in jks file setup<br>KEY_STORE_ALIAS=&quot;cbs1&quot; // As your wish in jks file setup<br>KEY_PASSWORD=&quot;123456&quot; // As your wish in jks file setup</pre><pre>#Step 5:<br>./gradlew clean assembleProdRelease task keyStoreFileTask &#39;-Pkeystorefile=&#39;$KEY_STORE_FILE task keyStorePasswordTask &#39;-Pkeystorepassword=&#39;$KEY_STORE_PASSWORD task keyStoreAliasTask &#39;-Pkeystorealias=&#39;$KEY_STORE_ALIAS task keyPasswordTask &#39;-Pkeypassword=&#39;$KEY_PASSWORD task versionNameTask &#39;-Pversionname=&#39;$VERSION_NAME task appNameTask &#39;-Pappname=&#39;$APP_NAME task applicationIdTask &#39;-Papplicationid=&#39;$APPLICATION_ID task versionCodeTask &#39;-Pversioncode=&#39;$VERSION_CODE task baseUrlTask &#39;-Pbaseurl=&#39;$BASE_URL task primaryColorTask &#39;-Pprimarycolor=&#39;$PRIMARY_COLOR task appIconTask &#39;-Pappicon=@mipmap/&#39;$FILE_NAME_ICON  task splashLogoTask &#39;-PsplashLogo=@drawable/&#39;$FILE_NAME_SPLASH<br><br>#End for prod release apk</pre><pre>#Step 6:<br>#Start for qa debug apk <br><br>./gradlew clean assembleQaDebug task versionNameTask &#39;-Pversionname=&#39;$VERSION_NAME task appNameTask &#39;-Pappname=&#39;$APP_NAME task applicationIdTask &#39;-Papplicationid=&#39;$APPLICATION_ID task versionCodeTask &#39;-Pversioncode=&#39;$VERSION_CODE task baseUrlTask &#39;-Pbaseurl=&#39;$BASE_URL task primaryColorTask &#39;-Pprimarycolor=&#39;$PRIMARY_COLOR task appIconTask &#39;-Pappicon=@mipmap/&#39;$FILE_NAME_ICON  task splashLogoTask &#39;-PsplashLogo=@drawable/&#39;$FILE_NAME_SPLASH<br><br>#End for qa debug apk</pre><p>In this example, we changed ‘App Name’, ‘Application Id’, ‘Version Name’, ‘Version Code’, ‘Base URL’, ‘Primary Color’, ‘App Icon’, ‘Splash Logo’ and so on. All Jenkins script are defined into 5 Step.</p><ul><li><strong>Step 1:</strong> Initialized all input as we want to change from Jenkins with gradle task. All input must be written with task in app.gradle file.</li><li><strong>Step 2: </strong>Create folder in Jenkins path to copy of app icon and splash logo.</li><li>Step 3: Convert app icon in all size and copy into appropriate folder like mipmap and drawable</li><li><strong>Step 4:</strong> Setup key store file with help of jks to create release apk. Make sure write task for jks file in app.gradle file. If any doubt follow this github task link.</li><li><strong>Step 5:</strong> Run this command and create release apk.</li><li><strong>Step 6:</strong> Run this command and create debug apk. Run both apk on your device and see all changes.</li></ul><h4>Conclusion</h4><p>Final Output from Jenkins Script:</p><ul><li>This is a final output to created from Jenkins console APK. In this apk, We have changed header color and splash logo image from jenkins script. We can see below.</li></ul><pre>PRIMARY_COLOR=&#39;&quot;#FF4081&quot;&#39; // As your wish<br>SPLASH_LOGO=&quot;/home/umesh/Desktop/splash_logo.png&quot; // As your wish. </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*wMy760O-XikvnJoTgcHhfg.png" /></figure><h4><strong>Code</strong></h4><ul><li><a href="https://github.com/umeshbsa/android-setup-jenkins-automation">Github url for simple Jenkins setup</a>.</li><li><a href="https://github.com/umeshbsa/android-jenkins-with-gradle-task">Github url for Jenkins setup with gradle task</a>.</li></ul><p>Have a nice day…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8f610bb9d17" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>