2.6 KiB
Android Development Container
This sets up development containers for Expo and Flutter using the Android SDK. The Dockerfile is derived from parts of thyrlian/android-sdk, with expo and flutter development infrastructure configured as well.
Build the Android SDK development container environment
The following steps will set up an Android build environment:
-
Seed
android-sdk-manager
container with an initial version of the Android SDK:docker compose build
This will build the base 'android-sdk-manager' container as well create an unseeded 'android-dev-container'.
-
Transfer the AndroidSDK from
android-sdk-manager
to the host:Copy the sdk from the android-sdk-manager to the host to allow multiple containers to use the same base SDK, as well as to perform SDK updates, upgrades, and additional package installations.
docker compose run -it --rm \ -v $(realpath AndroidSDK):/sdk:rw \ -v $(realpath scripts):/scripts:rw \ android-sdk-manager \ init
-
Install packages into SDK
The
android-sdk-manager
container can then be used to update then./AndroidSDK
on the host to include additional packages.The following will install Android platform 35:
ANDROID_PLATFORM=35 docker compose run -it --rm \ -v $(realpath AndroidSDK):/opt/android-sdk:rw \ -v $(realpath scripts):/scripts:rw \ android-sdk-manager -- \ sdkmanager \ "build-tools;${ANDROID_PLATFORM}.0.0" \ "platforms;android-${ANDROID_PLATFORM}" \ "platform-tools"
At this point,
./AndroidSDK
contains the latest SDK with the requested Android Platform version.
Seed a flutter repository
git clone https://github.com/flutter/flutter.git
To seed a new project (once per project)
PROJECT=foo
PROJECT_TYPE=expo # flutter
./seed.sh "${PROJECT_TYPE}" "${PROJECT}"
To develop
PROJECT=foo
PROJECT_TYPE=expo
./develop.sh "${PROJECT_TYPE}" "${PROJECT}"
To access the shell of the running project
PROJECT=foo
./shell.sh "${PROJECT}"
To stop development container
docker compose stop "${PROJECT}"
Things
To use virtual devices:
Install base image
sdkmanager "system-images;android-35-ext14;google_apis_playstore;x86_64"
Create virtual device
avdmanager create avd \
-n Pixel \
-d pixel_6a \
-k "system-images;android-35-ext14;google_apis_playstore;x86_64"