<?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: Nwokocha wisdom maduabuchi</title>
    <description>The latest articles on DEV Community by Nwokocha wisdom maduabuchi (@wise4rmgod).</description>
    <link>https://dev.to/wise4rmgod</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%2F215983%2F8bab118a-d52b-4439-a0ab-56021dc4c482.jpeg</url>
      <title>DEV Community: Nwokocha wisdom maduabuchi</title>
      <link>https://dev.to/wise4rmgod</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wise4rmgod"/>
    <language>en</language>
    <item>
      <title># How to Deploy a Word Counter Application to AWS S3 Bucket</title>
      <dc:creator>Nwokocha wisdom maduabuchi</dc:creator>
      <pubDate>Wed, 06 Mar 2024 11:32:36 +0000</pubDate>
      <link>https://dev.to/aws-builders/-how-to-deploy-a-word-counter-application-to-aws-s3-bucket-5bdn</link>
      <guid>https://dev.to/aws-builders/-how-to-deploy-a-word-counter-application-to-aws-s3-bucket-5bdn</guid>
      <description>&lt;p&gt;AWS S3 is a cloud storage service provided by Amazon Web Services. It is a simple storage service that offers scalability, security, and performance for storing and retrieving data.&lt;/p&gt;

&lt;p&gt;S3 allows developers to host static websites, store and retrieve data anytime, and manage data using a web interface.&lt;/p&gt;

&lt;p&gt;You’ll deploy a word counter application using an AWS S3 bucket. You can access this application in a web browser at the end of this article.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is an S3 Bucket?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html"&gt;Amazon Simple Storage Service S3&lt;/a&gt; is a scalable object storage service offered by AWS. It allows you to store and retrieve data from anywhere on the web.&lt;/p&gt;

&lt;p&gt;An S3 bucket is essentially a container for objects stored in S3. It serves as the top-level folder in which you store your files.&lt;/p&gt;

&lt;p&gt;S3 is an object storage service that stores data as objects in containers called buckets. An object can be any kind of file: a text file, an image, a video, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Overview
&lt;/h2&gt;

&lt;p&gt;This project will use the AWS console to create an S3 bucket and deploy a word counter application to the bucket.&lt;/p&gt;

&lt;p&gt;The word counter application contains HTML, CSS, and JavaScript files. The application will count the number of words in a given text.&lt;/p&gt;

&lt;p&gt;Once the bucket is created, you'll upload the Word Counter application files to it and make it public to access it using a web browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;This tutorial assumes that you have an &lt;a href="https://aws.amazon.com/"&gt;AWS account&lt;/a&gt; and are familiar with the AWS Management Console. Every other step will be explained in detail.&lt;/p&gt;

&lt;h3&gt;
  
  
  Application setup
&lt;/h3&gt;

&lt;p&gt;This word counter app can be found on GitHub. Clone the repository to your local machine using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/Aahil13/Word-counter.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The word counter application contains the following files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;index.html&lt;/code&gt;: The main HTML file that contains the structure of the application.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;style.css&lt;/code&gt;: The CSS file that contains the styles for the application.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;index.js&lt;/code&gt;: The JavaScript file that contains the logic for the word counter application.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;README.md&lt;/code&gt;: The README file that contains the instructions for running the application.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Dockerfile&lt;/code&gt;: The Dockerfile that contains the instructions for building the Docker image.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Favicon folder&lt;/code&gt;: The folder that contains the favicon for the application.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Create an S3 Bucket
&lt;/h2&gt;

&lt;p&gt;To create an S3 bucket, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the AWS Management Console and navigate to the S3 service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the &lt;strong&gt;Create bucket&lt;/strong&gt; button to create a new bucket.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter a unique name for your bucket and select the region where you want to create it. Then click on the &lt;strong&gt;Create bucket&lt;/strong&gt; button to create the bucket.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Figure 1&lt;/strong&gt;: Enter a unique name for your bucket.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Once the bucket is created, click on the bucket name to open the bucket.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Figure 2&lt;/strong&gt;: Bucket created.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Configure Bucket for Static Website Hosting
&lt;/h2&gt;

&lt;p&gt;To configure the bucket for static website hosting, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click on the &lt;strong&gt;Properties&lt;/strong&gt; tab and then click on the &lt;strong&gt;Static website hosting&lt;/strong&gt; card.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on &lt;strong&gt;Edit&lt;/strong&gt; and select the &lt;strong&gt;Enable&lt;/strong&gt; option. Enter the name of the index document (e.g, &lt;code&gt;index.html&lt;/code&gt;) and click on the &lt;strong&gt;Save changes&lt;/strong&gt; button to save the changes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Figure 3&lt;/strong&gt;: Configure the bucket for static website hosting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Make the Bucket Public
&lt;/h2&gt;

&lt;p&gt;To make the bucket public, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;On the &lt;strong&gt;Permissions&lt;/strong&gt; tab, click on the &lt;strong&gt;Block public access&lt;/strong&gt; button and then click on the &lt;strong&gt;Edit&lt;/strong&gt; button.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Figure 4&lt;/strong&gt;: Block public access.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Uncheck the &lt;strong&gt;Block all public access&lt;/strong&gt; option and click on the &lt;strong&gt;Save changes&lt;/strong&gt; button.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Figure 5&lt;/strong&gt;: Uncheck the block-all public access option.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Still on the &lt;strong&gt;Permissions&lt;/strong&gt; tab, click on the &lt;strong&gt;Bucket Policy&lt;/strong&gt; button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click &lt;strong&gt;Edit&lt;/strong&gt; and enter the following bucket policy to make the bucket public. Replace &lt;code&gt;your-bucket-name&lt;/code&gt; with the name of your bucket.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"Sid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"PublicReadGetObject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"Principal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"s3:GetObject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"arn:aws:s3:::your-bucket-name/*"&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Click on the &lt;strong&gt;Save changes&lt;/strong&gt; button to save the bucket policy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure 6&lt;/strong&gt;: Bucket policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Upload Application Files to the Bucket
&lt;/h2&gt;

&lt;p&gt;To upload the application files to the bucket, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;On the &lt;strong&gt;Objects&lt;/strong&gt; tab, click on the &lt;strong&gt;Upload&lt;/strong&gt; button to upload the application files to the bucket.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Figure 7&lt;/strong&gt;: Upload the application files to the bucket.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click the &lt;strong&gt;Add files&lt;/strong&gt; button and select the application files from your local machine. Then, click on &lt;strong&gt;Add folder&lt;/strong&gt; to upload the favicon folder.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Figure 8&lt;/strong&gt;: Add files to the bucket.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click the &lt;strong&gt;Upload&lt;/strong&gt; button to upload the files to the bucket.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Figure 9&lt;/strong&gt;: Application files uploaded to the bucket.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Access the Application
&lt;/h2&gt;

&lt;p&gt;To access the application, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the bucket and click on the &lt;strong&gt;Properties&lt;/strong&gt; tab.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the &lt;strong&gt;Static website hosting&lt;/strong&gt; card and copy the endpoint URL.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Figure 10&lt;/strong&gt;: Copy the endpoint URL.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open a web browser and paste the endpoint URL in the address bar.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Figure 11&lt;/strong&gt;: Word counter application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clean Up
&lt;/h2&gt;

&lt;p&gt;After deploying and playing around with your application, you can delete the S3 bucket to avoid incurring unnecessary charges.&lt;/p&gt;

&lt;p&gt;To delete the S3 bucket, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;On the &lt;strong&gt;word-counter&lt;/strong&gt; bucket, select all the files and click on the &lt;strong&gt;Delete&lt;/strong&gt; button to delete the files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Afterward, go back to your bucket and click the &lt;strong&gt;Delete&lt;/strong&gt; button to delete the bucket.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article, you learned about AWS S3 and how to deploy a word counter application to an S3 bucket.&lt;/p&gt;

&lt;p&gt;You created an S3 bucket, configured it for static website hosting, uploaded the application files to the bucket, and accessed the application using a web browser.&lt;/p&gt;

&lt;p&gt;This is a simple and fast way of hosting static websites on AWS!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Setup an Integrated Development Environment on AWS</title>
      <dc:creator>Nwokocha wisdom maduabuchi</dc:creator>
      <pubDate>Fri, 16 Feb 2024 17:56:54 +0000</pubDate>
      <link>https://dev.to/aws-builders/how-to-setup-an-integrated-development-environment-on-aws-4mi</link>
      <guid>https://dev.to/aws-builders/how-to-setup-an-integrated-development-environment-on-aws-4mi</guid>
      <description>&lt;p&gt;It is common for development teams to be distributed all over the world, and this can create a significant problem when collaborating. Remote teams often have isolated development environments on each developer's laptop. In the event of a bug or a problem, a developer may spend hours trying to fix it, whereas another team member may be able to resolve it more quickly.&lt;/p&gt;

&lt;p&gt;It is often difficult for team members to collaborate in the traditional paradigm of local IDEs due to geographical constraints and isolation. An effective solution to this problem is to create a shared development environment. It should be accessible to all team members, regardless of their location. This is where cloud-based IDEs come in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://aws.amazon.com/cloud9/?p=pm&amp;amp;c=cloud9&amp;amp;z=4"&gt;Cloud9&lt;/a&gt; is an AWS-developed IDE service that lets developers collaborate on a single codebase using cloud technology At the end of this article, you will learn how developers can collaborate on a single codebase using Cloud9.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Cloud9?
&lt;/h2&gt;

&lt;p&gt;AWS Cloud9 is a browser-based development environment that is backed by an Amazon EC2 instance. It provides a user with a complete environment including an editor, terminal, and terminal in the cloud.&lt;/p&gt;

