使用 C# 开发 Android 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10962104/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 15:56:47  来源:igfitidea点击:

Develop Android app using C#

c#androidmono

提问by CoolArchTek

Is it possible to write an android app using C#? Is there an API or something? Is it free for personal and commercial development?

是否可以使用 C# 编写 Android 应用程序?有API什么的吗?个人和商业开发是否免费?

What do I need to install to have android project template in my Visual Studio?

我需要安装什么才能在我的 Visual Studio 中安装 android 项目模板?

采纳答案by Darren

You could use Mono for Android:

你可以使用Mono for Android

http://xamarin.com/monoforandroid

http://xamarin.com/monoforandroid

An alternative is dot42:

另一种选择是dot42

http://www.dot42.com/

http://www.dot42.com/

dot42 provides a free community licence as well as a professional licence for $399.

dot42 提供免费的社区许可证和专业许可证,价格为 399 美元。

回答by Seva Alekseyev

Mono Touch is the answer.

Mono Touch 就是答案。

http://xamarin.com/monotouch

http://xamarin.com/monotouch

回答by roim

You should try something running Mono (its compatible with .NET).

您应该尝试运行 Mono(它与 .NET 兼容)。

For game development, I recommend unity: http://unity3d.com/

对于游戏开发,我推荐unity:http: //unity3d.com/

for general aplications: http://xamarin.com/monoforandroid

一般应用程序:http: //xamarin.com/monoforandroid

回答by libjup

There are indeed C# compilers for Android available. Even though I prefer developing Android Apps in Java, I can recommend MonoForAndroid. You find more information on http://xamarin.com/monoforandroid

确实有适用于 Android 的 C# 编译器可用。尽管我更喜欢用 Java 开发 Android 应用程序,但我可以推荐 MonoForAndroid。您可以在http://xamarin.com/monoforandroid上找到更多信息

回答by Frank Rem

Here is a new one (Note: in Tech Preview stage): http://www.dot42.com

这是一个新的(注意:在技术预览阶段):http: //www.dot42.com

It is basically a Visual Studio add-in that lets you compile your C# code directly to DEX code. This means there is no run-time requirement such as Mono.

它基本上是一个 Visual Studio 插件,可让您将 C# 代码直接编译为 DEX 代码。这意味着没有像 Mono 这样的运行时要求。

Disclosure: I work for this company

披露:我在这家公司工作



UPDATE: all sources are now on https://github.com/dot42

更新:所有来源现在都在https://github.com/dot42

回答by darksider474

Having used Mono, I would NOT recommend it. The Mono runtime is bundled with your app, so your apk ends up being bloated at more than 6MB. A better programming solution for C# would be dot42. Both Mono and dot42 are licensed products.

使用过 Mono,我不会推荐它。Mono 运行时与您的应用程序捆绑在一起,因此您的 apk 最终会膨胀超过 6MB。更好的 C# 编程解决方案是dot42。Mono 和 dot42 都是许可产品。

Personally, I would recommend using Java with the IntelliJ IDEAdev environment. I say this for 3 reasons:

就个人而言,我建议在IntelliJ IDEA开发环境中使用 Java 。我这样说有3个原因:

  1. There is so much Java code out there for Android already; do yourself a favour and don't re-invent the wheel.
  2. IDEA is similar enough to Visual Studio as to be a cinch to learn; it is made by JetBrains and the intelli-sense is better than VS.
  3. IDEA is free.
  1. 已经有很多适用于 Android 的 Java 代码了。帮自己一个忙,不要重新发明轮子。
  2. IDEA 与 Visual Studio 非常相似,易于学习;它由JetBrains制造,智能感知优于VS。
  3. 想法是免费的。

I have been a C# programmer for 12 years and started developing for Android with C# but ended up jumping ship and going the Java route. The languages are so similar you really won't notice much of a learning curve.

我做了 12 年的 C# 程序员,开始使用 C# 为 Android 开发,但最终跳槽并走 Java 路线。语言是如此相似,你真的不会注意到太多的学习曲线。

P.S. If you want to use LINQ, serialization and other handy features that are native to C# then you just need to look for the equivalent java library.

PS 如果你想使用 C# 原生的 LINQ、序列化和其他方便的特性,那么你只需要寻找等效的 java 库。

回答by Sonu

I have used the Unity 3D game engine for developing games for the PC and mobile phone. We use C# in this development.

我曾使用Unity 3D游戏引擎为PC和手机开发游戏。我们在这个开发中使用 C#。