Visual Studio 2017 cordova not building apk

Viewed 3068

I'm trying to compile a cordova project to apk using Visual Studio 2017, but it gives me this message:

platform android already added

It is not generating an apk. I followed various tutorials but it's no use. I can't get it to work. What to do?

3 Answers

You have to run it on a android simulator or a android phone for it to build a APK.

For clarification: Yes you have to use a "device" that is actually running android for Visual Studio to actually build the APK, just building the solution won't work.

You can either use your phone, or the microsoft android simulators for this. Running it in the browser doesn't use the APK so VS doesn't build it.

You can find more here http://taco.visualstudio.com/en-us/docs/tutorial-package-publish-readme/#package-the-android-version-of-your-app

When you install from the Visual Studio Installer, you need to install these options as well. Then only it will build the .apk file

In the right side you can find Android SDK setup, Google Android Emulator under Optional, please enable these options and Install.

pic1

After Installation, when you build, select Debug--->Android---->Google Emulator Phone as shown in image below pic2

Responding to your question: "What to do?" There are at least two ways:

  1. If you want to have an apk of your app "without/outside Visual Studio", you may obtain this by executing this from command line: "cordova build android --release" or in debug mode "cordova build android --debug"

  2. If you want to have an apk of your app "with/inside Visual Studio", you may cancel platforms folder and rebuild your solution with Visual Studio

Related