gpt4 book ai didi

android - Cordova 构建失败,但出现以下异常:无法解析com.android.tools.build:gradle:3.0.0

转载 作者:行者123 更新时间:2023-12-03 05:42:59 25 4
gpt4 key购买 nike

当我运行命令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并再次安装它们。我也已经尝试过在我的cordova项目的build.gradle文件中添加google()。
请帮助我解决问题。

提前致谢。

温暖的问候,
Kunj Bihari Shukla

最佳答案

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

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

  • 在“文档”目录下找到.gradle文件夹。通常位于:C:\Users\<YOUR_USER_NAME>\.gradle
  • 在该文件夹中创建一个文件init.gradle:C:\Users\<YOUR_USER_NAME>\.gradle\init.gradle
  • 在该文件上粘贴以下代码:
    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()存储库添加到所有项目中。

    关于android - Cordova 构建失败,但出现以下异常:无法解析com.android.tools.build:gradle:3.0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51595572/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com