&lt;p&gt;A variety of programming languages are also available, including Python, JavaScript, PHP, and more. With Cloud9, you can work with your team members in real time. Your team members can also work on the same codebase by sharing a development environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Cloud9?
&lt;/h2&gt;

&lt;p&gt;Apart from sharing environments for quick collaboration and pair coding, these are some reasons why you should consider using Cloud9:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Quick setup time:&lt;/strong&gt; Setting up a development environment on Cloud9 is quick and easy. You can set up and configure your development environment in minutes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Limited Maintenance:&lt;/strong&gt; Cloud9 is a managed service, so you don't have to worry about maintaining the infrastructure. AWS takes care of the infrastructure, so you can focus on writing code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Unlimited access:&lt;/strong&gt; You're not tied to a single machine. You can access your development environment from any machine with an internet connection. Allowing you to work from anywhere.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Easy integration with AWS services:&lt;/strong&gt; When you use AWS Cloud9, you can target AWS services such as AWS Lambda, pull code from AWS CodeCommit, and set up CI/CD pipelines with AWS CodePipeline.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Disposable environments:&lt;/strong&gt; When carrying out tests or debugging, you can create a new environment and discard it when you're done. This helps to keep your development environment clean and organized.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setting up Cloud9
&lt;/h2&gt;

&lt;p&gt;This article will guide you through setting up a Cloud9 environment using the AWS console.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;To set up a Cloud9 environment, you will need the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;An AWS account. If you don't have one, you can create one for free &lt;a href="https://portal.aws.amazon.com/billing/signup#/start/email"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Stable internet connection. Cloud9 is a cloud-based service, so you will need a stable internet connection to use it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A fundamental knowledge of AWS and how to navigate the AWS Management Console. To get started, you can check out the &lt;a href="https://aws.amazon.com/getting-started/hands-on/"&gt;AWS Management Console&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To create a Cloud9 environment using the AWS console, follow the steps below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;On AWS, navigate to the Cloud 9 console and click on the &lt;strong&gt;Create Environment&lt;/strong&gt; button.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6xeoctnfx02eskt962dt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6xeoctnfx02eskt962dt.png" alt="Cloud9 console" width="800" height="241"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fill in the form, specifying the &lt;strong&gt;Name&lt;/strong&gt;, &lt;strong&gt;Instance type&lt;/strong&gt; and &lt;strong&gt;Platform&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flw22cfur7fmj0bnxhwpo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flw22cfur7fmj0bnxhwpo.png" alt="Create Environment" width="800" height="309"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnv5vtybw5h0fs1tpd9hx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnv5vtybw5h0fs1tpd9hx.png" alt="Create Environment Form" width="800" height="315"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuqyl62aipd5o8cmg0s3c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuqyl62aipd5o8cmg0s3c.png" alt="Create Environment Form 2" width="800" height="252"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After which, click on the &lt;strong&gt;Create&lt;/strong&gt; button.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F36t16hy1zsxnw25q2eo2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F36t16hy1zsxnw25q2eo2.png" alt="Create Environment Form 3" width="800" height="304"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After the Cloud9 environment is provisioned, you can open the IDE.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffsryuf016etabg0yrq8m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffsryuf016etabg0yrq8m.png" alt="Cloud9 Environment" width="800" height="210"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Under the &lt;strong&gt;Cloud9 IDE&lt;/strong&gt; tab, click on &lt;strong&gt;Open&lt;/strong&gt; to view the IDE.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkogkpio1qjvdbrffar3a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkogkpio1qjvdbrffar3a.png" alt="Cloud9 Environment 2" width="800" height="254"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Explore the Cloud9 IDE. Observe the similarities and differences between your conventional IDE and this one.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm0ziwlsgbhou6b8h4lr1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm0ziwlsgbhou6b8h4lr1.png" alt="Cloud9 Environment 3" width="800" height="330"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftg5x14d5hiunzgqzit6f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftg5x14d5hiunzgqzit6f.png" alt="Cloud9 Environment 4" width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Remember to destroy the environment and associated resources such as the IAM role when finished.&lt;/p&gt;

&lt;p&gt;With this setup, you can share your codebase with your team members and collaborate in real time.&lt;/p&gt;

&lt;p&gt;To create a Cloud9 environment for an entire team, you can create an IAM role with the necessary permissions and share the environment with the team members. Learn more about Cloud9 team environments &lt;a href="https://docs.aws.amazon.com/cloud9/latest/user-guide/setup.html"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This article explains how to set up a Cloud9 environment via the AWS console. You have also learned about the benefits of using Cloud9 as a shared development environment.&lt;/p&gt;

&lt;p&gt;You can extend this knowledge by &lt;a href="https://github.com/Aahil13/Automated-AWS-Cloud9-Development-Environment"&gt;automating this process with AWS CloudFormation&lt;/a&gt;. This will allow you to create and destroy Cloud9 environments on the fly.&lt;/p&gt;

&lt;p&gt;Additionally, you could include configuration management tools such as Ansible to install and configure the necessary tools and libraries on the Cloud9 environment.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Building a Social Media App with AWS Amplify and Android Studio: A Step-by-Step Guide</title>
      <dc:creator>Nwokocha wisdom maduabuchi</dc:creator>
      <pubDate>Fri, 31 Mar 2023 10:06:54 +0000</pubDate>
      <link>https://dev.to/aws-builders/building-a-social-media-app-with-aws-amplify-and-android-studio-a-step-by-step-guide-1e7e</link>
      <guid>https://dev.to/aws-builders/building-a-social-media-app-with-aws-amplify-and-android-studio-a-step-by-step-guide-1e7e</guid>
      <description>&lt;p&gt;AWS Amplify is a popular development framework that enables developers to build scalable and secure cloud-powered applications. It simplifies the development process by providing a set of tools and services that allow developers to create high-quality mobile and web applications quickly. With AWS Amplify, developers can easily integrate cloud services into their applications, such as authentication, storage, APIs, and real-time data synchronization. &lt;/p&gt;

