Docs: How to build for android

Created on 8 Jan 2019  Â·  4Comments  Â·  Source: dotnet/docs

[Enter feedback here]
The RIDs is contain andorid,but no core sdk on android or cross build for it.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Area - .NET Core Guide P2 Pri2 doc-enhancement dotnet-corprod

Most helpful comment

What I've found

I found the following RIDs in the runtime.json

  • android
  • android-arm
  • android-arm64
  • android.21
  • android.21-arm
  • android.21-arm64

They were added at 125bc42 by merging pull request dotnet/corefx#16729 on 2017-03-07.
They were last modified at 81ba628 by merging pull request dotnet/corefx#28560 on 2018-03-30.

I tested them on .NET Core SDK 2.1.801 (Runtime 2.1.12). The result is only android and android.21 led to NETSDK1056 error; all others built successfully.


I am not able to investigate source of .NET, though there are some folders named after android in those repos.

I created a Hello World, built as android-arm64 SCD, and compared binaries.

dotnet new console
dotnet publish --configuration Release --runtime android-arm64

It's obvious that the runtime files are from linux-arm64 in package runtime.linux-arm64.Microsoft.NETCore.App, which means that android-arm64 is implemented by falling back to linux-arm64.

This should be because of the entry

{
  "android-arm64": {
    "#import": [
      "android",
      "linux-arm64"
    ]
  }
}

With a bit more effort, I drew the RID graph
(Only officially available paths are shown)

android.21-arm -> android-arm -> linux-arm -> ...

android.21-arm64 -> android-arm64 -> linux-arm64 -> ...
  • linux-arm is from runtime.linux-arm.Microsoft.NETCore.App
  • linux-arm64 is from runtime.linux-arm64.Microsoft.NETCore.App

The section Do I really need to add a new RID? of Runtime IDs says

Microsoft.NETCore.Platforms attempts to define all RIDs that packages may need, and as such will define RIDs for platforms that we don't actually cross compile for. This is to support higher-level packages, 3rd party packages, that may need to cross-compile for that RID.


The section RID graph of .NET Core RID Catalog | Microsoft Docs, which this issue is related to, says

When NuGet restores packages, it tries to find an exact match for the specified runtime. If an exact match is not found, NuGet walks back the graph until it finds the closest compatible system according to the RID graph.


In pull request dotnet/docs 8710 pointed out by piccaso,
jkotas said on 2018-11-13 that

I would delete the Android section here. There are no official/supported Android packages available today.


There is a similar situation in the issue dotnet/sdk#3037:

Alpine 3.9 RIDs were added in 2019-01, but not supported by all the SDK distros until 2019-04.

Conclusion

.NET may define RIDs for some reason but not implement them immediately.

There are still no direct official packages for Android so far.

The RIDs

  • android-arm
  • android-arm64
  • android.21-arm
  • android.21-arm64

are supported by fallback.

The RIDs

  • android
  • android.21

are defined for hierarchy, but there are no packages available.

Did I miss anything? Thanks.

All 4 comments

Any feedback on this issue?

Trying to build a console with

dotnet publish -r android stankinsv2/solution/StankinsV2/Stankins.Console/Stankins.Console.csproj --self-contained true

The answer is :

NETSDK1056: Project is targeting runtime 'android' but did not resolve any runtime-specific packages. This runtime may not be supported by the target framework.

You can find azure pipeline at
https://github.com/ignatandrei/stankins/

I'm not sure if there ever was (official) android support for dotnet core, but the android RIDs have been removed from the docs in #8710.

What I've found

I found the following RIDs in the runtime.json

  • android
  • android-arm
  • android-arm64
  • android.21
  • android.21-arm
  • android.21-arm64

They were added at 125bc42 by merging pull request dotnet/corefx#16729 on 2017-03-07.
They were last modified at 81ba628 by merging pull request dotnet/corefx#28560 on 2018-03-30.

I tested them on .NET Core SDK 2.1.801 (Runtime 2.1.12). The result is only android and android.21 led to NETSDK1056 error; all others built successfully.


I am not able to investigate source of .NET, though there are some folders named after android in those repos.

I created a Hello World, built as android-arm64 SCD, and compared binaries.

dotnet new console
dotnet publish --configuration Release --runtime android-arm64

It's obvious that the runtime files are from linux-arm64 in package runtime.linux-arm64.Microsoft.NETCore.App, which means that android-arm64 is implemented by falling back to linux-arm64.

This should be because of the entry

{
  "android-arm64": {
    "#import": [
      "android",
      "linux-arm64"
    ]
  }
}

With a bit more effort, I drew the RID graph
(Only officially available paths are shown)

android.21-arm -> android-arm -> linux-arm -> ...

android.21-arm64 -> android-arm64 -> linux-arm64 -> ...
  • linux-arm is from runtime.linux-arm.Microsoft.NETCore.App
  • linux-arm64 is from runtime.linux-arm64.Microsoft.NETCore.App

The section Do I really need to add a new RID? of Runtime IDs says

Microsoft.NETCore.Platforms attempts to define all RIDs that packages may need, and as such will define RIDs for platforms that we don't actually cross compile for. This is to support higher-level packages, 3rd party packages, that may need to cross-compile for that RID.


The section RID graph of .NET Core RID Catalog | Microsoft Docs, which this issue is related to, says

When NuGet restores packages, it tries to find an exact match for the specified runtime. If an exact match is not found, NuGet walks back the graph until it finds the closest compatible system according to the RID graph.


In pull request dotnet/docs 8710 pointed out by piccaso,
jkotas said on 2018-11-13 that

I would delete the Android section here. There are no official/supported Android packages available today.


There is a similar situation in the issue dotnet/sdk#3037:

Alpine 3.9 RIDs were added in 2019-01, but not supported by all the SDK distros until 2019-04.

Conclusion

.NET may define RIDs for some reason but not implement them immediately.

There are still no direct official packages for Android so far.

The RIDs

  • android-arm
  • android-arm64
  • android.21-arm
  • android.21-arm64

are supported by fallback.

The RIDs

  • android
  • android.21

are defined for hierarchy, but there are no packages available.

Did I miss anything? Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sdmaclea picture sdmaclea  Â·  3Comments

gmatv picture gmatv  Â·  3Comments

ike86 picture ike86  Â·  3Comments

sebagomez picture sebagomez  Â·  3Comments

ite-klass picture ite-klass  Â·  3Comments