DEV Community

Vignesh S
Vignesh S

Posted on

GitHub Actions for Android

In this post, the "Android-InAppBilling" open source android application sample was used that leverages GitHub Actions CI.

The Workflow:

The "Android-InAppBilling" open source android app sample is based on Gradle build system. So, the workflow will run "gradlew" script on its machine to build the app.

To accomplish this, created a new "build.yml" GitHub Actions Workflow file on:

root_repo/.github/workflows/build.yml

In the "build.yml", the name of workflow is given as

name: build

You can define your own workflow name, and you can create multiple workflows on the same project.

The project has to build the code base on:

1) whenever there is a change pushed to repository

2) whenever there is a new Pull Request created for the repository

To accomplish this, added the below changes on the workflow file:

on:
  push:
    branches: [ main ] 
  pull_request:
    branches: [ main ]

After this, we have created a job where all of the work will be running on ubuntu.

jobs:
  build:
    runs-on: ubuntu-latest

This workflow uses predefined actions that will checkout to the main branch and uses JDK 1.8

steps:
    - uses: actions/checkout@v2
    - name: Set up JDK 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 1.8

Then, we have granted executable permission for the "gradlew" script as "run" command to make a build as follows:

    - name: Grant execute permission for gradlew
      run: chmod +x gradlew

After this, we first try to check the code base with lint tool:

    - name: Check Lint
      run: sudo ./gradlew lintDebug

We used "sudo" here, just wanted to install missing Android SDK and the Build Tools.

If it was successful, then we try to run tests...

    - name: Run tests
      run: sudo ./gradlew test

If all the test cases passed, then we try to build the app by:

    - name: Build with Gradle
      run: sudo ./gradlew build

The complete workflow file and the repository link included here with this post as below...

Yaml File:

Link to Code:

GitHub logo LiteKite / Android-InAppBilling

A sample which uses Google's Play Billing Library and it does InApp Purchases and Subscriptions.

Android-InAppBilling

App Icon

A sample which uses Google's Play Billing Library and it does InApp Purchases and Subscriptions.

build

App Screenshot One
App Screenshot Two
App Screenshot Three
App Screenshot Four
App Screenshot Five
App Screenshot Six

Getting Started

  1. Add Play Billing Library dependency in your Android Studio Project.

  2. Use the Application ID that's been used in your Google Play Developer Console.

  1. Make In-app purchases by starting BillingClient connection, make querying purchases locally or from Google Play Store Cache from BillingClient

  2. In-app product or "Managed Products" can be bought multiple times by consuming purchase before requesting another purchase.

  3. Subscription based products cannot be consumed, It'll be based on some time periods that you choose and will expire after the time ends. These are all handled by Google Play Remote Server.

  4. Add Tester Accounts in Google Play Developer Console -> App Releases for making test purchases and upload the initial version of your project APK including Google Play Billing Library dependency.

Libraries Used

Play Billing Library -> for making Google Play In-app…

Submission Category:

Phone Friendly

Top comments (0)