&lt;p&gt;The purpose of this article is to provide a comprehensive, step-by-step guide to building a social media app using AWS Amplify and Android Studio. The article will explain how to set up Android Studio, add Amplify to the project, create a backend using the Amplify CLI, and implement authentication, storage, API services, and real-time data functionality using Amazon Cognito, Amazon S3, Amazon API Gateway, and Amazon AppSync. By the end of the article, readers will have a fully functional social media app that demonstrates the power and versatility of AWS Amplify and Android Studio.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up Development Environment
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Downloading and installing Android Studio&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Visit the Android Studio website (&lt;a href="https://developer.android.com/studio"&gt;https://developer.android.com/studio&lt;/a&gt;) and click on the "Download Android Studio" button.&lt;/li&gt;
&lt;li&gt;Choose the appropriate version for your operating system (Windows, macOS, or Linux) and click the "Download" button.&lt;/li&gt;
&lt;li&gt;Once the download is complete, run the installer file and follow the instructions to install Android Studio on your computer.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Creating a new project:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Launch Android Studio and select "Start a new Android Studio project" from the main menu.&lt;/li&gt;
&lt;li&gt;Choose the "Phone and Tablet" option and select the type of project you want to create, such as "Empty Activity" or "Basic Activity".&lt;/li&gt;
&lt;li&gt;Set the name and package name for your project.&lt;/li&gt;
&lt;li&gt;Choose the minimum SDK version and the target SDK version.&lt;/li&gt;
&lt;li&gt;Select the language you want to use (Java or Kotlin).&lt;/li&gt;
&lt;li&gt;Choose any additional features or services you want to include in your project.&lt;/li&gt;
&lt;li&gt;Click "Finish" to create your project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Congratulations! You have successfully installed Android Studio and created a new project. &lt;br&gt;
In the next section, you will explore how to integrate AWS Amplify into your Android Studio project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integrating AWS Amplify into Android Studio Project
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open your project in Android Studio.&lt;/li&gt;
&lt;li&gt;Navigate to the "app" folder in the project explorer.&lt;/li&gt;
&lt;li&gt;Open the build.gradle file for your app module.&lt;/li&gt;
&lt;li&gt;In the dependencies section, add the following line of code to include the AWS Amplify dependency:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;implementation 'com.amplifyframework:core:1.8.1'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Click on the "Sync Now" button to sync the changes with your project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Initializing Amplify in onCreate method of MainActivity.java file:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your MainActivity.java file.&lt;/li&gt;
&lt;li&gt;Add the following import statement at the top of your file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import com.amplifyframework.core.Amplify;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;In the onCreate method of your MainActivity, add the following code to initialize AWS Amplify:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Amplify.configure(getApplicationContext());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;This line of code initializes Amplify with the application context.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Congratulations! You have successfully added the AWS Amplify dependency to your build.gradle file and initialized it in your MainActivity.java file. &lt;br&gt;
In the next section, we will explore how to create an AWS Amplify backend for your Android application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating an AWS Amplify Backend
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open a terminal or command prompt and install the Amplify CLI by running the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g @aws-amplify/cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Once the installation is complete, initialize Amplify in your project directory by running the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;amplify init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Follow the prompts to configure your Amplify backend. Choose the appropriate options for your project, such as the AWS region, authentication type, and API type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once you have configured your backend, use the Amplify CLI to create the necessary resources by running the following command:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;amplify push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;This command creates the resources specified in your Amplify configuration file, such as authentication, API, and storage resources.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Configuring and deploying the backend:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;After running the amplify push command, navigate to the Amplify console in the AWS Management Console.&lt;/li&gt;
&lt;li&gt;Click on the "Backend environments" option in the left-hand menu and select your project.&lt;/li&gt;
&lt;li&gt;Click on the "Backend environments" tab and click on the environment you want to deploy to.&lt;/li&gt;
&lt;li&gt;Click on the "Deploy changes" button to deploy your backend resources to the selected environment.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Congratulations! You have successfully created an AWS Amplify backend for your Android application using the Amplify CLI and deployed it to the selected environment. &lt;br&gt;
In the next section, we will explore how to use AWS Amplify to implement various cloud services in your Android application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using AWS Amplify in Android Studio
&lt;/h2&gt;

&lt;p&gt;*&lt;em&gt;Adding authentication to the application using Amazon Cognito:&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your Amplify configuration file (amplify/backend/amplify-meta.json).&lt;/li&gt;
&lt;li&gt;Add the following lines of code to the auth section to enable Amazon Cognito authentication:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"auth": {
  "plugins": {
    "awsCognitoAuthPlugin": {
      "userPoolId": "YOUR_USER_POOL_ID",
      "region": "YOUR_AWS_REGION",
      "userPoolWebClientId": "YOUR_USER_POOL_WEB_CLIENT_ID"
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Replace the placeholders with your Amazon Cognito user pool ID, region, and user pool web client ID.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your Android project, initialize the Amazon Cognito authentication by adding the following code in your MainActivity.java file:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Amplify.addPlugin(new AWSCognitoAuthPlugin());
Amplify.configure(getApplicationContext());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;This code initializes the Amazon Cognito authentication plugin and configures Amplify with the application context.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementing storage using Amazon S3:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your Amplify configuration file.&lt;/li&gt;
&lt;li&gt;Add the following lines of code to the storage section to enable Amazon S3 storage:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"storage": {
  "plugins": {
    "awsS3StoragePlugin": {
      "bucketName": "YOUR_BUCKET_NAME",
      "region": "YOUR_AWS_REGION"
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Replace the placeholders with your Amazon S3 bucket name and region.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your Android project, use the Amplify Storage API to upload and download files from Amazon S3. For example, to upload a file, add the following code:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;File localFile = new File(getApplicationContext().getFilesDir(), "localFileName.jpg");
Amplify.Storage.uploadFile(
        "remoteFileName.jpg",
        localFile,
        result -&amp;gt; Log.i("MyAmplifyApp", "Successfully uploaded: " + result.getKey()),
        error -&amp;gt; Log.e("MyAmplifyApp", "Upload failed", error)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using API services with Amazon API Gateway:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your Amplify configuration file.&lt;/li&gt;
&lt;li&gt;Add the following lines of code to the api section to enable Amazon API Gateway:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"api": {
  "plugins": {
    "awsAPIPlugin": {
      "endpointType": "REST",
      "endpoint": "YOUR_API_ENDPOINT",
      "region": "YOUR_AWS_REGION"
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Replace the placeholders with your Amazon API Gateway endpoint and region.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your Android project, use the Amplify API category to interact with your API resources. For example, to fetch data from a resource, add the following code:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Amplify.API.get("resourceName", "/resourcePath", null,
        response -&amp;gt; Log.i("MyAmplifyApp", response.getData().asString()),
        error -&amp;gt; Log.e("MyAmplifyApp", "Failed to get resource data", error)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Displaying real-time data with Amazon AppSync:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your Amplify configuration file.&lt;/li&gt;
&lt;li&gt;Add the following lines of code to the api section to enable Amazon AppSync:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"api": {
  "plugins": {
    "awsAPIPlugin": {
      "endpointType": "GraphQL",
      "endpoint": "YOUR_APPSYNC_API_ENDPOINT",
      "region": "YOUR_AWS_REGION"
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Replace the placeholders with your Amazon AppSync API endpoint and region.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your Android project, use the Amplify API category to subscribe to real-time data changes. For example, to listen for updates to a specific resource, add the following code:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Amplify.API
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using API Services
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create a new REST API in the Amazon API Gateway console&lt;/li&gt;
&lt;li&gt;Go to the Amazon API Gateway console and click "Create API."&lt;/li&gt;
&lt;li&gt;Choose "REST API" as the type of API to create.&lt;/li&gt;
&lt;li&gt;Select "New API" and give your API a name.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click "Create API."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new resource&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click "Create Resource" under your newly created API.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter a name for your resource and click "Create Resource."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new method for the resource&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select your newly created resource and click "Create Method."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose the type of method you want to create (e.g., GET, POST, PUT).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the integration type (e.g., Lambda Function, HTTP Proxy, Mock).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Configure the integration settings according to your specific use case.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click "Save."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deploy the API&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click "Actions" and select "Deploy API."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose the deployment stage (e.g., Prod, Test) and click "Deploy."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the API in your Android app&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open your Android Studio project and add the necessary dependencies to your app's build.gradle file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new instance of the Amazon API Gateway client and set the appropriate endpoint and API key.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the client to make requests to your API and receive responses back in your app.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By following these steps, you can easily set up Amazon API Gateway and add API services to your social media app using AWS Amplify and Android Studio.&lt;/p&gt;

&lt;h2&gt;
  
  
  Displaying Real-time Data
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create a new GraphQL API in the Amazon AppSync console&lt;/li&gt;
&lt;li&gt;Go to the Amazon AppSync console and click "Create API."&lt;/li&gt;
&lt;li&gt;Choose "Create with Wizard" and give your API a name.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select "None" for data source and click "Create."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Define a GraphQL schema for your API&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the AppSync console, select your newly created API and click "Schema."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Define the data types and fields for your API using the GraphQL schema language.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save your schema.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new data source for your API&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the AppSync console, select your API and click "Data Sources."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click "Create New Data Source" and select the appropriate data source type (e.g., Amazon DynamoDB, AWS Lambda).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Configure the data source settings according to your specific use case.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click "Create."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new resolver for your API&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the AppSync console, select your API and click "Resolvers."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click "Create Resolver" and select the appropriate data source and field.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Define the resolver mapping template using the appropriate AppSync resolver syntax.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save your resolver.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add real-time data functionality to your app&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open your Android Studio project and add the necessary dependencies to your app's build.gradle file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new instance of the Amazon AppSync client and set the appropriate endpoint and API key.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Subscribe to the appropriate GraphQL subscription in your app's code to receive real-time updates from your API.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By following these steps, you can easily set up Amazon AppSync and add real-time data functionality to your social media app using AWS Amplify and Android Studio.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing the App
&lt;/h2&gt;

&lt;p&gt;After developing your social media app with AWS Amplify and Android Studio, you can run and test it on an Android device or emulator using the following steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Connect your Android device or start an emulator&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Connect your Android device to your computer using a USB cable, or start an emulator using Android Studio's AVD Manager.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build and run your app in Android Studio&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the "Run" button in Android Studio or select "Run" from the "Run" menu.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select your Android device or emulator from the list of available devices and click "OK."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Android Studio will build and install your app on the selected device or emulator.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test the app's functionality&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open the app on your Android device or emulator.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test the various features and functionality of your social media app, including authentication, storage, API services, and real-time data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify that your app is working correctly and that all features are functioning as expected.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Debug any issues&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you encounter any issues while testing your app, use Android Studio's debugging tools to identify and fix the problem.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the Android Logcat window to view app logs and error messages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the Android Debugging Bridge (ADB) to interact with your device or emulator and debug issues in real-time.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By following these steps, you can easily run and test your social media app on an Android device or emulator using AWS Amplify and Android Studio. This will ensure that your app is working correctly and that all features are functioning as expected before releasing it to your users.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;In summary, using AWS Amplify with Android Studio for social media app development offers several benefits, including:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Simplified app development: AWS Amplify provides a set of pre-built services and features that can be easily integrated into your app, reducing the need for custom coding and streamlining app development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scalability and flexibility: AWS Amplify allows for easy scaling and customization of your app as your business needs change, allowing you to add new features and services as necessary.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Security and compliance: AWS Amplify provides built-in security and compliance features that help keep your app and user data safe and secure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Real-time data: With Amplify's real-time data functionality, your social media app can provide instant updates and notifications to users, improving engagement and user experience.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cloud-powered infrastructure: AWS Amplify leverages the power of cloud infrastructure, allowing for seamless data storage, fast data processing, and reliable performance&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>Building Cloud-Powered Android Applications with AWS Amplify and Android Studio</title>
      <dc:creator>Nwokocha wisdom maduabuchi</dc:creator>
      <pubDate>Fri, 31 Mar 2023 09:49:03 +0000</pubDate>
      <link>https://dev.to/wise4rmgod/building-cloud-powered-android-applications-with-aws-amplify-and-android-studio-3lmn</link>
      <guid>https://dev.to/wise4rmgod/building-cloud-powered-android-applications-with-aws-amplify-and-android-studio-3lmn</guid>
      <description>&lt;p&gt;AWS Amplify is a popular development framework that enables developers to build scalable and secure cloud-powered applications. It simplifies the development process by providing a set of tools and services that allow developers to create high-quality mobile and web applications quickly. With AWS Amplify, developers can easily integrate cloud services into their applications, such as authentication, storage, APIs, and real-time data synchronization. &lt;/p&gt;

&lt;p&gt;In this article, we will explore how to use AWS Amplify with Android Studio, one of the most popular integrated development environments (IDEs) for Android app development. By the end of this article, you will have a good understanding of how to integrate AWS Amplify into your Android Studio project and use it to develop cloud-powered applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up Development Environment
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Downloading and installing Android Studio&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Visit the Android Studio website (&lt;a href="https://developer.android.com/studio"&gt;https://developer.android.com/studio&lt;/a&gt;) and click on the "Download Android Studio" button.&lt;/li&gt;
&lt;li&gt;Choose the appropriate version for your operating system (Windows, macOS, or Linux) and click the "Download" button.&lt;/li&gt;
&lt;li&gt;Once the download is complete, run the installer file and follow the instructions to install Android Studio on your computer.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Creating a new project:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Launch Android Studio and select "Start a new Android Studio project" from the main menu.&lt;/li&gt;
&lt;li&gt;Choose the "Phone and Tablet" option and select the type of project you want to create, such as "Empty Activity" or "Basic Activity".&lt;/li&gt;
&lt;li&gt;Set the name and package name for your project.&lt;/li&gt;
&lt;li&gt;Choose the minimum SDK version and the target SDK version.&lt;/li&gt;
&lt;li&gt;Select the language you want to use (Java or Kotlin).&lt;/li&gt;
&lt;li&gt;Choose any additional features or services you want to include in your project.&lt;/li&gt;
&lt;li&gt;Click "Finish" to create your project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Congratulations! You have successfully installed Android Studio and created a new project. &lt;br&gt;
In the next section, you will explore how to integrate AWS Amplify into your Android Studio project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integrating AWS Amplify into Android Studio Project
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open your project in Android Studio.&lt;/li&gt;
&lt;li&gt;Navigate to the "app" folder in the project explorer.&lt;/li&gt;
&lt;li&gt;Open the build.gradle file for your app module.&lt;/li&gt;
&lt;li&gt;In the dependencies section, add the following line of code to include the AWS Amplify dependency:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;implementation 'com.amplifyframework:core:1.8.1'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Click on the "Sync Now" button to sync the changes with your project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Initializing Amplify in onCreate method of MainActivity.java file:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your MainActivity.java file.&lt;/li&gt;
&lt;li&gt;Add the following import statement at the top of your file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import com.amplifyframework.core.Amplify;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;In the onCreate method of your MainActivity, add the following code to initialize AWS Amplify:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Amplify.configure(getApplicationContext());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;This line of code initializes Amplify with the application context.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Congratulations! You have successfully added the AWS Amplify dependency to your build.gradle file and initialized it in your MainActivity.java file. &lt;br&gt;
In the next section, we will explore how to create an AWS Amplify backend for your Android application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating an AWS Amplify Backend
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open a terminal or command prompt and install the Amplify CLI by running the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g @aws-amplify/cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Once the installation is complete, initialize Amplify in your project directory by running the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;amplify init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Follow the prompts to configure your Amplify backend. Choose the appropriate options for your project, such as the AWS region, authentication type, and API type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once you have configured your backend, use the Amplify CLI to create the necessary resources by running the following command:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;amplify push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;This command creates the resources specified in your Amplify configuration file, such as authentication, API, and storage resources.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Configuring and deploying the backend:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;After running the amplify push command, navigate to the Amplify console in the AWS Management Console.&lt;/li&gt;
&lt;li&gt;Click on the "Backend environments" option in the left-hand menu and select your project.&lt;/li&gt;
&lt;li&gt;Click on the "Backend environments" tab and click on the environment you want to deploy to.&lt;/li&gt;
&lt;li&gt;Click on the "Deploy changes" button to deploy your backend resources to the selected environment.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Congratulations! You have successfully created an AWS Amplify backend for your Android application using the Amplify CLI and deployed it to the selected environment. &lt;br&gt;
In the next section, we will explore how to use AWS Amplify to implement various cloud services in your Android application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using AWS Amplify in Android Studio
&lt;/h2&gt;

&lt;p&gt;*&lt;em&gt;Adding authentication to the application using Amazon Cognito:&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your Amplify configuration file (amplify/backend/amplify-meta.json).&lt;/li&gt;
&lt;li&gt;Add the following lines of code to the auth section to enable Amazon Cognito authentication:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"auth": {
  "plugins": {
    "awsCognitoAuthPlugin": {
      "userPoolId": "YOUR_USER_POOL_ID",
      "region": "YOUR_AWS_REGION",
      "userPoolWebClientId": "YOUR_USER_POOL_WEB_CLIENT_ID"
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Replace the placeholders with your Amazon Cognito user pool ID, region, and user pool web client ID.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your Android project, initialize the Amazon Cognito authentication by adding the following code in your MainActivity.java file:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Amplify.addPlugin(new AWSCognitoAuthPlugin());
Amplify.configure(getApplicationContext());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;This code initializes the Amazon Cognito authentication plugin and configures Amplify with the application context.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementing storage using Amazon S3:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your Amplify configuration file.&lt;/li&gt;
&lt;li&gt;Add the following lines of code to the storage section to enable Amazon S3 storage:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"storage": {
  "plugins": {
    "awsS3StoragePlugin": {
      "bucketName": "YOUR_BUCKET_NAME",
      "region": "YOUR_AWS_REGION"
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Replace the placeholders with your Amazon S3 bucket name and region.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your Android project, use the Amplify Storage API to upload and download files from Amazon S3. For example, to upload a file, add the following code:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;File localFile = new File(getApplicationContext().getFilesDir(), "localFileName.jpg");
Amplify.Storage.uploadFile(
        "remoteFileName.jpg",
        localFile,
        result -&amp;gt; Log.i("MyAmplifyApp", "Successfully uploaded: " + result.getKey()),
        error -&amp;gt; Log.e("MyAmplifyApp", "Upload failed", error)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using API services with Amazon API Gateway:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your Amplify configuration file.&lt;/li&gt;
&lt;li&gt;Add the following lines of code to the api section to enable Amazon API Gateway:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"api": {
  "plugins": {
    "awsAPIPlugin": {
      "endpointType": "REST",
      "endpoint": "YOUR_API_ENDPOINT",
      "region": "YOUR_AWS_REGION"
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Replace the placeholders with your Amazon API Gateway endpoint and region.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your Android project, use the Amplify API category to interact with your API resources. For example, to fetch data from a resource, add the following code:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Amplify.API.get("resourceName", "/resourcePath", null,
        response -&amp;gt; Log.i("MyAmplifyApp", response.getData().asString()),
        error -&amp;gt; Log.e("MyAmplifyApp", "Failed to get resource data", error)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Displaying real-time data with Amazon AppSync:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your Amplify configuration file.&lt;/li&gt;
&lt;li&gt;Add the following lines of code to the api section to enable Amazon AppSync:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"api": {
  "plugins": {
    "awsAPIPlugin": {
      "endpointType": "GraphQL",
      "endpoint": "YOUR_APPSYNC_API_ENDPOINT",
      "region": "YOUR_AWS_REGION"
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Replace the placeholders with your Amazon AppSync API endpoint and region.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your Android project, use the Amplify API category to subscribe to real-time data changes. For example, to listen for updates to a specific resource, add the following code:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Amplify.API
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;In summary, AWS Amplify provides developers with an easy and efficient way to build cloud-powered applications by simplifying the process of integrating and managing various AWS services. With Android Studio as the IDE, developers can easily implement Amplify and leverage its benefits to create high-performing and scalable applications.&lt;/p&gt;

&lt;p&gt;By following the steps outlined in this guide, developers can add authentication, storage, API services, and real-time data to their Android applications using Amazon Cognito, Amazon S3, Amazon API Gateway, and Amazon AppSync, respectively.&lt;/p&gt;

&lt;p&gt;Using AWS Amplify can significantly reduce the time and effort required to integrate various cloud services, allowing developers to focus more on building core features and functionality of their applications. Moreover, Amplify provides seamless scalability, robust security, and cost-effectiveness for cloud-powered application development.&lt;/p&gt;

&lt;p&gt;We encourage developers to explore and experiment with the various AWS Amplify services and features available, as it can open up new possibilities and opportunities for creating innovative and dynamic applications. With the extensive documentation and support provided by AWS, developers can easily get started with Amplify and take their applications to the next level.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Building Cloud-Powered Android Applications with AWS Amplify and Android Studio</title>
      <dc:creator>Nwokocha wisdom maduabuchi</dc:creator>
      <pubDate>Fri, 31 Mar 2023 09:40:46 +0000</pubDate>
      <link>https://dev.to/wise4rmgod/building-cloud-powered-android-applications-with-aws-amplify-and-android-studio-58hk</link>
      <guid>https://dev.to/wise4rmgod/building-cloud-powered-android-applications-with-aws-amplify-and-android-studio-58hk</guid>
      <description>&lt;p&gt;AWS Amplify Kotlin is a popular development framework that enables developers to build scalable and secure cloud-powered applications. It simplifies the development process by providing a set of tools and services that allow developers to create high-quality mobile and web applications quickly. With AWS Amplify, developers can easily integrate cloud services into their applications, such as authentication, storage, APIs, and real-time data synchronization. &lt;/p&gt;

&lt;p&gt;In this article, we will explore how to use AWS Amplify with Android Studio, one of the most popular integrated development environments (IDEs) for Android app development. By the end of this article, you will have a good understanding of how to integrate AWS Amplify into your Android Studio project and use it to develop cloud-powered applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up Development Environment
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Downloading and installing Android Studio&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Visit the Android Studio website (&lt;a href="https://developer.android.com/studio"&gt;https://developer.android.com/studio&lt;/a&gt;) and click on the "Download Android Studio" button.&lt;/li&gt;
&lt;li&gt;Choose the appropriate version for your operating system (Windows, macOS, or Linux) and click the "Download" button.&lt;/li&gt;
&lt;li&gt;Once the download is complete, run the installer file and follow the instructions to install Android Studio on your computer.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Creating a new project:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Launch Android Studio and select "Start a new Android Studio project" from the main menu.&lt;/li&gt;
&lt;li&gt;Choose the "Phone and Tablet" option and select the type of project you want to create, such as "Empty Activity" or "Basic Activity".&lt;/li&gt;
&lt;li&gt;Set the name and package name for your project.&lt;/li&gt;
&lt;li&gt;Choose the minimum SDK version and the target SDK version.&lt;/li&gt;
&lt;li&gt;Select the language you want to use (Java or Kotlin).&lt;/li&gt;
&lt;li&gt;Choose any additional features or services you want to include in your project.&lt;/li&gt;
&lt;li&gt;Click "Finish" to create your project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Congratulations! You have successfully installed Android Studio and created a new project. &lt;br&gt;
In the next section, you will explore how to integrate AWS Amplify into your Android Studio project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integrating AWS Amplify into Android Studio Project
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open your project in Android Studio.&lt;/li&gt;
&lt;li&gt;Navigate to the "app" folder in the project explorer.&lt;/li&gt;
&lt;li&gt;Open the build.gradle file for your app module.&lt;/li&gt;
&lt;li&gt;In the dependencies section, add the following line of code to include the AWS Amplify dependency:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;implementation 'com.amplifyframework:core:1.8.1'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Click on the "Sync Now" button to sync the changes with your project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Initializing Amplify in onCreate method of MainActivity.java file:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your MainActivity.java file.&lt;/li&gt;
&lt;li&gt;Add the following import statement at the top of your file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import com.amplifyframework.core.Amplify;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;In the onCreate method of your MainActivity, add the following code to initialize AWS Amplify:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Amplify.configure(getApplicationContext());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;This line of code initializes Amplify with the application context.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Congratulations! You have successfully added the AWS Amplify dependency to your build.gradle file and initialized it in your MainActivity.java file. &lt;br&gt;
In the next section, we will explore how to create an AWS Amplify backend for your Android application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating an AWS Amplify Backend
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open a terminal or command prompt and install the Amplify CLI by running the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g @aws-amplify/cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Once the installation is complete, initialize Amplify in your project directory by running the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;amplify init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Follow the prompts to configure your Amplify backend. Choose the appropriate options for your project, such as the AWS region, authentication type, and API type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once you have configured your backend, use the Amplify CLI to create the necessary resources by running the following command:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;amplify push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;This command creates the resources specified in your Amplify configuration file, such as authentication, API, and storage resources.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Configuring and deploying the backend:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;After running the amplify push command, navigate to the Amplify console in the AWS Management Console.&lt;/li&gt;
&lt;li&gt;Click on the "Backend environments" option in the left-hand menu and select your project.&lt;/li&gt;
&lt;li&gt;Click on the "Backend environments" tab and click on the environment you want to deploy to.&lt;/li&gt;
&lt;li&gt;Click on the "Deploy changes" button to deploy your backend resources to the selected environment.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Congratulations! You have successfully created an AWS Amplify backend for your Android application using the Amplify CLI and deployed it to the selected environment. &lt;br&gt;
In the next section, we will explore how to use AWS Amplify to implement various cloud services in your Android application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using AWS Amplify in Android Studio
&lt;/h2&gt;

&lt;p&gt;*&lt;em&gt;Adding authentication to the application using Amazon Cognito:&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your Amplify configuration file (amplify/backend/amplify-meta.json).&lt;/li&gt;
&lt;li&gt;Add the following lines of code to the auth section to enable Amazon Cognito authentication:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"auth": {
  "plugins": {
    "awsCognitoAuthPlugin": {
      "userPoolId": "YOUR_USER_POOL_ID",
      "region": "YOUR_AWS_REGION",
      "userPoolWebClientId": "YOUR_USER_POOL_WEB_CLIENT_ID"
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Replace the placeholders with your Amazon Cognito user pool ID, region, and user pool web client ID.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your Android project, initialize the Amazon Cognito authentication by adding the following code in your MainActivity.java file:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Amplify.addPlugin(new AWSCognitoAuthPlugin());
Amplify.configure(getApplicationContext());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;This code initializes the Amazon Cognito authentication plugin and configures Amplify with the application context.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Implementing storage using Amazon S3:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your Amplify configuration file.&lt;/li&gt;
&lt;li&gt;Add the following lines of code to the storage section to enable Amazon S3 storage:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"storage": {
  "plugins": {
    "awsS3StoragePlugin": {
      "bucketName": "YOUR_BUCKET_NAME",
      "region": "YOUR_AWS_REGION"
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Replace the placeholders with your Amazon S3 bucket name and region.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your Android project, use the Amplify Storage API to upload and download files from Amazon S3. For example, to upload a file, add the following code:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;File localFile = new File(getApplicationContext().getFilesDir(), "localFileName.jpg");
Amplify.Storage.uploadFile(
        "remoteFileName.jpg",
        localFile,
        result -&amp;gt; Log.i("MyAmplifyApp", "Successfully uploaded: " + result.getKey()),
        error -&amp;gt; Log.e("MyAmplifyApp", "Upload failed", error)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using API services with Amazon API Gateway:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your Amplify configuration file.&lt;/li&gt;
&lt;li&gt;Add the following lines of code to the api section to enable Amazon API Gateway:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"api": {
  "plugins": {
    "awsAPIPlugin": {
      "endpointType": "REST",
      "endpoint": "YOUR_API_ENDPOINT",
      "region": "YOUR_AWS_REGION"
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Replace the placeholders with your Amazon API Gateway endpoint and region.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your Android project, use the Amplify API category to interact with your API resources. For example, to fetch data from a resource, add the following code:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Amplify.API.get("resourceName", "/resourcePath", null,
        response -&amp;gt; Log.i("MyAmplifyApp", response.getData().asString()),
        error -&amp;gt; Log.e("MyAmplifyApp", "Failed to get resource data", error)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Displaying real-time data with Amazon AppSync:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your Amplify configuration file.&lt;/li&gt;
&lt;li&gt;Add the following lines of code to the api section to enable Amazon AppSync:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"api": {
  "plugins": {
    "awsAPIPlugin": {
      "endpointType": "GraphQL",
      "endpoint": "YOUR_APPSYNC_API_ENDPOINT",
      "region": "YOUR_AWS_REGION"
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Replace the placeholders with your Amazon AppSync API endpoint and region.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your Android project, use the Amplify API category to subscribe to real-time data changes. For example, to listen for updates to a specific resource, add the following code:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Amplify.API
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;In summary, AWS Amplify provides developers with an easy and efficient way to build cloud-powered applications by simplifying the process of integrating and managing various AWS services. With Android Studio as the IDE, developers can easily implement Amplify and leverage its benefits to create high-performing and scalable applications.&lt;/p&gt;

&lt;p&gt;By following the steps outlined in this guide, developers can add authentication, storage, API services, and real-time data to their Android applications using Amazon Cognito, Amazon S3, Amazon API Gateway, and Amazon AppSync, respectively.&lt;/p&gt;

&lt;p&gt;Using AWS Amplify can significantly reduce the time and effort required to integrate various cloud services, allowing developers to focus more on building core features and functionality of their applications. Moreover, Amplify provides seamless scalability, robust security, and cost-effectiveness for cloud-powered application development.&lt;/p&gt;

&lt;p&gt;We encourage developers to explore and experiment with the various AWS Amplify services and features available, as it can open up new possibilities and opportunities for creating innovative and dynamic applications. With the extensive documentation and support provided by AWS, developers can easily get started with Amplify and take their applications to the next level.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The beauty of Retrofit 2.6.0 with Coroutines support</title>
      <dc:creator>Nwokocha wisdom maduabuchi</dc:creator>
      <pubDate>Thu, 09 Apr 2020 18:53:39 +0000</pubDate>
      <link>https://dev.to/wise4rmgod/the-beauty-of-retrofit-2-6-0-with-coroutines-support-3ddm</link>
      <guid>https://dev.to/wise4rmgod/the-beauty-of-retrofit-2-6-0-with-coroutines-support-3ddm</guid>
      <description>&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fn4hng7j8che0gc00o0dh.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fn4hng7j8che0gc00o0dh.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Hello Dev, &lt;br&gt;
I will be teaching you how to build a simple project using Retrofit 2.6.0 with its inbuilt support for Coroutines, this will help you to achieve better performance and reduces boilerplate codes significantly. 😍😍😍😍🥰🔥🔥&lt;/p&gt;
&lt;h3&gt;
  
  
  Note:
&lt;/h3&gt;

&lt;p&gt;This tutorial assumes that you are familiar with the basics of the Retrofit library. If you are completely new to Retrofit, I advise you to read through &lt;a href="http://www.kotlincodes.com/kotlin/retrofit-with-kotlin/" rel="noopener noreferrer"&gt;http://www.kotlincodes.com/kotlin/retrofit-with-kotlin/&lt;/a&gt; first.&lt;/p&gt;
&lt;h3&gt;
  
  
  New:
&lt;/h3&gt;

&lt;p&gt;Retrofit 2.6. 0 has been released with support for suspend functions. This allows you to express the asynchrony of HTTP requests in an idiomatic fashion for the Kotlin language.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nd"&gt;@GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"users/{id}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;suspend&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;@Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Long&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Behind the scenes this behaves as if defined as fun user(...): Call and then invoked with Call.enqueue. You can also return Response for access to the response metadata.&lt;br&gt;
follow up threads on the Retrofit release: &lt;a href="https://github.com/square/retrofit/blob/master/CHANGELOG.md" rel="noopener noreferrer"&gt;https://github.com/square/retrofit/blob/master/CHANGELOG.md&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What is the purpose of this article&lt;br&gt;
1: learn how to build clean, readable and maintainable code&lt;br&gt;
2: learn how to work with retrofit 2.6.0&lt;br&gt;
3: learn how to work with MVVM architecture&lt;br&gt;
4: learn how to work with a repository pattern &lt;/p&gt;

&lt;p&gt;In this article I will be using an app I built for learning purposes called  " Wammy ", the application is written in Kotlin and it uses MVVM, implemented repository, view model, live data and real-time internet connectivity check. &lt;/p&gt;

&lt;p&gt;Alright lets 👀👀👀&lt;/p&gt;

&lt;p&gt;First steps we are to add the necessary Dependencies&lt;/p&gt;

&lt;p&gt;Build.gradle(module: app)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;
&lt;span class="nf"&gt;dependencies&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;lifecycle_version&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"2.3.0-alpha01"&lt;/span&gt;
    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;arch_version&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"2.1.0"&lt;/span&gt;
    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;activity_version&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"1.2.0-alpha02"&lt;/span&gt;

    &lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;squareup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;retrofit2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;converter-gson&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mf"&gt;2.6.0&lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt;
    &lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;squareup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;retrofit2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;retrofit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mf"&gt;2.6.0&lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt;
    &lt;span class="n"&gt;kapt&lt;/span&gt; &lt;span class="s"&gt;"androidx.lifecycle:lifecycle-compiler:$lifecycle_version"&lt;/span&gt;
    &lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wise4rmgod&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nc"&gt;AdnetwrokManager&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mf"&gt;0.1.0&lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt;
    &lt;span class="c1"&gt;// Kotlin&lt;/span&gt;
    &lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="s"&gt;"androidx.activity:activity-ktx:$activity_version"&lt;/span&gt;
    &lt;span class="c1"&gt;// Lifecycles only (without ViewModel or LiveData)&lt;/span&gt;
    &lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="s"&gt;"androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"&lt;/span&gt;
    &lt;span class="c1"&gt;// ViewModel&lt;/span&gt;
    &lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="n"&gt;androidx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lifecycle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;lifecycle-viewmodel-ktx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mf"&gt;2.3.0&lt;/span&gt;&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="n"&gt;alpha01&lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt;
    &lt;span class="c1"&gt;// LiveData&lt;/span&gt;
    &lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="s"&gt;"androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"&lt;/span&gt;
    &lt;span class="c1"&gt;// Coroutines&lt;/span&gt;
    &lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="s"&gt;"org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2"&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second step is to know the API Endpoint to work with, in this example we will work :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nc"&gt;GET&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//jsonplaceholder.typicode.com/posts&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the Endpoint will return&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s"&gt;"userId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"sunt aut facere repellat provident occaecati excepturi optio reprehenderit"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;"body"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"&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;/div&gt;



&lt;p&gt;The third step is to create a Retrofit interface. in this example, it will be&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;
&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;Webservice&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;@GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/posts"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;suspend&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;getTodo&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nc"&gt;Todou&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that let's implement the Retrofit builder that will return our webservice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;RetrofitClient&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;companion&lt;/span&gt; &lt;span class="k"&gt;object&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;retrofit&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Retrofit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Builder&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;baseUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Constant&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;BASE_URL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addConverterFactory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;GsonConverterFactory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;GsonBuilder&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Webservice&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;java&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;/div&gt;



&lt;p&gt;The next step is to create the Repository class which creates the instance of the retrofit service and initiates the API call, our method for this call should be a suspend function as it will later be called through a coroutine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TodoRepository&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;client&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Webservice&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;RetrofitClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;retrofit&lt;/span&gt;

    &lt;span class="k"&gt;suspend&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;getTodo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getTodo&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;/div&gt;



&lt;p&gt;Now that our repository is set up we can create a method in the ViewModel which uses the liveData builder to create a process on the IO thread.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TodoViewmodel&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ViewModel&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;repository&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;TodoRepository&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TodoRepository&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;firstTodo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;LiveData&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Todou&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;liveData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Dispatchers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IO&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;retrivedTodo&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getTodo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nf"&gt;emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;retrivedTodo&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;/div&gt;



&lt;p&gt;The emit function emits the changes in the underlying database to the observer variables, in our case which will be located in the MainActivity.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;viewModel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;TodoViewmodel&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="nf"&gt;viewModels&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;lateinit&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;binding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ActivityMainBinding&lt;/span&gt;
    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onCreate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;savedInstanceState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Bundle&lt;/span&gt;&lt;span class="p"&gt;?)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;onCreate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;savedInstanceState&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;binding&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ActivityMainBinding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;inflate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;layoutInflater&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;setContentView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="nf"&gt;gotonextativity&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nf"&gt;checknetworkstatus&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;checknetworkstatus&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;CheckNetworkStatus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getNetworkLiveData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;applicationContext&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Observer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt;
            &lt;span class="k"&gt;when&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;true&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="nf"&gt;showdummy&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
                &lt;span class="k"&gt;false&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="nc"&gt;Toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;makeText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"No Network Connection"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;LENGTH_SHORT&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
                &lt;span class="k"&gt;null&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="c1"&gt;// TODO: Handle the connection...&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;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;showdummy&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;viewModel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;firstTodo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Observer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt;
            &lt;span class="n"&gt;binding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;recyclerView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;adapter&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;
                &lt;span class="nc"&gt;DummyAdapter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;applicationContext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;binding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;recyclerView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;adapter&lt;/span&gt;&lt;span class="o"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;notifyDataSetChanged&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;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we can see the observer observing the value of t from the API and updating the UI accordingly.&lt;/p&gt;

&lt;p&gt;Hurray!!! your code is cleaner, readable and leverages the coroutine support.&lt;br&gt;
Thanks for your time 🥰🔥🔥&lt;br&gt;
follow me on Twitter: &lt;a href="https://twitter.com/Joklinztech" rel="noopener noreferrer"&gt;https://twitter.com/Joklinztech&lt;/a&gt;&lt;br&gt;
full project Github: &lt;a href="https://github.com/wise4rmgod/Wammy" rel="noopener noreferrer"&gt;https://github.com/wise4rmgod/Wammy&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Build small-sized apps using ProGuard</title>
      <dc:creator>Nwokocha wisdom maduabuchi</dc:creator>
      <pubDate>Sat, 04 Apr 2020 19:39:52 +0000</pubDate>
      <link>https://dev.to/wise4rmgod/build-small-sized-apps-using-proguard-11k2</link>
      <guid>https://dev.to/wise4rmgod/build-small-sized-apps-using-proguard-11k2</guid>
      <description>&lt;p&gt;It's important to enable proguard in our project, so if a question arises in the form "should all android apps enable proguard?" I will say yes.&lt;br&gt;
Because you will build a small-sized app, unused code removed and all identifiers changed to protect from decompiling apk.&lt;/p&gt;
&lt;h3&gt;
  
  
  What is ProGuard
&lt;/h3&gt;

&lt;p&gt;ProGuard is a tool that shrinks, optimizes and obfuscates code, it is readily available as part of the Android Gradle build process and ships with the SDK.&lt;/p&gt;
&lt;h3&gt;
  
  
  Why Proguard
&lt;/h3&gt;

&lt;p&gt;1: it gets rid of unused code&lt;br&gt;
2: it renames identifiers to make the code smaller,&lt;br&gt;
3: it performs the whole program optimizations.&lt;/p&gt;
&lt;h3&gt;
  
  
  Note:
&lt;/h3&gt;

&lt;p&gt;However, when you create a new project using Android Studio, shrinking, obfuscation, and code optimization is not enabled by default. That’s because these compile-time optimizations increase the build time of your project and might introduce bugs if you do not sufficiently&lt;br&gt;
So, it’s best to enable these compile-time tasks when building the final version of your app that you test prior to publishing. To enable shrinking, obfuscation, and optimization, you will include the following in your project-level build.gradle file.&lt;/p&gt;

&lt;p&gt;How to Setup Proguard&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
android {
    buildTypes {
        release {
            // Enables code shrinking, obfuscation, and optimization for only
            // your project's release build type.
            minifyEnabled true

            // Enables resource shrinking, which is performed by the
            // Android Gradle plugin.
            shrinkResources true

            // Includes the default ProGuard rules files that are packaged with
            // the Android Gradle plugin. To learn more, go to the section about
            // R8 configuration files.
            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'
        }
    }
    ...
}


&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Conclusion: &lt;br&gt;
When you use ProGuard you should always QA your release builds thoroughly, either by having end-to-end tests or manually going through all screens in your app to see if anything is missing or crashing.&lt;br&gt;
also, some Libraries include Proguard/R8 guide to help protect some of the classes created to avoid missing classes example Retrofit&lt;/p&gt;

</description>
    </item>
    <item>
      <title>UI Testing with Espresso in Android Studio</title>
      <dc:creator>Nwokocha wisdom maduabuchi</dc:creator>
      <pubDate>Thu, 19 Mar 2020 10:27:37 +0000</pubDate>
      <link>https://dev.to/wise4rmgod/ui-testing-with-espresso-in-android-studio-1f7a</link>
      <guid>https://dev.to/wise4rmgod/ui-testing-with-espresso-in-android-studio-1f7a</guid>
      <description>&lt;p&gt;User interface (UI) testing lets you ensure that your app meets its functional requirements and achieves a high standard of quality such that it is more likely to be successfully adopted by users. &lt;/p&gt;

&lt;p&gt;The Espresso testing framework, provided by AndroidX Test, provides APIs for writing UI tests to simulate user interactions within a single target app. Espresso tests can run on devices running Android 2.3.3 (API level 10) and higher, also The Espresso testing framework is an instrumentation-based API and works with the AndroidJUnitRunner test runner.&lt;br&gt;
UI testing using Espresso Test Recorder is very good because it will take the pain of writing the test manually.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;em&gt;BENEFITS OF ESPRESSO&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;1) Saves time writing UI test&lt;/p&gt;

&lt;p&gt;2) it's not error-prone &lt;/p&gt;

&lt;p&gt;3) it automates the test&lt;/p&gt;

&lt;p&gt;4) it's maintained by the Android team&lt;/p&gt;

&lt;p&gt;5) it's not tedious&lt;/p&gt;

&lt;p&gt;6) it's easy to use&lt;/p&gt;

&lt;p&gt;7) write concise, beautiful, and reliable Android UI tests&lt;/p&gt;
&lt;h3&gt;
  
  
  API components
&lt;/h3&gt;

&lt;p&gt;The main components of the Espresso include the following:&lt;/p&gt;
&lt;h2&gt;
  
  
  Espresso
&lt;/h2&gt;

&lt;p&gt;Entry point to interactions with views (via onView() and onData()). It also exposes APIs that are not necessarily tied to any view, such as pressBack().&lt;/p&gt;
&lt;h2&gt;
  
  
  ViewMatchers
&lt;/h2&gt;

&lt;p&gt;A collection of objects that implement the Matcher&amp;lt;? super View&amp;gt; interface. You can pass one or more of these to the onView() method to locate a view within the current view hierarchy.&lt;/p&gt;
&lt;h2&gt;
  
  
  ViewActions
&lt;/h2&gt;

&lt;p&gt;A collection of ViewAction objects that can be passed to the ViewInteraction.perform() method, such as click().&lt;/p&gt;
&lt;h2&gt;
  
  
  ViewAssertions
&lt;/h2&gt;

&lt;p&gt;A collection of ViewAssertion objects that can be passed the ViewInteraction.check() method. Most of the time, you will use the matches assertion, which uses a View matcher to assert the state of the currently selected view.&lt;/p&gt;

&lt;p&gt;NOTE: An assertion: is the core of your test. It's a code statement that checks that your code or app behaved as expected. &lt;/p&gt;
&lt;h3&gt;
  
  
  HOW IT WORKS
&lt;/h3&gt;

&lt;p&gt;Set up Espresso&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dependencies {
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the video, I explained how to write a simple UI test using an espresso test recorder in an Android studio.&lt;/p&gt;

&lt;p&gt;Video: &lt;a href="https://youtu.be/22MZXJFMq98"&gt;https://youtu.be/22MZXJFMq98&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more info: &lt;a href="https://developer.android.com/training/testing/espresso"&gt;https://developer.android.com/training/testing/espresso&lt;/a&gt; &lt;br&gt;
and &lt;a href="https://developer.android.com/training/testing/espresso/basics"&gt;https://developer.android.com/training/testing/espresso/basics&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to add the DayNight Theme to an Android app using Kotlin</title>
      <dc:creator>Nwokocha wisdom maduabuchi</dc:creator>
      <pubDate>Tue, 10 Mar 2020 19:17:30 +0000</pubDate>
      <link>https://dev.to/wise4rmgod/how-to-add-the-daynight-theme-to-an-android-app-250m</link>
      <guid>https://dev.to/wise4rmgod/how-to-add-the-daynight-theme-to-an-android-app-250m</guid>
      <description>&lt;p&gt;The DayNight functionality in AppCompat allows your app to easily switch between a dark ⚫ and light ⚪ theme.&lt;br&gt;
Also, the DayNight theme gives an app the cool capability of switching color schemes based on the time of day and the device's last known location.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;em&gt;Benefits of DayNight Theme&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;1: Saves battery life &lt;br&gt;
2: reduce the risk of damaging the eyes&lt;br&gt;
3: easily accessible at night &lt;br&gt;
4: increasing usability for people with reduced-vision&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;em&gt;Learn to use Androidx DayNight Theme&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;Step 1 ) Update styles.xml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar"&amp;gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The themes you can extend from to add day night theme switching capability are the following:&lt;/p&gt;

&lt;p&gt;"Theme.AppCompat.DayNight"&lt;br&gt;
"Theme.AppCompat.DayNight.NoActionBar"&lt;br&gt;
"Theme.AppCompat.DayNight.DarkActionBar"&lt;/p&gt;

&lt;p&gt;Step 2 ) Update MainActivity code&lt;/p&gt;

&lt;p&gt;To switch the theme, call the AppCompatDelegate.setDefaultNightMode(int) method from your Kotlin code. (This will change the color scheme for the whole app, not just any one activity or fragment.) For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;em&gt;Note:&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;AppCompatDelegate.MODE_NIGHT_NO: &lt;br&gt;
this sets the default theme for your app and takes the colors defined in the res/values directory. It is recommended to use light colors for this theme.&lt;/p&gt;

&lt;p&gt;AppCompatDelegate.MODE_NIGHT_YES: &lt;br&gt;
this sets a night theme for your app and takes the colors defined in the res/values-night directory. It is recommended to use dark colors for this theme.&lt;/p&gt;

&lt;p&gt;AppCompatDelegate.MODE_NIGHT_AUTO: &lt;br&gt;
this auto switches the colors of the app based on the time of the day and the colors you have defined in values and values-night directories.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;em&gt;Note:&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;however, that the theme switch will not persist if you kill the app and reopen it. If you do that, the theme will switch back to AppCompatDelegate.MODE_NIGHT_AUTO, which is the default value. If you want the theme switch to persist, make sure you store the value in shared preferences and load the stored value each time the app is opened after it has been destroyed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/wise4rmgod/DayNightTheme_Example"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding Memory Leaks in Android Developments.</title>
      <dc:creator>Nwokocha wisdom maduabuchi</dc:creator>
      <pubDate>Mon, 09 Mar 2020 18:15:25 +0000</pubDate>
      <link>https://dev.to/wise4rmgod/understanding-memory-leaks-in-android-developments-1dne</link>
      <guid>https://dev.to/wise4rmgod/understanding-memory-leaks-in-android-developments-1dne</guid>
      <description>&lt;p&gt;Imagine living in an apartment with your little waste bin outside, a bit close to the sitting room window. But every time the garbage truck/collectors come around, they skip emptying your waste bin. With each passing day your waste bin gets fuller and more smelly, the pungent smell may discourage you from laying on the sitting room couch. Then one day you decide to do something about your waste, you move your waste bin further to where it could be seen and picked up easily. Finally, your waste gets disposed and you can once again breathe a breath of fresh air.&lt;/p&gt;

&lt;p&gt;This is exactly how a memory leak on an android app works. A memory leak occurs due to flimsy mistakes made while coding. And if an app has a memory leakage, the garbage collector can’t clear the heaps. Thereby causing the app to consume more memory which often leads to you receiving an error message stating; “ OutOfMemoryError”.&lt;/p&gt;

&lt;p&gt;What is a Memory leak?&lt;/p&gt;

&lt;p&gt;A memory leak is a programming error that causes an application to keep a reference to an object that is no longer needed. As a result, the memory allocated for that object cannot be reclaimed, eventually leading to an OutOfMemoryError crash.&lt;/p&gt;

&lt;p&gt;One of the core benefits of Java is automated memory management with the help of the built-in Garbage Collector (or GC for short). Now you might want to ask what is a Garbage Collector and its function.&lt;/p&gt;

&lt;p&gt;What Is A Garbage Collector?&lt;/p&gt;

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

&lt;p&gt;The garbage collector is a program which runs on the Java Virtual Machinewhich gets rid of objects which are not being used by a Java application anymore. It is a form of automatic memory management.&lt;/p&gt;

&lt;p&gt;The garbage collector will look for objects which aren’t being used anymore and gets rid of them, freeing up the memory so other new objects can use that piece of memory.&lt;/p&gt;

&lt;p&gt;In Java, memory management is taken care of by the garbage collector, but in other languages such as C, one needs to perform memory management on their own using functions such as malloc and free. Memory management is one of those things which are easy to make mistakes, which can lead to what is called memory leaks — places where memory is not reclaimed when they are not in use anymore.&lt;/p&gt;

&lt;p&gt;Automatic memory management schemes like garbage collection make it so the programmer does not have to worry so much about memory management issues, so he or she can focus more on developing the applications they need to develop.&lt;/p&gt;

&lt;h3&gt;
  
  
  So what are some of the common mistakes that lead to memory leaks?
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Broadcast Receivers:
Consider this scenario — you need to register a local broadcast receiver in your activity. If you don’t unregister the broadcast receiver, then it still holds a reference to the activity, even if you close the activity.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;How to solve this? Always remember to call unregister receiver in onStop() of the activity.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Static Activity or View Reference:
You are declaring a TextView as static (for whatever reason). If you reference activity or view directly or indirectly from a static reference, the activity would not be garbage collected after it is destroyed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;How to solve this? Always remember to NEVER use static variables for views or activities or contexts.&lt;/p&gt;

&lt;p&gt;NOTE:&lt;br&gt;
Always stop what you started in a program.&lt;/p&gt;

&lt;p&gt;How to find a memory leak in our project.&lt;/p&gt;

&lt;p&gt;1: Android profiler in android studio&lt;br&gt;
2: LeakyCanary android library.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Unit Testing using Robolectric in Android Studio</title>
      <dc:creator>Nwokocha wisdom maduabuchi</dc:creator>
      <pubDate>Sun, 05 Jan 2020 17:17:13 +0000</pubDate>
      <link>https://dev.to/wise4rmgod/unit-testing-using-robolectric-in-android-studio-2ibl</link>
      <guid>https://dev.to/wise4rmgod/unit-testing-using-robolectric-in-android-studio-2ibl</guid>
      <description>&lt;p&gt;Unit testing is important because it is one of the earliest testing efforts performed on the code and the earlier defects are detected, the easier they are to fix. Early bug-detection is also the most cost-effective for a project, with code fixes becoming more expensive the later they're found in the lifecycle.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  &lt;strong&gt;What is Unit Testing&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;UNIT TESTING is a level of software testing where individual units/ components of the software are tested. The purpose is to validate that each unit of the software performs as designed. A unit is the smallest testable part of any software. It usually has one or a few inputs and usually a single output.&lt;/p&gt;

&lt;p&gt;Furthermore, Unit tests are the fundamental tests in your app testing strategy. By creating and running unit tests against your code, you can easily verify that the logic of individual units is correct. Running unit tests after every build help you to quickly catch and fix software regressions introduced by code changes to your app.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Two types of automated unit testing in android&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Local tests:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Unit tests run on your local machine only. These tests are compiled to run locally on the Java Virtual Machine (JVM) to minimize execution time. If your tests depend on objects in the Android framework, we recommend using Robolectric. For tests that depend on your own dependencies, use mock objects to emulate your dependencies' behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Instrumented tests:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Unit tests run on an Android device or emulator. These tests have access to instrumentation information, such as the Context for the app under test. Use this approach to run unit tests that have complex Android dependencies that require a more robust environment, such as Robolectric.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Benefits of Unit Testing&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The goal of unit testing is to segregate each part of the program and test that the individual parts are working correctly. It isolates the smallest piece of testable software from the remainder of the code and determines whether it behaves exactly as you expect. &lt;/p&gt;

&lt;p&gt;Unit testing provides numerous benefits including finding software bugs early, facilitating change, simplifying integration, and many others, which we will look right now with more detail. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Quality of Code&lt;/strong&gt;&lt;br&gt;
Unit testing improves the quality of the code. It identifies every defect that may have come up before code is sent further for integration testing. Writing tests before actual coding makes you think harder about the problem. It exposes the edge cases and makes you write better code. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Finds Software Bugs Early&lt;/strong&gt;&lt;br&gt;
Issues are found at an early stage. Since unit testing is carried out by developers who test individual code before integration, issues can be found very early and can be resolved then and there without impacting the other pieces of the code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Facilitates Changes and Simplifies Integration&lt;/strong&gt;&lt;br&gt;
Unit testing reduces defects in the newly developed features or reduces bugs when changing the existing functionality. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Debugging Process&lt;/strong&gt;&lt;br&gt;
Unit testing helps simplify the debugging process. If a test fails, then only the latest changes made in the code need to be debugged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Design&lt;/strong&gt;&lt;br&gt;
Writing the test first forces you to think through your design and what it must accomplish before you write the code. This not only keeps you focused; it makes you create better designs. Testing a piece of code forces you to define what that code is responsible for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Reduce Costs&lt;/strong&gt;&lt;br&gt;
Since the bugs are found early, unit testing helps reduce the cost of bug fixes. Just imagine the cost of a bug found during the later stages of development, like during system testing or during acceptance testing. Of course, bugs detected earlier are easier to fix because bugs detected later are usually the result of many changes, and you don’t really know which one caused the bug.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Running unit test with Robolectric&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Robolectric, it is a unit testing framework that allows Android applications to be tested on the JVM without an emulator&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reason to write unit test with Robolectric&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1 It provides a way to run our tests inside Android Studio, without launching an app on Device or Emulator.&lt;/p&gt;

&lt;p&gt;2 Shadow Classes, rewritten android core libraries by Robolectric, are the real magic of Robolectric. It is a replica of the Android class with some exposed useful functions. Cool, isn’t it?&lt;/p&gt;

&lt;p&gt;3 You can test on Android components like:&lt;/p&gt;

&lt;p&gt;Activity&lt;/p&gt;

&lt;p&gt;Services&lt;/p&gt;

&lt;p&gt;Broadcast Receiver&lt;/p&gt;

&lt;p&gt;On app resources like:&lt;/p&gt;

&lt;p&gt;Localization from strings.xml&lt;/p&gt;

&lt;p&gt;Configuration like Landscape or Portrait&lt;/p&gt;

&lt;p&gt;Styles and themes&lt;/p&gt;

&lt;p&gt;And also for:&lt;br&gt;
Multiple product flavors&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to integrate Robolectric in Android Studio?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Add following dependencies in Gradle:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;testOptions {
        unitTests {
            includeAndroidResources = true
        }
    }

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.2.0'
    testCompile 'junit:junit:4.12'
    testCompile 'org.robolectric:robolectric:3.2.2'
}



&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, let add UI Button and TextView into our app’s main screen. Following illustrates how our XML codes look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ui.last_step.LastStepActivity"&amp;gt;


 &amp;lt;Button
            android:id="@+id/laststepfinishbtn"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:background="@drawable/roundedgeeditext"
            android:text="Finish"
            android:textColor="@color/white" /&amp;gt;

&amp;lt;/android.support.constraint.ConstraintLayout&amp;gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The MainActivity class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


laststepfinishbtn.setOnClickListener {
            val intent =
                Intent(applicationContext, HomeActivity::class.java)

            startActivity(intent)
        }

    }


}


&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;we have to create tests:&lt;br&gt;
There are 3 folders in-app folder &amp;gt; src directory named&lt;br&gt;
androidTest&lt;br&gt;
main&lt;br&gt;
test&lt;br&gt;
We will add all our tests at test &amp;gt; java &amp;gt; [Your Package Name]. It’s standard practice to keep the same project structure of both the main and test folders. It will easy for us to track. Now create MainActivityTest class like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
@RunWith(RobolectricTestRunner::class)
@Config(manifest = Config.NONE)
class MainActivityTest {
    @Test
    fun taketosigninactivity() {
        val activity = Robolectric.setupActivity(LastStepActivity::class.java)
        activity.laststepfinishbtn.performClick()
        val intent = Shadows.shadowOf(activity).peekNextStartedActivity()
        Assert.assertEquals(
            HomeActivity::class.java.canonicalName,
            intent.component!!.className
        )

    }
}



&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Terms and there meaning:&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;*assertTrue:&lt;br&gt;
you are asserting that the expression is true. If it is not, then it will display the message and the assertion will fail.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;assertTrue("TextView contains incorrect text",
            "Hello world!".equals(tvHelloWorld.getText().toString()));

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;*assertFalse:&lt;br&gt;
 you are asserting that an expression evaluates to false. If it is not, then the message is displayed and the assertion fails.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;assertFalse("TextView contains incorrect text",
            "Hello world!".equals(tvHelloWorld.getText().toString()));

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;*assertNotnull: &lt;br&gt;
you are asserting that the expression is not empty. If it is not, then it will display the message and the assertion will fail.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; assertNotNull("TextView is null", textView);

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;*shadows:&lt;br&gt;
Shadows are classes that modify or extend the behavior of classes in the Android SDK. Most of the Android core views are built with shadow classes to avoid needing the device or an emulator to run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; val intent = Shadows.shadowOf(activity).peekNextStartedActivity()
        Assert.assertEquals(
            HomeActivity::class.java.canonicalName,
            intent.component!!.className
        )

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Useful Link for Asserts methods&lt;/p&gt;

&lt;p&gt;&lt;a href="https://junit.org/junit4/javadoc/4.12/org/junit/Assert.html"&gt;all Assert method&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations you have written your first unit test using Robolectric Android library&lt;/p&gt;

</description>
      <category>android</category>
      <category>kotlin</category>
      <category>testing</category>
    </item>
    <item>
      <title>9 Reasons to Use Kotlin Over Java for Android Development</title>
      <dc:creator>Nwokocha wisdom maduabuchi</dc:creator>
      <pubDate>Thu, 26 Dec 2019 22:51:29 +0000</pubDate>
      <link>https://dev.to/wise4rmgod/9-reasons-to-use-kotlin-over-java-for-android-development-8dp</link>
      <guid>https://dev.to/wise4rmgod/9-reasons-to-use-kotlin-over-java-for-android-development-8dp</guid>
      <description>&lt;p&gt;It's a big decision to make by moving from Java to Kotlin as your go-to language for your Android-based projects.&lt;/p&gt;

&lt;p&gt;The biggest question now is " Why would you even consider trying Kotlin in your future mobile app projects? "&lt;/p&gt;

&lt;p&gt;Here are the nine strongest reasons why, as an Android developer, you should start using a kotlin programming language to build your next Android project:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;1: Kotlin the future of Android development&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Kotlin is all set for a bright future in the Android app development eco-system. The lower cost of development and maintenance of Kotlin projects is a big plus for any business. It has a plethora of great language features and offers brevity that ensures higher quality with faster turn-around time.&lt;br&gt;
Kotlin is the number one language to build an Android native app.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;2:  It's Completely Interoperable With Java&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Kotlin is 100% interoperable with java means whenever two java and kotlin files exist together they can share data with each other.&lt;/p&gt;

&lt;p&gt;While designing interoperability in kotlin, JetBrains makes major emphasis on Kotlin’s interaction with the existing Java code. The team makes sure that kotlin can easily and completely interact with the existing Java code. So that it can become easy for Java developers to migrate their Java project to Kotlin. There is also an automatic java-to-Kotlin converter in major IDEs for simplifies migration from Java to Kotlin.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;3: It's More Concise Than Java&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;It means fewer opportunities for errors. Adopting Kotlin does not cost anything. Kotlin is compatible with all Java libraries and frameworks, the JVM (Java Virtual Machine) and can be integrated with Gradle or Maven build systems.&lt;br&gt;
Yes, Kotlin makes programming easier and Android apps better. Kotlin is a modern programming language. It was created by JetBrains - a company that built the best Java IDE ever. They created Kotlin to address the weaknesses of existing languages.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;4: It Has Null in Its Type System&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Nullability issues have been one of Java's well-known sore points. Since it's a common thing in Android for the absence of certain values to be represented as “null,” Kotlin comes to address these issues by placing null right in its type system.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;5: Kotlin has a strong community&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;JetBrains is constantly improving the language. It's committed to the project, has a large and highly competent team working on it, has a stable business model and is even converting parts of their own flagship product to use it.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;6: its easier to write than Java&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you want to facilitate the product maintenance or streamline custom Android app development, you can assign two or three engineers to move the project to Kotlin starting from a small part of the codebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;7: jetpack compose is built upon kotlin&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Jetpack Compose simplifies and accelerates UI development on Android. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs.&lt;br&gt;
it's 100% Kotlin.&lt;/p&gt;

</description>
      <category>android</category>
      <category>kotlin</category>
      <category>java</category>
    </item>
  </channel>
</rss>
