简体   繁体   中英

Visual Studio 2022 How to add android support to my C++ project

I was wondering how would I add android support to my c++ project? That is where do I put android manifest? How to edit it(android manifest) through c++ when choosing option for example to build for android. How to build apk and windows exe at the same time?

I am sorry I've been thinking about this and I can't wrap my head around game engines having the button "Export to Android". Can someone please show me the simple way or where can I learn that?

To clarify I am not making a game engine I am just trying to learn how to do this.

Getting Started

Getting your head around android development can be a bit difficult because there are so many moving parts. This question is kind off broad, what graphics API are you using(openGL ES, Vulkan, etc). I'm going to assume you are using openGL ES or Vulkan and as a window/input manager something like SDL2(my preference for cross-platform). Here's a list of things to get started.

Gradle

Gradle is a great build automation tool that you can use from the command-line but android studio all ready includes this (and a bunch of other helpful tools). It's used in all of the tutorials below and is great because it's fast, general-purpose, flexible and has great IDE support.

Architecture

There are a million ways to design your application to be cross-platform but a general rule is to isolate API and platform specific systems(like the renderer or window manager). And to answer your question of how engines can have a "Export to Android" button they probably just use an automated build system like gradle to generate the apk file. The engine itself is probably compiled ahead of time as a android library file that is linked to the engine runtime(the game).

A good folder structure might look something like this:

Solution
  + Engine
    + Core 
    + Platforms
    + Vendor  
  + Project
    + Game

Tutorials

A Good Tutorial For A Baisic Cross-Platform Framework In C++

Android Vulkan Tutorials By Google

Gradle Docs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM