0

This is my stacktrace after ionic build android, after the simple three steps to begin working with ionic:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:2.1.0.
     Required by:
         :android:unspecified
      > Could not resolve com.android.tools.build:gradle:2.1.0.
         > Could not get resource 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.1.0/gradle-2.1.0.pom'.
            > Could not GET 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.1.0/gradle-2.1.0.pom'.
               > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      > Could not resolve com.android.tools.build:gradle:2.1.0.
         > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.0/gradle-2.1.0.pom'.
            > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.0/gradle-2.1.0.pom'.
               > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

All the code is the default code coming with $ ionic start myApp tabs

I tried to change gradle version, update cordova. I've also tried to add this lines in build.gradle:

repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }

I also did that, just in case: When running the "Cordova build android" I'm getting the below exception

Community
  • 1
  • 1
danieltellez
  • 206
  • 1
  • 11

2 Answers2

0

I had the same problem and I resolve it installing manually gradle.

https://gradle.org/gradle-download/

I made these commands:

curl -s https://get.sdkman.io | bash

sdk install gradle 2.1 # Changing 3.1 version to 2.1

I had to restart my computer to get the paths configured correctly. Previously I checked that it was configured correctly java and his paths but I don't think it has been important to solve it.

Draken
  • 3,134
  • 13
  • 34
  • 54
0

It's now 2023 and I was still getting this error when running a project via the Ionic VS Code plug in. The problem is that I have Gradle 8.0.2 installed yet the plug is expecting Gradle 8.0.0 and keeps updating the project build file accordingly.

The solution:

  • Update the Gradle class path dependency in /android/build.gradle to the installed version.
  • Run the project from the command line using: ionic capacitor run android --external

To enable live reload, add the --livereload or -l parameter to the ionic command.

To make life easy, I've added 'android' and 'android:live' scripts to my package.json file.

SteveC
  • 644
  • 7
  • 12