尝试构建android时Cordova错误

时间:2015-09-28 13:10:38

标签: cordova build command-line-interface

我按照这一步:

  1. npm install -g cordova
  2. cordova create hello com.lorenzo.hello hello
  3. cd hello
  4. cordova platform添加android
  5. cordova build
  6. 它给了我这个错误:

    C:\Documents and Settings\gcappella\hello>cordova build
    Running command: cmd "/s /c ""C:\Documents and Settings\gcappella\hello\platform
    s\android\cordova\build.bat"""
    ANDROID_HOME=C:\Android
    JAVA_HOME=C:\Programmi\Java\jdk1.8.0_60
    Running: C:\Documents and Settings\gcappella\hello\platforms\android\gradlew cdv
    BuildDebug -b C:\Documents and Settings\gcappella\hello\platforms\android\build.
    gradle -Dorg.gradle.daemon=true
    Downloading http://services.gradle.org/distributions/gradle-2.2.1-all.zip
    
    Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Serv
    er returned HTTP response code: 403 for URL: http://services.gradle.org/distribu
    tions/gradle-2.2.1-all.zip
            at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
    essManager.java:78)
            at org.gradle.wrapper.Install.createDist(Install.java:47)
            at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
            at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
    Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL:
     http://services.gradle.org/distributions/gradle-2.2.1-all.zip
            at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLCo
    nnection.java:1839)
            at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:1440)
            at org.gradle.wrapper.Download.downloadInternal(Download.java:59)
            at org.gradle.wrapper.Download.download(Download.java:45)
            at org.gradle.wrapper.Install$1.call(Install.java:60)
            at org.gradle.wrapper.Install$1.call(Install.java:47)
            at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
    essManager.java:65)
            ... 3 more
    Built the following apk(s):
    

1 个答案:

答案 0 :(得分:0)

@Lorenzo, 因为你最近建立了这个,它可能会被突然升级。这是你需要知道的。

来自 Phonegap Build 论坛,Petra Adds

  

我想补充一点:没有公告,PGB将默认PGB版本从3.7.0更改为cli-5.2.0。这导致所有未在config.xml中设置'phonegap-version'的人面临突然需要的泼水屏幕和白名单插件以及配置和HTML中的其他白名单规范。

     

此外,几个插件似乎无法使用cli-5.2.0正确构建,导致关于“Class ***。java”的日志文件错误消息。

FWIW: Phonegap Build admitted to as much in this tweet

在你的情况下,你有一个JAVA错误,所以这是我的线索。您需要在构建中设置版本,并且可能需要使用 white-list

来自Top Mistakes by Developers new to Cordova/Phonegap你已经点击了:

  • #6 未为您的编译器设置“phonegap版本”
  • #7 没有为您的插件设置“版本”
  • #10 未在config.xml中添加新的“white-list”和“white-list plugin”参数。

对于#6& #7

  

使用CLI版本,如果您没有为您的平台分配版本,或者如果您未在config.xml中设置phonegap-version,则在“Phonegap Build”中,您将获得最新版本。如果运气好,您的程序就会按预期运行。如果你不幸运,你会得到一组级联错误。

     

幸运的是,对于我们所有人来说,Holly Schinsky写了一篇很好的博文来解释这一切:

     

Cordova / PhoneGap版本混淆
  http://devgirl.org/2014/11/07/cordovaphonegap-version-confusion/

#10

  

这个相对*新*要求意味着 - 要访问网络上的任何网站或资源,您必须使用白名单和白名单插件。如果您使用cordova-android@4.0.0或更高版本,此要求将生效;包括cli-5.1.1。但是,如果您的版本在4.0.0之前,请使用3.5.0或3.7.0,那么必须添加 white-list 要求。< / p>      

要明确的是,“白名单”已经存在了一段时间,但插件和要求非常新。正如您所料,当添加“白名单”时,不推荐使用事实上的开放访问功能。或者说另一种方式,事实上开放访问功能已被计划并计划被淘汰。此更改标志着删除开放访问功能的一个步骤。

     

此外,内容安全策略(CSP)已经吸引了众多开发人员 - 因为它的公开性很差。这个CSP需要进入您使用的每个HTML页面,就像您必须等待'deviceready'一样。该文档隐藏在许多最新文档页面的底部。

相关链接

  

Phonegap Build Forum:Notes for upgrading to cli-5.1.1 on PGB,现在需要白名单