2016-11-29 253 views
1

我有一個Ionic/Cordova項目,爲Android構建是用Gradle完成的。如何使用Gradle構建的Android Cordova項目離線構建?

我安裝了所有必要的Android SDK和項目建設精細多月,但今天它失敗,出現以下錯誤:

Running: d:\git\myproject\platforms\android\gradlew cdvBuildDebug -b d:\git\myproject\platforms\android\build.gradle -Dorg.gradle.daemon=true 

FAILURE: Build failed with an exception. 

* What went wrong: 
A problem occurred configuring root project 'android'. 
> Could not resolve all dependencies for configuration ':classpath'. 
    > Could not resolve com.android.tools.build:gradle:1.0.0+. 
    Required by: 

BUILD FAILED 

Total time: 26.792 secs 
     :android:unspecified 
     > Failed to list versions for com.android.tools.build:gradle. 
     > Unable to load Maven meta-data from https://repo1.maven.org/maven2/com/android/tools/build/gradle/maven-metadata.xml. 
      > Could not GET 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/maven-metadata.xml'. 
       > Connection to https://repo1.maven.org refused 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

d:\git\myproject\platforms\android\cordova\node_modules\q\q.js:126 
        throw e; 
        ^
Error code 1 for command: cmd with args: /s /c "d:\git\myproject\platforms\android\gradlew cdvBuildDebug -b d:\git\myproject\platforms\android\build.gradle -Dorg.gradle.daemon=true" 
Error: cmd: Command failed with exit code 1 
Cordova command failed with error code 1, aborting! 

顯然,由於該項目是建築就好了幾個月,一切需要讓它構建已經在磁盤上,但構建可能會檢查Maven回購中是否有更新的工件版本,並且這是失敗的。

有時這不是一個非常期望的行爲。

是否可以將構建配置爲始終離線構建?

回答

0

所以我grepped我的回購爲com.android.tools.build:gradle,我發現它在幾個文件:

D:\git\myproject\platforms\android\build.gradle\build.gradle 
D:\git\myproject\platforms\android\cordova\lib\plugin-build.gradle\plugin-build.gradle 
D:\git\myproject\platforms\android\CordovaLib\build.gradle\build.gradle 

我改變

dependencies { 
    classpath 'com.android.tools.build:gradle:1.0.0+' 
} 

dependencies { 
    classpath 'com.android.tools.build:gradle:1.0.0' 
} 

希望這解決了我的問題,儘管現在問題已經消失,即使1.0.0+,所以我不能很容易地驗證。

您可以在檢查你有本地可用其中com.android.tools.build:gradle確切版本在以下文件夾在Windows上:

$HOME\.gradle\caches\modules-2\files-2.1\com.android.tools.build\gradle 
相關問題