1

I just installed Cordova Tools for Visual Studio 2017 and created my first app. Running it in browser emulation works fine, but when I try to build an APK, it fails with the following error message:

1>MSBUILD : cordova-build error : FAILURE: Build failed with an exception.
1>MSBUILD : cordova-build error : * What went wrong:
1>MSBUILD : cordova-build error : A problem occurred configuring root project 'android'.
1>MSBUILD : cordova-build error : > Could not resolve all dependencies for configuration ':classpath'.
1>MSBUILD : cordova-build error :  > Could not resolve com.android.tools.build:gradle:2.1.0.
1>MSBUILD : cordova-build error :  Required by:
1>MSBUILD : cordova-build error :  :android:unspecified
1>MSBUILD : cordova-build error :  > Could not resolve com.android.tools.build:gradle:2.1.0.
1>MSBUILD : cordova-build error :  > Could not get resource 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.1.0/gradle-2.1.0.pom'.
1>MSBUILD : cordova-build error :  > Could not HEAD 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.1.0/gradle-2.1.0.pom'.
1>MSBUILD : cordova-build error :  > Received fatal alert: protocol_version
1>MSBUILD : cordova-build error :  > Could not resolve com.android.tools.build:gradle:2.1.0.
1>MSBUILD : cordova-build error :  > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.0/gradle-2.1.0.pom'.
1>MSBUILD : cordova-build error :  > Could not HEAD 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.0/gradle-2.1.0.pom'.
1>MSBUILD : cordova-build error :  > Connection reset
1>MSBUILD : cordova-build error : * Try:
1>MSBUILD : cordova-build error : Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Command finished with error code 1: cmd /s /c ""C:\Users\Brennced\Documents\Visual Studio 2017\Projects\SoundBoardRemote\SoundBoardRemote\platforms\android\gradlew.bat" cdvBuildRelease -b "C:\Users\Brennced\Documents\Visual Studio 2017\Projects\SoundBoardRemote\SoundBoardRemote\platforms\android\build.gradle" -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true"


1>MSBUILD : cordova-build error : Error: cmd: Command failed with exit code 1 Error output:
1>MSBUILD : cordova-build error : FAILURE: Build failed with an exception.
1>MSBUILD : cordova-build error : * What went wrong:
1>MSBUILD : cordova-build error : A problem occurred configuring root project 'android'.
1>MSBUILD : cordova-build error : > Could not resolve all dependencies for configuration ':classpath'.
1>MSBUILD : cordova-build error :  > Could not resolve com.android.tools.build:gradle:2.1.0.
1>MSBUILD : cordova-build error :  Required by:
1>MSBUILD : cordova-build error :  :android:unspecified
1>MSBUILD : cordova-build error :  > Could not resolve com.android.tools.build:gradle:2.1.0.
1>MSBUILD : cordova-build error :  > Could not get resource 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.1.0/gradle-2.1.0.pom'.
1>MSBUILD : cordova-build error :  > Could not HEAD 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.1.0/gradle-2.1.0.pom'.
1>MSBUILD : cordova-build error :  > Received fatal alert: protocol_version
1>MSBUILD : cordova-build error :  > Could not resolve com.android.tools.build:gradle:2.1.0.
1>MSBUILD : cordova-build error :  > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.0/gradle-2.1.0.pom'.
1>MSBUILD : cordova-build error :  > Could not HEAD 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.0/gradle-2.1.0.pom'.
1>MSBUILD : cordova-build error :  > Connection reset
1>MSBUILD : cordova-build error : * Try:
1>MSBUILD : cordova-build error : Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
1>MSBUILD : cordova-build error : Picked up _JAVA_OPTIONS: -Xmx512M

What is the problem and how can I fix this?

Jonas Kohl
  • 1,018
  • 1
  • 11
  • 28
  • I'm having the same issue, and from googling it seems that you have to install support for tls v1.2. I've got as far as installing Maven, but it seems I need a .pom file, which I assume comes from starting a java/maven project. I'm not sure how one installs it for the cordova build to work. Relevant links: https://blog.sonatype.com/enhancing-ssl-security-and-http/2-support-for-central, https://central.sonatype.org/articles/2018/May/04/discontinued-support-for-tlsv11-and-below/, https://stackoverflow.com/q/50824789/2953322 – Mahendran Nadesan Jul 22 '18 at 13:32

4 Answers4

1

I solved this problem by not ticking the checkbox. The figure is shown below. Go to Tools > Options > Apache Cordova Tools > Cordova Tools.

screenshot

Wei-Lun
  • 11
  • 1
  • This will only clear the cache. When it`s the first app this really should not point to the problem. TLS is defnetly discontinied and should be the problem in every fresh installation – Marc Wittmann Sep 12 '19 at 12:42
1

Solution is to upgrade to Java 1.8 By downloading the JDK then point the Java home to the java 1.8 directory That should work due to TLS1.2 and discontinued TLS1.0 and TLS 1.1 due to security. Java 1.8 support TLS1.2 https://stackoverflow.com/a/50824799/10825931

1.Download and install Java 1.8 JDK from Oracle website

2.Go to visual studio Go to Tools>Options

Go to Tools for Apache Cordova then Environment Variable Overrides

Go and set the directory of JDK 1.8 usually in Program Files/Java or Program Files(x86)/Java depending on whether 32bit or 64bit version installed and click OK

Go and build the Apk

1

Navigate Windows Explorer to your android platform folder such as "C:\vs2017\Solution1\platforms\android\cordova\lib\builders" and find the file GradleBuilder.js Look for the .ZIP entry and change it to:

add s in http

var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https://services.gradle.org/distributions/gradle-2.14.1-all.zip';

0

Navigate Windows Explorer to your android platform folder such as "C:\vs2017\Solution1\platforms\android\cordova\lib\builders" and find the file GradleBuilder.js

Look for the .ZIP entry and change it to:

var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'http\://services.gradle.org/distributions/gradle-2.14.1-all.zip';

Note the 2.14.1 version. This may not help.