Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Role of CI-CD and Unit Testing to create and publish android APKs

As I have gone through many JDs of different companies, I have found one point like CI-CD. As i have learned may things in CI-CD like. Lint checking, Unit testing, integration testing and many more things...

But, I haven't found any solution to publish APK to play console directly by using CI-CD. So, I want to know that is it possible to publish APK To play console directly with CI-CD flow.

Further, I want to know that, What is the role of CI-CD in android builds like which kind of processes we have to do in CI-CD section.

Now a days, I am planing for job change and also want to enhance my skill in CI-CD and testing area and want to get guidance from those who are working as TL in big IT Industries and I want to aware about industry standards and rules for specific CI-CD and Testing also.

Generally, Many Devs like me who comes from small industries, don't much aware about this and just make application ready with robust code with unit testing and test it manually but don't aware about the CI-CD and Unit testing(like how TL Checks that All unit test cases ate written properly and code coverage of it. because after every PR Merge, test and generate report manually is bit headache for TL so how it is organised and managed by industries) flow and how it plays big role in large industries.

Kindly provide me some guidance on the same!

Thank you in advance!


1 Answers

This question is too broad but I'll do my best at least to have some starting points.

If using github you can use github actions from r0adkll to sign an android release and upload it to google play.

For that, first you should create service account and grant permission for CD pipeline to deploy in play store:

A key for the API access will be needed with access granted.

Then you will need to create an AAB signed by using r0adkll/sign-android-release:

    - name: Build Release AAB
      run: ./gradlew bundleRelease

    - name: Sign app bundle      
      uses: r0adkll/sign-android-release@v1
      id: sign_app
      with:
        releaseDirectory: app/build/outputs/bundle/release
        signingKeyBase64: ${{ secrets.SIGNING_KEY }}
        alias: ${{ secrets.KEY_ALIAS }}
        keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
        keyPassword: ${{ secrets.KEY_PASSWORD }}

and to deploy it r0adkll/upload-google-play:

    - name: Create service_account.json
      run: echo '${{ secrets.SERVICE_ACCOUNT_JSON }}' > service_account.json

    - name: Deploy to Play Store
      uses: r0adkll/upload-google-play@v1
      with:
        serviceAccountJson: service_account.json
        packageName: ${{ github.event.inputs.app_id }}
        releaseFiles: app/build/outputs/bundle/release/*.aab
        track: production

With that github action the relese .aab file (Android app bundle) is uploaded to the Google Play Console.

About which process you should do in CI/CD it depends on what you need, probably you'll want to run unit tests:

    - name: Run tests
      run: ./gradlew test

If there are ui tests to be passed I use reactivecircus/android-emulator-runner@v2

    - name: Run espresso tests
      uses: reactivecircus/android-emulator-runner@v2
      with:
        api-level: 33
        script: ./gradlew connectedCheck

and I'm now using roborazzi for screenshot tests which don't need the emulator:

    - name: Verify Screenshots (roborazzi)
      run: 'bash ./gradlew verifyRoborazziDebug'

It's an extended topic, the key is going adding one by one the workflows, jobs and steps you need.

More details and examples in: https://github.com/TharunBalaji2004/android-ci-cd

I hope this helps.

like image 152
jeprubio Avatar answered Nov 30 '25 02:11

jeprubio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!