Skip to content

JPrendy/github-simple-retrofit-kotlin-application

Repository files navigation

Github simple retrofit kotlin application

Description

A Kotlin Application that uses Guthub public API to show a list of repos name. It uses Retrofit and MockWebServer to mock apis.

Contents

Setup Steps

Go to the app module build.gradle and add the following dependencies

implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.8.1'
implementation 'com.squareup.retrofit2:converter-gson:2.8.1'
implementation 'com.squareup.retrofit2:converter-moshi:2.4.0'
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "com.squareup.okhttp3:okhttp:4.4.0"
androidTestImplementation "com.squareup.okhttp3:mockwebserver:4.4.0"
androidTestImplementation 'com.jakewharton.espresso:okhttp3-idling-resource:1.0.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'

Go to the AndroidManifest.xml and allow internet permission

<uses-permission android:name="android.permission.INTERNET"/>

In the AndroidManifest.xml, make sure you add the name of the application you will use, in this instance it is GithubApp.

android:name="GithubApp"

In the AndroidManifest.xml, make sure you add the following or you may have issues using the MockTestRunner.

android:usesCleartextTraffic="true"

The api we are fetching is a normal list, an example of the type of API we are using link

[
  {
    "id": 132935648,
    "node_id": "MDEwOlJlcG9zaXRvcnkxMzI5MzU2NDg=",
    "name": "boysenberry-repo-1",
    "full_name": "octocat/boysenberry-repo-1",
    "private": false,
    "owner": {
      "login": "octocat",
      "id": 583231,
      "node_id": "MDQ6VXNlcjU4MzIzMQ==",
      "avatar_url": "https://avatars3.githubusercontent.com/u/583231?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octocat",
      "html_url": "https://github.com/octocat",
      "followers_url": "https://api.github.com/users/octocat/followers",
      "following_url": "https://api.github.com/users/octocat/following{/other_user}",
      "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
      "organizations_url": "https://api.github.com/users/octocat/orgs",
      "repos_url": "https://api.github.com/users/octocat/repos",
      "events_url": "https://api.github.com/users/octocat/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octocat/received_events",
      "type": "User",
      "site_admin": false
    },

How to run the project locally

To run the unit tests locally.

./gradlew testdebugUnitTest

To run the ui tests locally, but first we need an emulator to be open.

./gradlew connectedCheck

Tools

Linter: we use the following linter link.

Uploading Artifacts: we use the following way to upload Artifacts, they allow you to persist data like test results after a job has completed, see the following documentation link.

Creating a Mock Server: we use a mock server with Postman to quickly test apis, to see how to create a mock server, see the following video link.

Mobile Specific Tools:

Fastlane: Fastlane allows us to automate our development and release process link.

App Center: App Center is used to distribute an app, making it very easy to test on a physical device by using a fastlane plugin link.

Update Dependencies

Npm: How to update a npm package.

Gemfile: How to update a Gemfile package.

Releases

How to manage releases in a repository link.

Helpful resources

The following link provides very helpful information on Retrofit and mocking using MockWebServer.

The following link goes into leveling up your ui tests with MockWebServer

The following link provides a guide on consuming apis with Retrofit

The following link helps if you get the following error Failed to open QEMU pipe 'qemud:network': Invalid argument.

The following link provides information if you failed to define the application in the manifest.

The following link provides information on how to convert from using Gson to Moshi.

The following link provides Moshi's official github which provides examples on how to use Moshi.

The following link provides info on Unresolved reference: kotlinx.

About

A Kotlin Application that uses Github public API to show a list of repos name. It uses Retrofit and MockWebServer to mock apis.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages