Generating an APK without having an Android SDK

Hello there, I’m very new to Jenkins and I’m hitting a wall right now. As the title suggests, I’m trying to set up a Jenkins job that would be able to generate an Android APK every time a commit occurs in GitLab.

My problem is that currently the Jenkins server is located on a Mac and for certain reasons I am unable to set up the Android SDK environment on the machine. Most of the guides and tutorial I’ve found on the internet requires an SDK environment to generate an APK, so I’m currently out of ideas on how to do this.

On the other hand, I was able to generate an IPA for the iOS version of the app I’m developing using Fastlane without setting up any connections to Xcode (This was done using said Mac). I would like to replicate this process on a Windows device but Fastlane doesn’t really have the best support on Windows so I’m iffy about using it. I tried looking for the Windows equivalent/alternative to Fastlane but to no avail.

So now we’re back to the title, would it be possible to generate an APK without setting up an Android SDK on Jenkins?

If you can find a way to do it without jenkins, then i’m sure jenkins can do it.

But the sdk includes all the depandancies, so i think they are needed.

Just fyi, as I set it up this week, installing the sdk is download the commandlinetools zip, extracting to a directory, then adding it to path. This is something jenkins can do in your build if you can’t install android studio (which is what I’m assuming you mean when you say “cant install for reasons”)

I don’t really know anything about APK’s and Android studio. But I have other ideas for fixing the problem.

Can you setup docker on the mac machine that is running Jenkins? If so you could try running the build inside of a container that uses a docker image that has Android Studio, something like this container.

I meant to post this hours ago and got distracted lol. But if you think this would work but need help with docker let me know.

Yeah, I didn’t want to touch too much on why I can’t install the SDK but knowing that I don’t need to have Android Studio on the machine helps. Thanks for the answer!

I was suggested to use a docker image that contains an SDK on stack overflow too. That said, I’ve no prior experience with docker images whatsoever so I’m trying to see if I absolutely can’t set up the SDK on the Mac machine.

When push comes to shove, I’ll try the docker solution as you suggested. I’ll follow up your offer to help if I’m going through with the docker solution. Thanks for the help!

Docker is pretty handy to have in your personal toolkit. At a basic level, a container is just an ephemeral VM. So if you normally install the Android Studio and run the bash command make apk. Then you can do it in Jenkins with:

node {
    /* Requires the Docker Pipeline plugin to be installed */
    docker.image('androidsdk/android-30:latest').inside {
        stage('Create APK') {
            sh('make apk')

Where you basically tell Jenkins the container you want to use and then the commands to run inside that container. Jenkins will make your workspace available inside the container behind the scenes.

Do you have any guides/article/videos on Dockers that you’d recommend? Preferably something beginner friendly.

Unfortunately I do not, but if you search in youtube, I’m sure some of the most viewed videos should be sufficient enough to get you started.

No problem. Still, thanks for the assistance!

1 Like