[FIXED] Build Script android apk for Bitbucket Pipiline

Issue

I am very new to this and probably don’t understand some things that i should, so bare with me!

I am trying to create a build script for building an android apk on Bitbucket pipeline.
I use ./gradlew assembleDebug but i miss a lot of things there.

In the project i have a custom library which needs ndk in order to be built, but i don’t know how to get that ndk in the pipeline.
In my studio locally it builds fine! But i don’t know how to do that on pipeline.

Can someone please explain to me what i need to do?

image: androidsdk/android-30

pipelines:
  default:
     - step:
          name: Android Debug Application
          deployment: Test
          caches:
            - gradle
          script:
            - echo 'Start Building'
            - ./gradlew assembleDebug
            - echo 'Building Finished'
          artifacts:
            - app/build/outputs/**

The above is what i have now!

Please help a friendly noobCoder here.
Many thanks in advance!

Solution

After a lot of searching and testing, this is my result

image: androidsdk/android-30

pipelines:
  default:
     - step:
          name: Android Debug Application
          deployment: Test
          caches:
            - gradle
          script:
            - echo 'Start Building'
            - apt-get install make -y
            # download ndk
            - wget "https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip" -O temp.zip
            - unzip temp.zip -d ~/android_ndk
            - rm temp.zip
            - export DIR=~/android_ndk/android-ndk-r14b
            - echo "ndk.dir=$DIR" >> local.properties
            
            - cat local.properties
            - ./gradlew assembleDebug
            - echo 'Building Finished'
          artifacts:
            - app/build/outputs/**

I use an unsupported ndk that is why i download it. In case you want a supported ndk you can easily type:

- sdkmanager <ndk;version>

It will get more updates I hope so!

Answered By – panos pavlatos

Answer Checked By – Senaida (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published