【问题标题】:Cordova build failed with an exception: Could not resolve com.android.tools.build:gradle:3.0.0Cordova 构建失败并出现异常:无法解析 com.android.tools.build:gradle:3.0.0
【发布时间】:2018-07-30 13:53:27
【问题描述】:

当我运行命令 Cordova compile android 或 cordova build 时,我在 CMD 上遇到错误。

D:\Cordova\NewCordova\hogya>cordova compile android
Android Studio project detected
ANDROID_HOME=C:\Users\29556\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131
studio
Subproject Path: CordovaLib
Subproject Path: app
Downloading https://services.gradle.org/distributions/gradle-4.1-all.zip
................................................................................
.....
Unzipping C:\Users\29556\.gradle\wrapper\dists\gradle-4.1-all\bzyivzo6n839fup2jb
ap0tjew\gradle-4.1-all.zip to C:\Users\29556\.gradle\wrapper\dists\gradle-4.1-al
l\bzyivzo6n839fup2jbap0tjew
Starting a Gradle Daemon, 1 busy and 1 incompatible and 1 stopped Daemons could
not be reused, use --status for details

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> Could not resolve all files for configuration ':CordovaLib:classpath'.
   > Could not resolve com.android.tools.build:gradle:3.0.0.
     Required by:
         project :CordovaLib
      > Could not resolve com.android.tools.build:gradle:3.0.0.
         > Could not get resource 'https://jcenter.bintray.com/com/android/tools
/build/gradle/3.0.0/gradle-3.0.0.pom'.
            > Could not HEAD 'https://jcenter.bintray.com/com/android/tools/buil
d/gradle/3.0.0/gradle-3.0.0.pom'.
               > Connect to 10.6.13.208:8080 [/10.6.13.208] failed: Connection t
imed out: connect
      > Could not resolve com.android.tools.build:gradle:3.0.0.
         > Could not get resource 'https://maven.google.com/com/android/tools/bu
ild/gradle/3.0.0/gradle-3.0.0.pom'.
            > Could not HEAD 'https://maven.google.com/com/android/tools/build/g
radle/3.0.0/gradle-3.0.0.pom'.
               > Connect to 10.6.13.208:8080 [/10.6.13.208] failed: Connection t
imed out: connect
   > Could not resolve com.github.dcendents:android-maven-gradle-plugin:1.5.
     Required by:
         project :CordovaLib
      > Could not resolve com.github.dcendents:android-maven-gradle-plugin:1.5.
         > Could not get resource 'https://jcenter.bintray.com/com/github/dcende
nts/android-maven-gradle-plugin/1.5/android-maven-gradle-plugin-1.5.pom'.
            > Could not GET 'https://jcenter.bintray.com/com/github/dcendents/an
droid-maven-gradle-plugin/1.5/android-maven-gradle-plugin-1.5.pom'.
               > Connect to 10.6.13.208:8080 [/10.6.13.208] failed: Connection t
imed out: connect
      > Could not resolve com.github.dcendents:android-maven-gradle-plugin:1.5.
         > Could not get resource 'https://maven.google.com/com/github/dcendents
/android-maven-gradle-plugin/1.5/android-maven-gradle-plugin-1.5.pom'.
            > Could not GET 'https://maven.google.com/com/github/dcendents/andro
id-maven-gradle-plugin/1.5/android-maven-gradle-plugin-1.5.pom'.
               > Connect to 10.6.13.208:8080 [/10.6.13.208] failed: Connection t
imed out: connect

* 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

BUILD FAILED in 6m 16s
(node:5548) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with ex
it code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> Could not resolve all files for configuration ':CordovaLib:classpath'.
   > Could not resolve com.android.tools.build:gradle:3.0.0.
     Required by:
         project :CordovaLib
      > Could not resolve com.android.tools.build:gradle:3.0.0.
         > Could not get resource 'https://jcenter.bintray.com/com/android/tools
