-
-
Notifications
You must be signed in to change notification settings - Fork 382
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 Studio Integration: Attempt via bsp for Java android apps #4362
Android Studio Integration: Attempt via bsp for Java android apps #4362
Conversation
e6f78de
to
8ac7b18
Compare
Saw this and I'm wondering if I should also give it a go with a maven import and maybe test the conversion of android apps to mill |
Give it a try! I expect it will not work out of the box, but maybe it can be made to work with some effort |
@@ -1030,11 +1076,15 @@ trait AndroidAppModule extends JavaModule { | |||
|
|||
override def androidEmulatorPort: String = parent.androidEmulatorPort | |||
|
|||
override def sources: T[Seq[PathRef]] = parent.sources() :+ PathRef(androidTestPath / "java") | |||
override def sources: T[Seq[PathRef]] = Seq(PathRef(androidTestPath / "java")) |
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.
This is a good change, but still, the way instrumented testing is implemented right now is different from the way AGP does it.
The current approach is to generate a single fat APK, consisting of production + test files.
AGP is doing it in a different way: it will be 2 APKs, one is a normal production APK, another one will contain only test files and will also have a dedicated manifest obviously, with a dedicated package name attribute which will be ${main app package name}.test
. And this test APK should be installed with -t
option (see here).
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.
8ac7b18
to
cd85eea
Compare
Hi! I'm I would like to apply some automated changes to this pull request, but it looks like I don't have the necessary permissions to do so. To get this pull request into a mergeable state, please do one of the following two things:
|
will do after I give a closer look into it, this PR should be ready soon (once everything passes) |
71e3ba4
to
51469bd
Compare
getting a failure on this job, so I haven't marked it as ready yet, but I don't think it's related to my changes |
@vaslabs might be flakiness, feel free to ignore for now |
Cleanup Progressing on android studio integration Progressing slowly remove Imports and tests working but with a hack semi decent solution
7cd9cc8
to
034b3ed
Compare
I'm done with the changes within the scope of this PR |
…m-lihaoyi#4362) ## This PR provides - ability to import a mill android project to android studio via BSP, including sources and generated sources. - necessary changes to the way sources are resolved (through module dependency instead of class inheritance). - Changes to tests (e.g. number of sources compiled) reflect these changes ### Not provided - Compilation still needs to be done from the command line in order for the paths to be resolved inside the IDE. Note that to make compilation, running, testing and debugging work from android studio, we'll need to develop a plugin for it ## Note This is an early draft and I need to cleanup or review a few rough edges, I submit this as a draft to get some early feedback. I've implemented java to get the basics to work, as kotlin has multiple kinds of sources and files that need to be taken care of, so this is just a small step. Don't hesitate to point out any issues as I've really just braced through and hacked around to get this to work! @0xnm @lihaoyi any feedback will be appreciated! ## Android Studio Integration The attempt focuses on BSP. Although bsp as a plugin does not seem to be available for android studio, it strangely becomes available if it is installed through intelliJ (see video) ### Basic changes - Use the moduleDeps instead of resolving the classpath bits (sources, resources) through inheritance. This makes BSP and studio integration work (see the directories that are highlighted correctly) - Crude implementation of bsp methods to get the IDE to report the imported modules correctly ### Tricky parts - Resources are compiled twice due to how aapt linking and later the module deps compile hierarchy. In order to avoid this, I've added an empty generatedSources method in android instrumentation module . ### Demo You can see in the demo most of the IDE static import features work (R is not recognised but I'll look into it either in this PR or subsequent). https://github.com/user-attachments/assets/77fe5e52-57e7-4480-9971-b50cc8d4d839 EDIT: I've fixed the R not being recognised and the kotlin import  EDIT 2: Added summary at the top
This PR provides
Not provided
Note that to make compilation, running, testing and debugging work from android studio, we'll need to develop a plugin for it
Note
This is an early draft and I need to cleanup or review a few rough edges, I submit this as a draft to get some early feedback.
I've implemented java to get the basics to work, as kotlin has multiple kinds of sources and files that need to be taken care of, so this is just a small step.
Don't hesitate to point out any issues as I've really just braced through and hacked around to get this to work!
@0xnm @lihaoyi any feedback will be appreciated!
Android Studio Integration
The attempt focuses on BSP. Although bsp as a plugin does not seem to be available for android studio, it strangely becomes available if it is installed through intelliJ (see video)
Basic changes
Tricky parts
Demo
You can see in the demo most of the IDE static import features work (R is not recognised but I'll look into it either in this PR or subsequent).
Screencast.From.2025-01-17.18-41-15.mp4
EDIT: I've fixed the R not being recognised and the kotlin import
EDIT 2: Added summary at the top