Build error for ionic project on mac os for unable to find valid certification path to requested target

#1

Getting following error for ionic cordova android build

[20:08:54] lint finished in 7.78 s

cordova build android Android Studio project detected ANDROID_HOME=/Users/user/Library/Android/sdk JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home studio Subproject Path: CordovaLib Subproject Path: app Downloading https://services.gradle.org/distributions/gradle-4.1-all.zip

Exception in thread “main” javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Ionic:

ionic (Ionic CLI) : 4.0.6 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.11

Cordova:

cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.0.0

System:

Android SDK Tools : 26.1.1
ios-deploy : 1.5.0
ios-sim : 3.1.1
NodeJS : v8.11.3 (/usr/local/bin/node)
npm : 5.6.0
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b

Environment:

ANDROID_HOME : /Users/nd/Library/Android/sdk