如何使用 MS Visual Studio 进行 Android 开发?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1371939/
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
How can I use MS Visual Studio for Android Development?
提问by
Can you use Visual Studio for Android Development?
您可以使用 Visual Studio 进行 Android 开发吗?
If so how would you set the android SDK instead of .NET framework and are there any special settings or configuration?
如果是这样,您将如何设置 android SDK 而不是 .NET 框架,是否有任何特殊设置或配置?
回答by user1169079
Yes, you can use Visual Studio for Android (native) using "vs-android".
是的,您可以使用“vs-android”使用 Visual Studio for Android(本机)。
Here are the steps to set it up:
以下是设置它的步骤:
Download the Android SDK here.
Download the Android NDK here.
Download Cygwin here.
Download the JDK here.
Download Visual Studio 2010, 2012 or 2013 here.
Download vs-android here.
Download Apache Ant here.
Set environment variables:
在此处下载 Android SDK 。
在此处下载 Android NDK 。
在此处下载 Cygwin 。
在此处下载 JDK 。
在此处下载 Visual Studio 2010、2012 或 2013 。
在此处下载 vs-android 。
在此处下载 Apache Ant 。
设置环境变量:
(Control Panel > System > Advanced > Environment Variables)
(控制面板 > 系统 > 高级 > 环境变量)
ANDROID_HOME = <install_path>\android-sdk
ANDROID_NDK_ROOT = <install_path>\android-ndk
ANT_HOME = <install_path>\apache-ant
JAVA_HOME = <install_path>\jdk
_JAVA_OPTIONS = -Xms256m -Xmx512m
- Download examples from here.
- 从这里下载示例。
It works like a charm... and best so far to use.
它就像一个魅力......到目前为止最好使用。
回答by Erwin Coumans
Yes you can:
是的你可以:
http://www.gavpugh.com/2011/02/04/vs-android-developing-for-android-in-visual-studio/
http://www.gavpugh.com/2011/02/04/vs-android-developing-for-android-in-visual-studio/
In case you get "Unable to locate tools.jar. Expected to find it in C:\Program Files (x86)\Java\jre6\lib\tools.jar" you can add an environment variable JAVA_HOME that points to your Java JDK path, for example c:\sdks\glassfish3\jdk (restart MSVC afterwards)
如果您收到“无法找到 tools.jar。预计在 C:\Program Files (x86)\Java\jre6\lib\tools.jar 中找到它”,您可以添加一个环境变量 JAVA_HOME 指向您的 Java JDK 路径,例如 c:\sdks\glassfish3\jdk (之后重启 MSVC)
An even better solution is using WinGDB Mobile Edition in Visual Studio: it lets you create and debug Android projects all inside Visual Studio:
一个更好的解决方案是在 Visual Studio 中使用 WinGDB 移动版:它允许您在 Visual Studio 中创建和调试 Android 项目:
http://ian-ni-lewis.blogspot.com/2011/01/its-like-coming-home-again.html
http://ian-ni-lewis.blogspot.com/2011/01/its-like-coming-home-again.html
Download WinGDC for Android from http://www.wingdb.com/wgMobileEdition.htm
从http://www.wingdb.com/wgMobileEdition.htm下载适用于 Android 的 WinGDC
回答by Alex
Believe me, I've tried so hard to find a decent IDE for Android developement but I failed. I used Visual Studio for many years, and it is so hard for me to get use to the way Eclipse doing things.
相信我,我一直在努力为 Android 开发找到一个像样的 IDE,但我失败了。我使用 Visual Studio 很多年了,我很难习惯 Eclipse 做事的方式。
However, the new IntelliJ supports for Android development, it's the closest you can get.
但是,新的 IntelliJ 支持 Android 开发,这是您可以获得的最接近的。
回答by Mark Cheverton
If you're interested in producing HTML5 hybrid applications (web apps wrapped in a native container giving access to device functions), the Nomad Visual Studio extensionsupports building for android devices.
如果您有兴趣生成 HTML5 混合应用程序(包装在本机容器中的 Web 应用程序,可以访问设备功能),Nomad Visual Studio 扩展支持为 android 设备构建。
回答by Dimitar Dimitrov
From the Androiddocumentation:
从Android文档:
The recommended way to develop an Android application is to use Eclipse with the ADT plugin... However, if you'd rather develop your application in another IDE, such as IntelliJ, or in a basic editor, such as Emacs, you can do that instead.
开发 Android 应用程序的推荐方法是使用带有 ADT 插件的 Eclipse...但是,如果您更愿意在另一个 IDE(例如 IntelliJ)或基本编辑器(例如 Emacs)中开发您的应用程序,您可以这样做那个。
Currently, there are plug-ins for IntelliJ IDEA and NetBeans, but you can still use the tools in /tools to build, debug, monitor, measure and start the emulator.
目前,有 IntelliJ IDEA 和 NetBeans 的插件,但您仍然可以使用 /tools 中的工具来构建、调试、监视、测量和启动模拟器。
回答by scottrudy
Much has changed since this question was asked. Visual Studio 2013 with update 4 and Visual Studio 2015 now have integrated tools for Apache Cordovaand you can run them on a Visual Studio emulator for Android.
自从提出这个问题以来,情况发生了很大变化。Visual Studio 2013 with update 4 和 Visual Studio 2015 现在集成了 Apache Cordova 工具,您可以在Visual Studio 模拟器 for Android上运行它们。
回答by Lee Stott
Microsoft Visual Studio 2015 now has options for Android development: C++, Cordova, and C# with Xamarin. When choosing one of those Android development options, Visual Studio will also install the brand new Visual Studio Emulator for Android to use as a target for debugging your app. You can also download the emulator without needing to install Visual Studio. For more details see
Microsoft Visual Studio 2015 现在提供了用于 Android 开发的选项:C++、Cordova 和 C# with Xamarin。在选择这些 Android 开发选项之一时,Visual Studio 还将安装全新的 Visual Studio Emulator for Android 以用作调试应用程序的目标。您还可以下载模拟器而无需安装 Visual Studio。有关更多详细信息,请参阅
Visuals Studio 2015 https://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs
Visuals Studio 2015 https://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs
Visual Studio Emulator https://www.visualstudio.com/en-us/features/msft-android-emulator-vs.aspx
Visual Studio 模拟器 https://www.visualstudio.com/en-us/features/msft-android-emulator-vs.aspx
Video of features https://channel9.msdn.com/Events/Visual-Studio/Visual-Studio-2015-Final-Release-Event/Visual-Studio-Emulator-for-Android
Java Extension for Visuals Studio 2012, 2013. 2015 https://visualstudiogallery.msdn.microsoft.com/bc561769-36ff-4a40-9504-e266e8706f93
Visuals Studio 的 Java 扩展 2012、2013。2015 https://visualstudiogallery.msdn.microsoft.com/bc561769-36ff-4a40-9504-e266e8706f93
回答by Ivan Shcherbakov
That depends on what you actually want to achieve.
这取决于您实际想要实现的目标。
You want to keep on making normal Java-based Android application, but use Visual Studio for development? Then it's bad news, as Visual Studio has no built-in java support. Thus, if you use it out-of-the-box, you will lose all Java-specific Eclipse functionality (IntelliSense for Java, Java debugger, wizards, etc) as well as numerous Android plugins (that are Eclipse-specific and won't work with VS).
您想继续制作基于 Java 的普通 Android 应用程序,但使用 Visual Studio 进行开发?那么这是个坏消息,因为 Visual Studio 没有内置的 Java 支持。因此,如果您开箱即用地使用它,您将失去所有特定于 Java 的 Eclipse 功能(IntelliSense for Java、Java 调试器、向导等)以及许多 Android 插件(特定于 Eclipse 并且不会与 VS 一起工作)。
On the other hand, you can use Mono for Android to develop apps in C# in VS, but they won't look as smooth as the native apps (some functionality might be missing, look-and-feel slightly different, etc.). In that case such app could sell less than a "normal" Java app that looks and feels like all other Java apps.
另一方面,您可以使用 Mono for Android 在 VS 中使用 C# 开发应用程序,但它们看起来不如本机应用程序流畅(某些功能可能会丢失,外观略有不同等)。在这种情况下,此类应用程序的销量可能会低于外观和感觉与所有其他 Java 应用程序相似的“普通”Java 应用程序。
If you are talking about native Android code (in C/C++), such as games, the news are not as bad. As Visual Studio has no problem with C++, there are numerous ways to make it work:
如果您在谈论原生 Android 代码(在 C/C++ 中),例如游戏,那么消息并没有那么糟糕。由于 Visual Studio 对 C++ 没有问题,因此有多种方法可以使其工作:
If you only want to compile your code, you can use the free vs-androidtoolset. It's essentially a set of build rules telling Visual Studio how to launch Android compiler.
If you want to compile anddebug your native code with Visual Studio, you will need something more advanced, such as VisualGDB for Android. It can build/debug your Native code independently, or together with debugging Java code from Eclipse.
如果您只想编译代码,可以使用免费的vs-android工具集。它本质上是一组构建规则,告诉 Visual Studio 如何启动 Android 编译器。
如果要使用 Visual Studio编译和调试本机代码,则需要更高级的东西,例如VisualGDB for Android。它可以独立构建/调试您的本机代码,也可以与来自 Eclipse 的调试 Java 代码一起构建/调试。
回答by free4ride
I know this q is quite old but it might me useful:
我知道这个 q 已经很老了,但它可能对我有用:
http://blogs.nvidia.com/2013/02/nvidia-introduces-nsight-tegra-to-assist-android-developers/
http://blogs.nvidia.com/2013/02/nvidia-introduces-nsight-tegra-to-assist-android-developers/
回答by fipda
Besides, you can use VS for Android development too, because in the end, the IDE is nothing but a fancy text editor with shortcuts to command line tools, so most popular IDE's can be used.
此外,您也可以使用 VS 进行 Android 开发,因为说到底,IDE 只不过是一个带有命令行工具快捷方式的精美文本编辑器,因此可以使用大多数流行的 IDE。
However, if you want to develop fully native without restrictions, you'll have all kinds of issues, such as those related to file system case insensitivity and missing libraries on Windows platform..
但是,如果您想不受限制地开发完全本机,则会遇到各种问题,例如与文件系统不区分大小写和 Windows 平台上缺少库相关的问题。
If you try to build windows mobile apps on Linux platform, you'll have bigger problems than other way around, but still makes most sense to use Linux with Eclipse for Android OS.
如果您尝试在 Linux 平台上构建 Windows 移动应用程序,您会遇到比其他方式更大的问题,但将 Linux 与 Eclipse 用于 Android 操作系统仍然是最有意义的。