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

António Valente
May 15 · 2 min read

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 {
project.ext.AWS_S3_BUCKET = "YOUR BUCKET NAME"
project.ext.AWS_S3_KEY_ID = "YOUR BUCKED SECRET ID"
project.ext.AWS_S3_KEY_SECRET = "YOUR BUCKED SECRET KEY"
project.ext.AWS_S3_APK_TARGET_FOLDER = "YOUR S3 TARGET FOLDER"
}

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.

apply from: 'publishApkToS3.gradle'

5. Publish your app to S3

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

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

Thank you for reading!

Thank you so much for reading and if you enjoyed this article make sure to hit that 👏👏 button. It means a lot to us! Also don’t forget to follow Coletiv on Medium, Twitter, and LinkedIn as we keep posting more and more interesting articles on multiple technologies.

Coletiv

Thoughts, dreams and rants about technology and work life from the Coletiv team

Thanks to Tiago Duarte.

António Valente

Written by

Coletiv

Coletiv

Thoughts, dreams and rants about technology and work life from the Coletiv team