-
-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android: add aar dependencies support, create proper build pipeline, add Jetpack Compose example #4188
Conversation
e4eb576
to
a37153c
Compare
Android examples are failing, because work with emulator is flaky - it seems that, for example, it starts very slow, causing timeout. This is not related to the changes in this PR. |
I think it looks reasonable for me, @vaslabs would be great if you could give this a review pass (whenever you're available) before I merge it |
@@ -49,13 +52,43 @@ object AndroidLintReportFormat extends Enumeration { | |||
@mill.api.experimental | |||
trait AndroidAppModule extends JavaModule { | |||
|
|||
override def sources: T[Seq[PathRef]] = Task.Sources(millSourcePath / "src/main/java") | |||
private val parent: AndroidAppModule = this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Scala, it is customary to achieve this via
trait AndroidAppModule extends JavaModule { self =>
or
trait AndroidAppModule extends JavaModule { parent =>
if you will
// TODO store this key outside of the build file structure, because once build folders are deleted, new key will | ||
// be created, so app will have another signature leading to the need to remove app from the device/emulator | ||
// before installing a new build, which is annoying. | ||
val debugKeystoreFile = T.dest / "debugKeyStore.jks" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should have similar behaviour with gradle/android studio and store this in ~/.android
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also playing with instant APK feature, it could solve this problem
LGTM, nice, only left one comment but in general we can keep working on any rough edges in subsequent PRs. I've also tested it locally! |
Thanks @vaslabs ! Let me kick CI a few times to try and get a green before merging |
@0xnm |
indeed, when ran concurrently
this was already mentioned in one of the methods. Perhaps a quick fix, if not adding more work for a central debug keystore, we can have an option to have different aliases for different apps. In general we need to find a way to test these usecases that rely on shared resources (I had the same issue with the emulator which right now also causes a lot of flakiness) without conflicts . |
yes, it did. I guess there is some flakiness, I will try to address it as a part of this PR, hold on with the merge. |
If it's concurrency related we could try setting mill/.github/workflows/run-tests.yml Line 80 in d2df820
|
89304c4
to
0c6a839
Compare
…add Jetpack Compose example
0c6a839
to
a84f97c
Compare
Indeed, the concurrency of the tests run is the issue. The problem here is that AVD/Emulator is the shared resource: it can only be a single instance of emulator on the particular port; it can be only the single instance of AVD with the given name. It means, that if certain Android example tests are running in parallel, they can mess up with each other, because they are managing the same AVD and the same emulator. They (or even better Android hadling logic in Mill) should cover "non-happy" cases (like AVD with the given name already exists when trying to create it, etc.). For the moment I've added |
Apart from |
I've configured each task (one in kotlin on in java) that uses the emulator to use a different one and on different port. but I think the issue is that both need 1.5GB of ram and it cannot be reduced. I've seen in my branch that if the job is run on its own, it usually passes. |
I'm going to go ahead and merge this, since |
This PR changes a lot of things in the Android build support (mainly focusing on creating proper build pipeline). In details:
aar
dependencies processingaapt2
at thecompile
/link
stagesaapt2
and dexingThis PR doesn't add yet support of the transitive Android modules, this is a work to be done in the future.
The code quality is maybe meh, but I expect many pieces here to be changed in the future to be better and have wider support of the different build options/flags.
The most important part this PR does is mentioned above: it brings a proper pipeline. I added many flags/comments for the future work, allowing contributors to focus on the specific parts.
One thing to mention as well is that in the current state the incremental builds will have terrible performance. This is the area which requires a massive time investment to be on-par with AGP to support only processing of the files in the pipeline which really changed. Because of this the output types of certain tasks will probably change in the future or they will be split into more granular tasks.
I would like also to mention other things which should be improved:
def bundleToolVersion = "1.17.2"
should be pre-defined in the Android SDK module and they shouldn't be required for writing build script, because:MavenModule
?mill.androidlib
?AndroidAppBundle
is a good idea, because it is just a way of packaging. AGP has only 2 main entrypoints: Application and Library, the rest is their configuration options. Bazel also has application and library as main entrypoints for rules (see https://github.com/bazelbuild/rules_android/tree/main/rules).compileSdk
version (e.gcompileSdk
is 35, thenbuildToolsVersion
should be35.0.0
by default), but in the current layout it is not possible to do implicitly, so both versions should be specified.