Commit 6deb704
Working towards android support (#4169)
## Part of Android support
### Relevant issues:
- #3868
- #3550
### Outline
- Follow android studio + gradle standard for directory structure
- Unit test support (local runs - no android device needed)
- Integration test support (android tests, needs an android
device/emulator)
### New features
- Ability to install an apk in the default available android device
(tested against AVD)
- Ability to run all integration tests with the install command (android
manifest with instrumentation is needed, this needs to be a
functionality of integration tests support in the future instead)
- Classpath resolution (runtimeDependencies) for packaging with
dependencies and user's source code (tested against integration test and
running the android app itself via the emulator)
- Special classpath resolution and packaging for android tests
(integration tests)
- Mill integrates with avdmanager, adb and emulator to automate the run
of integration tests by creating virtual devices and controlling the
emulator (start, stop). Examples are added in documentation of both
kotlin and java app. This includes the ability to use different
emulators for different apps, by specifying identifiers and ports,
though this use case should be rare in app development lifecycles.
- Github actions & mill support to run integration tests in (headless)
emulator & differentiate from local mode (windowed emulator + default
gpu settings)
### Github actions
A sample repo to demonstrate what's needed to run the emulator
https://github.com/vaslabs-ltd/test-android-emulator
In the end what slowed me down was that for github actions, the AVD home
env var was needed, which wasn't obvious until I've tested it in
isolation . All the flags and kvm configs are also needed and it's what
https://github.com/ReactiveCircus/android-emulator-runner does
### Stubs and missing features
An effort was made to standardise the structure faster, so follow up PRs
will not use a non-standard structure. Things that are working but not
"production ready" are:
1. Integration tests debug apk: This inherits the current apk
construction, debug functionality needs to be added and separated from
the release androidApk task
2. No testOnly for integration tests: this is easy to do, but was not
added in the interest of not increasing the size of the PR and the
testing surface
3. Classpath resolution: For kotlin, jvm specific dependencies are
removed in a hardcoded way.
4. Desugaring: This shows as a warning in the android tests apk
creation, while the flow works, the d8 will need to be configured to
desugar annotations properly.
5. Emulator CI mode only recognises github actions
### Demo
#### Running android tests
https://github.com/user-attachments/assets/0cb47ac7-32ff-4d5c-a678-11cd18807b10
---------
Co-authored-by: irodotos7 <[email protected]>1 parent 4cc94cf commit 6deb704
File tree
29 files changed
+781
-75
lines changed- .github/workflows
- example/android
- javalib
- 1-hello-world
- app/src
- androidTest/java/com/helloworld/app
- main
- java/com/helloworld
- res/values
- test/java/com/helloworld
- 2-app-bundle
- bundle/src/main
- res/values
- 3-linting
- app/src/main
- res/values
- kotlinlib/1-hello-kotlin
- app/src
- androidTest/java/com/helloworld/app
- main
- java/com/helloworld
- kotlin/com/helloworld
- res/values
- test
- java/com/helloworld
- kotlin/com/helloworld
- kotlinlib/src/mill/kotlinlib/android
- scalalib/src/mill/javalib/android
29 files changed
+781
-75
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
56 | 69 | | |
57 | 70 | | |
58 | 71 | | |
| |||
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| |||
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| 29 | + | |
| 30 | + | |
26 | 31 | | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
31 | 94 | | |
32 | 95 | | |
33 | 96 | | |
| |||
52 | 115 | | |
53 | 116 | | |
54 | 117 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
64 | 130 | | |
65 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
57 | 60 | | |
58 | 61 | | |
0 commit comments