Update Tools For Apache Cordova in Visual Studio

1.7k views Asked by At

I am new to apache cordova and i'm trying to build a client app for my asp.net mvc website, using apache cordova in visual studio. but visual studio 2017 tools for apache cordova installs cordova 6.3.1 and some plugins like onesignal can't work on it. Could you please help me?

1

There are 1 answers

1
andreszs On

That is a known issue but it can be fixed following these steps:

Assuming you have already installed Cordova 7.1.0 gobally using npm install -g [email protected]

In Visual Studio 2017 go to File > New > Project > Blank App (Apache Cordova)

Open config.xml in View Code mode and find this:

<vs:toolsetVersion>6.3.1</vs:toolsetVersion>
<engine name="android" spec="5.2.1" />

Replace with:

<vs:toolsetVersion>7.1.0</vs:toolsetVersion>
<engine name="android" spec="6.3.0" />

Where 7.1.0 is your global Cordova version.

Note how cordova-android has been increased to 6.3.0 as well.

Feel free to try using cordova-android 6.4.0 or cordova-android 7.0.0, however they may or may not introduce some issues (with Gradle for example). I have tested 6.3.0 but certain plugins may require a newer version.

Select Device as target.

Now Build > Build Solution

Save, close and reload the project. When you access config.xml in designer mode you'll see Global Cordova 7.1.0 as the selected toolset.

enter image description here

In order to build you may need to use the external Android SDK Build Tools (API 26) instead of the ones provided by Visual Studio (API 25).

enter image description here

Use the Android SDK Manager to manage versions, no need to get Android Studio for this.

enter image description here

Remember to follow the guidelines from Microsoft when changing the CLI on existing projects. However I strongly recommend creating a new one and then importing your files and adding your plugins to avoid potential problems.