Skip to content
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

How to build NativeAOT for Android under Linux (Docker) #107337

Closed
JCash opened this issue Sep 4, 2024 · 5 comments
Closed

How to build NativeAOT for Android under Linux (Docker) #107337

JCash opened this issue Sep 4, 2024 · 5 comments

Comments

@JCash
Copy link

JCash commented Sep 4, 2024

Description

When building for Android under Linux (in our Docker container), I get:

grep: /opt/platformsdk/android/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/etc/os-release: No such file or directory
  Generating native code
  Unhandled exception. System.CommandLine.CommandLineException: Target OS 'android' is not supported
     at System.CommandLine.Helpers.GetTargetOS(String) + 0x4e9
     at System.CommandLine.CliArgument`1.<>c__DisplayClass8_0.<set_CustomParser>b__0(ArgumentResult, Object&) + 0x31
     at System.CommandLine.Parsing.ArgumentResult.ValidateAndConvert(Boolean) + 0x162
     at System.CommandLine.Parsing.CommandResult.ValidateOptions(Boolean) + 0x153
     at System.CommandLine.Parsing.CommandResult.Validate(Boolean) + 0x6e
     at System.CommandLine.Parsing.ParseOperation.Validate() + 0x1b
     at System.CommandLine.Parsing.ParseOperation.Parse() + 0x30
     at System.CommandLine.Parsing.CliParser.Parse(CliCommand, IReadOnlyList`1, String, CliConfiguration) + 0x7a
     at System.CommandLine.CliConfiguration.Invoke(String[]) + 0x15
     at ILCompiler.Program.Main(String[] args) + 0xd8
  Aborted

It complains about both a missing folder, but also says Android is unsupported?
Is it one or the other, or both?

I've used the googles sdkmanager to install the Android SDK, which it seems DotNet picks up correctly.
Our setup works for building Android apps just fine, so I'm unclear on what package is missing from the Android install here?

Any help appreciated!

Regards,
Mathias

Reproduction Steps

Here is our sdk packaging script:
https://github.com/defold/defold/blob/dev/scripts/package/package_android_sdk.sh#L92-L93

Expected behavior

It should have all needed to build for Android already?
It would be good if DotNet mentioned which tool was missing, rather than a folder name.

Actual behavior

It doesn't build.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Sep 4, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Sep 4, 2024
@huoyaoyuan huoyaoyuan added area-NativeAOT-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Sep 4, 2024
Copy link
Contributor

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

@huoyaoyuan
Copy link
Member

NativeAOT for Android is still under development. See #106748 (comment) .
Closing as a duplicate.

@huoyaoyuan huoyaoyuan closed this as not planned Won't fix, can't repro, duplicate, stale Sep 4, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Sep 4, 2024
@MichalStrehovsky
Copy link
Member

If you want to build for Bionic libc, this is possible starting with .NET 8, instructions here: https://github.com/dotnet/runtime/blob/main/src/coreclr/nativeaot/docs/android-bionic.md

A more complex sample including JNI here: https://github.com/josephmoresena/NativeAOT-AndroidHelloJniLib/tree/main

This target is experimental.

@JCash
Copy link
Author

JCash commented Sep 4, 2024

Hi!
Thanks for the link.

I'm not sure I understand the target platform though: linux-bionic-arm64, is that supported later when I link my Android native app, with arch armv8-a?

Also, "Copy it to an Android device" is a step I cannot do on my (cloud) linux machine.

@MichalStrehovsky
Copy link
Member

I'm not sure I understand the target platform though: linux-bionic-arm64, is that supported later when I link my Android native app, with arch armv8-a?

linux-bionic-arm64 is a .NET RID. armv8-a doesn't exist as a RID in .NET.

Also, "Copy it to an Android device" is a step I cannot do on my (cloud) linux machine.

The instructions just show how to build and run an command line executable to run on Android. If you don't need to run it, don't copy it. I assume you want to build a library to include in a otherwise non-.NET app anyway so the way to package/execute it will be different.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

No branches or pull requests

3 participants