将 .NET Standard 类库转换为原生 aar/jar

编程入门 行业动态 更新时间:2024-10-26 10:38:06
本文介绍了将 .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.

  • developer.xamarin/releases/dotnetembedding/dotnetembedding_0/dotnetembedding_0.4/
  • 安装 .NET 嵌入

你可以使用 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.

    回复: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:github/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.

更多推荐

将 .NET Standard 类库转换为原生 aar/jar

本文发布于:2023-11-14 09:02:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586789.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   类库   Standard   NET   aar

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!