PhoneGap-无法解析com.android.tools.build:gradle:3.0.1

时间:2019-01-14 14:18:18

标签: gradle android-gradle phonegap

我正在尝试使用Cordova(PhoneGap)构建一个android-app,但是在构建过程中出现了异常:

   BUILD FAILED in 11s

cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all files for configuration ':classpath'.
 > Could not resolve com.android.tools.build:gradle:3.0.1.
 Required by:
     project :
  > Could not resolve com.android.tools.build:gradle:3.0.1.
     > Could not get resource 'https://maven.google.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
        > Could not HEAD 'https://maven.google.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
           > maven.google.com
  > Could not resolve com.android.tools.build:gradle:3.0.1.
     > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
        > Could not HEAD 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
           > jcenter.bintray.com

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

渐变文件

  buildscript {
repositories {
    maven {
        url "https://maven.google.com"
    }
    jcenter()
    google()
}
dependencies {

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.android.tools.build:gradle:3.2.1'
}
}

allprojects {
repositories {
    maven {
        url "https://maven.google.com"
    }
    jcenter()
}
//This replaces project.properties w.r.t. build settings
project.ext {
  defaultBuildToolsVersion="27.0.1" //String
  defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
  defaultTargetSdkVersion=27 //Integer - We ALWAYS target the latest by  default
  defaultCompileSdkVersion=27 //Integer - We ALWAYS compile with the   latest by default
}
}

task clean(type: Delete) {
delete rootProject.buildDir
 }

什么原因导致此异常,我该如何解决?似乎Cordova正在寻找较旧版本的gradle-我可以在某处更改它吗?

1 个答案:

答案 0 :(得分:0)

尝试创建一个新项目,看看是否遇到相同的错误。

如果仍然失败,请尝试更新您的cordova版本。

npm update -g cordova