3.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:
Build Eikona
./launch.sh eikona
./shell.sh eikona
./build.sh debug # release, or empty
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"
Emulator
Run the emulator
Launch the development container
./launch.sh eikona
Once the emulator is launched (see below), select the device (shift-a) then switch to debug build (s) and finally open the app (a).
Launch the emulator
./shell.sh eikona
./emulator.sh Pixel
Install the app
./shell.sh eikona
./install.sh debug # or release -- default debug
Add a new component
Shell in and add component
./shell.sh eikona
npx expo install react-pdf-viewer
To remove
./shell.sh eikona
npm remove react-pdf-viewer
Build the app
While in the shell previously launched, run the 'build' script:
./shell.sh eikona
./build.sh debug # release
Update the application launcher icon
Go to https://easyappicon.com/, drag the adaptive-icon.png to the app, reduce padding to -100%, then save.
Copy the ic-launcher/android/* files to android/app/src/main/res/
Rebuild the application.