cordova build android 失败

cordova build android 失败,已解决。

命令:

cordova build android;

cordova 编译失败,错误信息如下:

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 download commons-lang.jar (commons-lang:commons-lang:2.4)
      > Could not get resource 'https://jcenter.bintray.com/commons-lang/commons                                                                                                              -lang/2.4/commons-lang-2.4.jar'.
         > Could not HEAD 'https://jcenter.bintray.com/commons-lang/commons-lang                                                                                                              /2.4/commons-lang-2.4.jar'.
            > Connect to d29vzk4ow07wi7.cloudfront.net:443 [d29vzk4ow07wi7.cloud                                                                                                              front.net/143.204.132.159, d29vzk4ow07wi7.cloudfront.net/143.204.132.57, d29vzk4                                                                                                              ow07wi7.cloudfront.net/143.204.132.53, d29vzk4ow07wi7.cloudfront.net/143.204.132                                                                                                              .100] failed: Read timed out

* 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 2m 9s
(node:19192) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with e                                                                                                              xit 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 download commons-lang.jar (commons-lang:commons-lang:2.4)
      > Could not get resource 'https://jcenter.bintray.com/commons-lang/commons                                                                                                              -lang/2.4/commons-lang-2.4.jar'.
         > Could not HEAD 'https://jcenter.bintray.com/commons-lang/commons-lang                                                                                                              /2.4/commons-lang-2.4.jar'.
            > Connect to d29vzk4ow07wi7.cloudfront.net:443 [d29vzk4ow07wi7.cloud                                                                                                              front.net/143.204.132.159, d29vzk4ow07wi7.cloudfront.net/143.204.132.57, d29vzk4                                                                                                              ow07wi7.cloudfront.net/143.204.132.53, d29vzk4ow07wi7.cloudfront.net/143.204.132                                                                                                              .100] failed: Read timed out

* 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 2m 9s
    at ChildProcess.whenDone (D:\WordSpaces\cordova\hello\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:19192) 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(). (rejectio                                                                                                              n id: 1)
(node:19192) [DEP0018] DeprecationWarning: Unhandled promise rejections are depr                                                                                                              ecated. In the future, promise rejections that are not handled will terminate th                                                                                                              e Node.js process with a non-zero exit code.

解决办法:

修改 \platforms\android\CordovaLib目录下的 build.gradle 文件:

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

改成

repositories {
        jcenter{url "http://jcenter.bintray.com/"}
        maven {
            url "https://maven.google.com"
        }
    }

再重新编译成功!

...... 
BUILD SUCCESSFUL in 3m 28s
47 actionable tasks: 47 executed
Built the following apk(s):
        xx\hello\platforms\android\app\build\outputs\apk\debug\app-debug.apk

你可能感兴趣的:(cordova build android 失败)