|
1 | | -###Lightweight Android Container |
| 1 | +##Lightweight Android Container |
| 2 | + |
| 3 | +####First attempt:[Project Sunflower](https://github.com/android/sunflower) |
| 4 | +>A gardening app illustrating Android development best practices with Android Jetpack. |
| 5 | +
|
| 6 | +Sunflower is currently configurated with`gradle-5.4.1` and`Android Build Tools v28` |
| 7 | + |
| 8 | +Build the docker image that works for this project: |
| 9 | +```shell |
| 10 | +docker build \ |
| 11 | +--build-arg GRADLE_VERSION=5.4.1 \ |
| 12 | +--build-arg ANDROID_SDK_VERSION=28 \ |
| 13 | +--build-arg EMULATOR_NAME=test \ |
| 14 | +-t android-container:28-5.4.1. |
| 15 | +``` |
| 16 | + |
| 17 | +Clone and cd to the project dir:`git clone https://github.com/android/sunflower && cd sunflower/` |
| 18 | + |
| 19 | +Start to build the project |
| 20 | +```shell |
| 21 | +docker run --privileged -it --rm -v$PWD:/data android-container:28-5.4.1 \ |
| 22 | +bash -c". /start.sh && gradlew connectedAndroidTest -p /data" |
| 23 | +``` |
| 24 | + |
| 25 | +Here is result that I observed on my terminal |
| 26 | +```shell |
| 27 | +> Task :app:connectedDebugAndroidTest |
| 28 | + |
| 29 | +com.google.samples.apps.sunflower.PlantDetailFragmentTest> testShareTextIntent[test(AVD) - 9] SKIPPED |
| 30 | + |
| 31 | +08:44:46 V/InstrumentationResultParser: INSTRUMENTATION_RESULT: stream= |
| 32 | +08:44:46 V/InstrumentationResultParser: |
| 33 | +08:44:46 V/InstrumentationResultParser: Time: 2.872 |
| 34 | +08:44:46 V/InstrumentationResultParser: |
| 35 | +08:44:46 V/InstrumentationResultParser: OK (11 tests) |
| 36 | +08:44:46 V/InstrumentationResultParser: |
| 37 | +08:44:46 V/InstrumentationResultParser: |
| 38 | +08:44:46 V/InstrumentationResultParser: INSTRUMENTATION_CODE: -1 |
| 39 | +08:44:46 V/InstrumentationResultParser: |
| 40 | +08:44:46 I/XmlResultReporter: XMLtest result file generated at /data/app/build/outputs/androidTest-results/connected/TEST-test(AVD) - 9-app-.xml. Total tests 12, passed 11, ignored 1, |
| 41 | +08:44:46 V/ddms: execute'am instrument -w -r com.google.samples.apps.sunflower.test/androidx.test.runner.AndroidJUnitRunner' on'emulator-5554': EOF hit. Read: -1 |
| 42 | +08:44:46 V/ddms: execute: returning |
| 43 | +08:44:46 V/ddms: execute: running pm uninstall com.google.samples.apps.sunflower.test |
| 44 | +08:44:46 V/ddms: execute'pm uninstall com.google.samples.apps.sunflower.test' on'emulator-5554': EOF hit. Read: -1 |
| 45 | +08:44:46 V/ddms: execute: returning |
| 46 | +08:44:46 V/ddms: execute: running pm uninstall com.google.samples.apps.sunflower |
| 47 | +08:44:46 V/ddms: execute'pm uninstall com.google.samples.apps.sunflower' on'emulator-5554': EOF hit. Read: -1 |
| 48 | +08:44:46 V/ddms: execute: returning |
| 49 | + |
| 50 | +Deprecated Gradle features were usedin this build, making it incompatible with Gradle 6.0. |
| 51 | +Use'--warning-mode all' to show the individual deprecation warnings. |
| 52 | +See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings |
| 53 | +``` |
| 54 | + |
| 55 | +Cool, it works! |