![](/img/trans.png)
[英]React Native FAILURE: Build failed with an exception. Could not resolve ':classpath'. Could not find com.android.tools.build:gradle:3.0.1
[英]Cordova build failed with an exception: Could not resolve com.android.tools.build:gradle:3.0.0
當我運行命令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僅在jcenter
和maven
存儲庫中搜索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()
存儲庫添加到所有項目中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.