Android XR support
I've been working to test mill's capabilities of building Android XR applications. While I managed to build and install it on a non-XR device, I haven't managed to actually test it yet.
It seems from a first glance, XR emulator is only available for Windows and Mac. I have a Mac machine that I'm planning to test so I'm opening this issue to track progress and any issues
For reference, my current experiment is here
@souvlakias if you get the chance before me, to test this setup on your windows machine that'd be great!
On my system I can only see this image for now:
system-images;android-34;google-xr;x86_64 | 5 | Google Play XR Intel x86_64 Atom System Image
I'll see if it works on Linux as well
(of course, imo this is a very niche device profile, but it can still serve to discover issues out)
Missing features
- [x] jni (native libraries) packaged in AARs are not packaged in apk. PR https://github.com/com-lihaoyi/mill/pull/5760
- [x] Find proguard rules for device provided classes. PR https://github.com/com-lihaoyi/mill/pull/5809
Bugs
~~- [ ] windows 11 throws a not supported platform when installing command line tools~~ ~~- [ ] windows android cli tools are bat files and not recognised~~
EDIT: Created a new issue to track windows as it turns out it needs a lot of work https://github.com/com-lihaoyi/mill/issues/5762
I've also tracked down the reason for needing:
// TODO warns about classes that are shipped in devices
override def androidR8Args = Seq("--map-diagnostics", "error", "warning")
most of the errors (that I realised with the XR extensions that are shipped with the devices) are because classes (such as android.windows.sidecar.* we usually find in jetpack compose apps) are expected to be present on supported devices.
So we are missing the functionality somewhere, that adds a rule to proguard to ignore this missing links
Managed to run the XR device, but the app is crashing, seems these native libraries need to be packaged:
we are missing functionality where we need to package any jni's with the apk
also, @souvlakias found an issue on windows, he's gonna be following up with a PR
after fixing the native libs I get
java.lang.NoSuchMethodError: No virtual method createSystemRendererConnection(Landroid/app/Activity;Ljava/util/concurrent/Executor;)Lcom/android/extensions/xr/splitengine/SystemRendererConnection; in class Lcom/android/extensions/xr/XrExtensions; or its super classes (declaration of 'com.android.extensions.xr.XrExtensions' appears in /system_ext/framework/com.android.extensions.xr.jar)
which is either an issue with the dependency resolution, the rest of the xr dependencies, somehow getting it packaged or proguard rules not being picked from compiled deps and they do something with the method signatures.
but at the moment the 3 found issues are valid for all mainstream apks and will not dig deeper to XR for the time being
ran the gradle app and has the same no such method error issue, so probably it's the system image I installed @souvlakias , let me know if you manage to test it on windows
for the proguard rules I think the key is here
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:xr/runtime/runtime/proguard-rules.pro
or
https://android.googlesource.com/platform/packages/apps/Settings/+/1cf31d17aae6798e6174f6b4eaf60603352aa7f7/proguard.flags
@souvlakias check if there are any compose rules too, these files may be in the android sdk directory , if not, we need a reliable way of fetching them
EDIT: actual link for reference:
https://android.googlesource.com/platform/tools/base/+/refs/heads/studio-master-dev/build-system/gradle-core/src/main/resources/com/android/build/gradle/proguard-common.txt#52