Building an Android project from the command line with Docker

I inherited Android Java-code in my company, without Gradle-files etc, and I want to be able to compile this on my dev-server (I program from a ChromeOS machine, hence a CLI SSH connection to a server where I do dev stuff). Now I found some Docker images like https://hub.docker.com/r/ksoichiro/android/ (with a not even working command line example) but I don’t manage to create an APK yet. What am I missing and how would you do this?

  • Android SDK tools install in Docker fails
  • Unable to run android emulator inside Docker container
  • Docker cannot create a machine - 'Error in driver during machine creation'
  • Android instrumentation test with Bitbucket pipelane and Docker
  • ADB unable to start or find devices after sudo adb devices
  • Emulate Bluetooth LE Adapter for Acceptance Testing
  • How to run appium test using aluedeke/appium-android docker image?
  • Can I add new shared directories to Docker from the command line?
  • Docker environment for two similar projects
  • How to install Cloud Foundry CLI on Ubuntu
  • Emulate Bluetooth LE Adapter for Acceptance Testing
  • how to automate docker development environment startup for a multi-service web app (on Linux)
  • One Solution collect form web for “Building an Android project from the command line with Docker”

    You have three steps to do:

    1. Migrate your project to gradle.

      It isn’t too difficult since there are plenty of gradle project out there and you can try to follow them or just read “Migrating to Gradle” article.

    2. Build project with gradle on local machine.

      If you migrated properly you can build your project in terminal like:

      ./gradlew assembleDebug

      but it might be also assembleDevDebug or assembleProdRelease which depends on your buildType and flavor in gradle. Check which assembles are available by running:

      ./gradlew tasks

    3. Build project using Docker.

      Based on image you linked:

      docker run -t -i ksoichiro/android -v /path/to/project:/workspace -w workspace /bin/sh -c "./gradlew assembleDebug"

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.