How to publish your Android app to an S3 bucket using Gradle

How to Publish your Android app to an S3 bucket using Gradle - Coletiv Blog

If you ever need to publish your Android app in a simple way outside the Play Store, publishing the app .apk file to an S3 bucket could be a good solution. Then you’ll just need to share the generated link to that .apk file.

Here’s how to do it.

1. Create an AWS S3 bucket

If you don’t have one already, refer to the AWS documentation for this step.

2. Create an IAM user

Again, refer to the AWS documentation to check how to do this. Just make sure that you select Programmatic access as the type of access for this user and save the Access Key and Secret Key.

3. Setup your S3 variables

You can either set up the S3 variables in the project build script or per individual module if you prefer. In this example, I will do it in the project. Just open the build.gradle file and add the following code.

allprojects {

For security reasons, I highly recommend that you save the Access Key and Secret Key as environment variables so they won’t end up in your code repository.

4. Add the publish task to your project

First, you need to download the code for the publish task, find it in this gist, and put it in your app folder.

Then, in the build.gradle of each application you want to publish, add the following:

apply from: "publishApkToS3.gradle"

Keep in mind that this task uses CURL, so make sure you have it installed in your machine.

5. Publish your app to S3

Finally, you just need to execute the following command to publish your app to the S3 bucket.


If you’re planning on running this on your CI, add the following commands to your configuration file.

chmod +x ./gradlew
./gradlew publish{flavor-name}ToS3

Thank you for reading!

Thank you so much for reading, it means a lot to us! Don’t forget to follow Coletiv on Facebook, Twitter, and LinkedIn as we keep posting interesting articles on technologies, processes, and experiences.

If you'd like to work with us on a digital product just drop us a message here.

Do you want to become part of our community?

Join our newsletter 😎