当我运行命令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
答案 0 :(得分:0)
您确实必须添加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()
存储库添加到所有项目中。