将 .NET Standard 类库转换为原生 aar/jar
目前,我们正在开发一个可供不同 Xamarin.* 平台使用的 .NET Standard 类库.
Currently, we are developing a .NET Standard class library that will be used by different Xamarin.* platforms.
我想知道是否有办法在原生 Android 项目中使用共享代码(可能生成 AAR/JAR 文件).
I was wondering if there is a way to use the shared code in a native Android project (maybe produce an AAR/JAR file).
我需要此功能的原因是我们公司为我们的一位客户提供了一个 AAR(由原生 Android 项目使用),我们希望保留一个源代码库,而不是两个.
The reason I need this functionality is because our company provides an AAR to one of our customers (that is used by a native Android project), and we would like to keep a single source base instead of two.
提前致谢!
更新:
名称更改为.NET 嵌入";并且在本次更新时为 v0.4.
Update:
The name changed to ".NET Embedding" and it is at v0.4 at the time of this update.
你可以使用 Mono 的 Embeddinator-4000
You can use Mono's Embeddinator-4000
它支持各种语言使用者,因此它将 .NET 代码显示为目标语言中的惯用代码.这是目前支持的语言列表:
It supports various language consumers, so it surfaces .NET code as idiomatic code in the target language. This is the list of supported languages at present:
- Objective-C:将 .NET 映射到惯用的 Objective-C API.
- Java:将 .NET 映射到惯用的 Java API.
- C:将 .NET 映射到面向对象的 C API.
Embeddinator-4000 是一种工具,可让您现有的 .NET 代码(C#、F# 和其他)从其他编程语言和各种不同的环境中使用.
Embeddinator-4000 is a tool that allows your existing .NET Code (C#, F# and others) to be consumed from other programming languages and in various different environments.
Java 目前处于 macOS、Windows 和 Android 的预览状态.
Java is currently in a preview state for macOS, Windows, and Android.
通过将 --platform= 命令行参数传递给嵌入器来选择平台.目前支持 macOS、Windows 和 Android.
The platform is selected by passing the --platform= command-line argument to the embeddinator. Currently macOS, Windows, and Android are supported.
回复:https://mono.github.io/Embeddinator-4000/
作为 Android 要求的一部分,您将需要 Xamarin.Android
7.4.99+ 和 Android Studio 3+ (Java 1.8) 但如果您使用 Xamarin 和 Java 构建 Android 应用程序,您将需要已经有了.
As a part of the requires For Android you will need Xamarin.Android
7.4.99+ and Android Studio 3+ (Java 1.8) but if you are building Android apps with Xamarin and Java you would have those already.
注意:此工具在预览中,因此请查看未解决的问题并在需要时发布新问题.
Note: This tool is in Preview, so review the open issues and post new if needed.
re: https://github.com/mono/Embeddinator-4000/issues
注意:这不是反编译,而是将 Mono 的运行时嵌入本机包中,允许 CIL 代码、AOT(即 iOS)或不在不同的语言/运行时中运行.
Note: This is not trans-compiling, but embedding Mono's runtime in a native package that allow CIL code, AOT'd (i.e. iOS) or not to run within a different language/runtime.