Visual Studio supports writing C++ code that targets Android and iOS mobile platforms from a single Windows development environment. The Mobile development with C++ workload installs the Android NDK, the Android SDK, Apache Ant, and Clang toolsets so you can create, build, debug, and deploy Android Native Activity apps and shared libraries directly from the Visual Studio IDE. For iOS, the workload includes tools to connect to a Mac build host running Xcode.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MicrosoftDocs/cpp-docs/llms.txt
Use this file to discover all available pages before exploring further.
Installing the Mobile Development with C++ Workload
Open Visual Studio Installer
Run the Visual Studio Installer from the Start menu. Click Modify next to your Visual Studio installation.
Select the workload
On the Workloads tab, find and select Mobile development with C++. The workload automatically includes:
- Android Native Development Kit (NDK)
- Android SDK with platform tools
- Apache Ant (build system for legacy Android projects)
- GCC and Clang toolsets for Android ABIs
- C++ Android development templates
- C++ iOS development tools (for connecting to a Mac)
Select optional components
In the Installation details pane, expand Mobile development with C++ → Optional to add:
- Additional Android NDK versions
- Google Android Emulator
- Intel Hardware Accelerated Execution Manager (HAXM) — for fast x86 emulation on Intel CPUs
- IncrediBuild for parallel builds
Android NDK and SDK Setup
After installation, Visual Studio manages the NDK and SDK paths automatically. To verify or change them:- Go to Tools → Options → Cross Platform → C++ → Android.
- The dialog shows the detected paths for:
- Android NDK — the toolchain directory (e.g.,
C:\Microsoft\AndroidNDK\android-ndk-r25c) - Android SDK — the SDK root (e.g.,
C:\Program Files (x86)\Android\android-sdk) - Java SE Development Kit — required for the Android build process
- Android NDK — the toolchain directory (e.g.,
Some Android NDK tools do not support Unicode characters in file paths. Ensure your project directory and source file names use only ASCII characters to avoid build failures.
Creating an Android Native Activity App
The Native Activity Application (Android) template generates a fully functional Android app written in C++ using the Android NativeActivity API. NativeActivity allows the majority of your app to be pure C/C++ code, with only a thin Java glue layer.Create the project
Go to File → New → Project. In the Create a new project dialog, search for Native-Activity Application (Android) and select it. Click Next, give your project a name (e.g.,
MyAndroidApp), and click Create.Explore the solution
Visual Studio creates two projects:
- MyAndroidApp.NativeActivity — contains
main.cppwith the C++ entry point (android_main), precompiled headers, and NDK glue code. This project compiles to a shared library (.sofile). - MyAndroidApp.Packaging — contains
AndroidManifest.xml, resources, and the Antbuild.xml. This is the startup project that creates the.apkfor deployment.
Select a target platform
From the Solution Platforms dropdown, choose x86 (for emulator) or ARM / ARM64 (for physical devices).
Android Native Activity Code Structure
The generatedmain.cpp follows the Android NativeActivity pattern:
AndroidManifest.xml declares the NativeActivity:
Debugging Android C++ in Visual Studio
When you press F5 with an Android project, Visual Studio:- Compiles the C++ code with the NDK’s
clang++for the selected ABI. - Packages the
.sointo an.apkusing the Android SDK tools. - Deploys the
.apkto the emulator or connected device via ADB. - Attaches LLDB (on newer NDK versions) or GDB as the native debugger.
Building for iOS with Clang on a Mac
Building for iOS requires a Mac running Xcode (version 10.2 or later) because Apple’s build tools and code signing infrastructure run only on macOS. Visual Studio connects to the Mac over the network to perform the actual compilation.Set up vcremote on the Mac
On your Mac, install the Note the host name, port, and security PIN displayed — you will need them in Visual Studio.
vcremote agent via npm (do not use sudo — see the vcremote prerequisites):Configure the remote connection in Visual Studio
In Visual Studio, go to Tools → Options → Cross Platform → C++ → iOS. Enter:
- Host name: IP address or hostname of the Mac
- Port:
3030(default vcremote port) - PIN: The PIN shown when you started vcremote
Supported Android ABIs and API Levels
The NDK supports multiple CPU architectures. Configure the target ABI in Project Properties → General → Target Architecture:| ABI | Target Devices | Notes |
|---|---|---|
x86 | Android emulator (Intel) | Fast emulation via HAXM/AEHD |
x86_64 | Android emulator (Intel) | 64-bit emulation |
armeabi-v7a | 32-bit ARM devices | Minimum API level 16 |
arm64-v8a | 64-bit ARM devices | Required for 64-bit APKs (Play Store policy) |
The Google Play Store requires that APKs targeting API level 26 and above include a 64-bit (
arm64-v8a) native library. Build a multi-ABI APK by specifying multiple architectures in your project configuration.