/build/gradle/3.0.0/gradle-3.0.0.pom'.
            > Could not HEAD 'https://jcenter.bintray.com/com/android/tools/buil
d/gradle/3.0.0/gradle-3.0.0.pom'.
               > Connect to 10.6.13.208:8080 [/10.6.13.208] failed: Connection t
imed out: connect
      > Could not resolve com.android.tools.build:gradle:3.0.0.
         > Could not get resource 'https://maven.google.com/com/android/tools/bu
ild/gradle/3.0.0/gradle-3.0.0.pom'.
            > Could not HEAD 'https://maven.google.com/com/android/tools/build/g
radle/3.0.0/gradle-3.0.0.pom'.
               > Connect to 10.6.13.208:8080 [/10.6.13.208] failed: Connection t
imed out: connect
   > Could not resolve com.github.dcendents:android-maven-gradle-plugin:1.5.
     Required by:
         project :CordovaLib
      > Could not resolve com.github.dcendents:android-maven-gradle-plugin:1.5.
         > Could not get resource 'https://jcenter.bintray.com/com/github/dcende
nts/android-maven-gradle-plugin/1.5/android-maven-gradle-plugin-1.5.pom'.
            > Could not GET 'https://jcenter.bintray.com/com/github/dcendents/an
droid-maven-gradle-plugin/1.5/android-maven-gradle-plugin-1.5.pom'.
               > Connect to 10.6.13.208:8080 [/10.6.13.208] failed: Connection t
imed out: connect
      > Could not resolve com.github.dcendents:android-maven-gradle-plugin:1.5.
         > Could not get resource 'https://maven.google.com/com/github/dcendents
/android-maven-gradle-plugin/1.5/android-maven-gradle-plugin-1.5.pom'.
            > Could not GET 'https://maven.google.com/com/github/dcendents/andro
id-maven-gradle-plugin/1.5/android-maven-gradle-plugin-1.5.pom'.
               > Connect to 10.6.13.208:8080 [/10.6.13.208] failed: Connection t
imed out: connect

* 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

BUILD FAILED in 6m 16s
    at ChildProcess.whenDone (D:\Cordova\NewCordova\hogya\platforms\android\cord
ova\node_modules\cordova-common\src\superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:5548) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This
error originated either by throwing inside of an async function without a catch
block, or by rejecting a promise which was not handled with .catch(). (rejection
 id: 1)
(node:5548) [DEP0018] DeprecationWarning: Unhandled promise rejections are depre
cated. In the future, promise rejections that are not handled will terminate the
 Node.js process with a non-zero exit code.`    

我已经尝试卸载cordova 和ANdroid studio 并再次安装它们。我也已经尝试在我的科尔多瓦项目的 build.gradle 文件中添加 google() 。 请帮我解决问题。

提前致谢。

热烈的问候, 昆吉·比哈里·舒克拉

【问题讨论】:

    标签: android cordova android-studio gradle sapui5


    【解决方案1】:

    您确实必须将google() 添加为存储库。根据您的日志,似乎 gradle 仅在 jcentermaven 存储库中搜索 gradle 插件,并且他们没有该插件(至少在那个版本上)。

    一种选择是将 google() 添加到 init.gradle

    1. 在“Documents”目录下找到.gradle文件夹。它通常位于:C:\Users\<YOUR_USER_NAME>\.gradle

    2. 在该文件夹中创建一个文件init.gradleC:\Users\<YOUR_USER_NAME>\.gradle\init.gradle

    3. 在该文件上粘贴以下代码:

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

    这是解决该问题的一种方法...这样,您可以将 google()jcenter()maven() 存储库添加到您的所有项目中。

    【讨论】:

    • 感谢@W0rmH0le 现在我的构建成功了
    猜你喜欢
    • 2018-05-07
    • 2016-05-28
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 2021-11-11
    相关资源
    最近更新 更多