2014-11-24 77 views
0

當我將Android項目從Eclipse遷移到Android Studio時,使用travis ci來構建項目,它有以下錯誤。git用非零退出值完成128

失敗:生成失敗並出現異常。
*其中:
構建文件 '/home/travis/build/Logan676/seadroid/app/build.gradle' 行:20
*出了什麼問題:
發生評估項目中的問題 ':應用程序'。
進程「命令'git的」完成與非零退出值128

所述的build.gradle文件是

buildscript { 
     repositories { 
      jcenter() 
     } 
     dependencies { 
      classpath 'com.android.tools.build:gradle:0.13.0' 
     } 
    } 
    apply plugin: 'com.android.application' 

    repositories { 
     jcenter() 
    } 

    /* 
    * Gets the version name from the latest Git tag 
    */ 
    def getVersionName = { -> 
     def stdout = new ByteArrayOutputStream() 
     exec { 
      // LINE 20 IS HERER!!!!!!!!!!!!! 
      commandLine 'git', 'describe', '--tags' 
      standardOutput = stdout 
     } 
     return stdout.toString().trim() 
    } 
    def getVersionCode = { -> 
     def stdout = new ByteArrayOutputStream() 
     exec { 
      commandLine 'git', 'rev-list', '--count', "HEAD" 
      standardOutput = stdout 
     } 
     return Integer.valueOf(stdout.toString().trim()) 
    } 


    dependencies { 
     compile 'com.android.support:support-v4:21.0.+' 
     compile 'com.actionbarsherlock:actionbarsherlock:[email protected]' 
     compile 'com.inkapplications.viewpageindicator:library:2.4.3' 
     compile 'com.github.kevinsawicki:http-request:5.6' 
     compile 'commons-io:commons-io:2.4' 
     compile 'com.google.guava:guava:18.0' 
     compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3' 
     compile project(':libraries:NewQuickAction') 
     compile project(':libraries:MarkdownView') 
     compile project(':libraries:PullToRefresh') 
    } 

    android { 
     compileSdkVersion rootProject.ext.compileSdkVersion 
     buildToolsVersion rootProject.ext.buildToolsVersion 

     defaultConfig { 
      minSdkVersion rootProject.ext.minSdkVersion 
      targetSdkVersion rootProject.ext.targetSdkVersion 
      versionCode getVersionCode() 
      versionName getVersionName() 
     } 

     lintOptions { 
      abortOnError false 
     } 

     signingConfigs { 
      release { 
       // Signing code for manual signing 
       //storeFile file(System.console().readLine("\n\$ Enter keystore path: ")) 
       //storePassword System.console().readPassword("\n\$ Enter keystore  password: ").toString() 
       //keyAlias System.console().readLine("\n\$ Enter key alias: ") 
       //keyPassword System.console().readPassword("\n\$ Enter key password: ").toString() 
      } 
     } 

     buildTypes { 
      release { 
       //signingConfig signingConfigs.release 
       runProguard true 
       proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt' 
      } 
     } 
    } 

我想這引起未安裝GIT中的錯誤。但我不知道如何解決它。也許它需要一些腳本來自動安裝git。所以任何人都可以幫助我修改Gradle文件,如上所示。

+0

檢查https://confluence.atlassian.com/display/FISHKB/Non-zero+exit+code%3A+128+Error+executing+command% 3A +無法+ +找到+遠程+助手+ + http – 2014-11-24 08:54:02

+0

你有沒有發現這個問題的任何修復? – 2016-03-31 12:09:33

回答

0

我趕上修訂在代碼的git命令的輸出版本屬性(代碼通用的Unix /第一EXEC /和Windows /秒的exec /,命令混帳必須從控制檯工作)

def os = System.getProperty("os.name").toLowerCase() 
def revision = new ByteArrayOutputStream() 
if (!os.contains("windows")) { 
    exec { 
     executable "/bin/sh" 
     args "-c", "echo -n `git rev-list HEAD | wc -l | sed 's/^[ ^t]*//'`" 
     standardOutput = revision; 
    } 
} else { 
    exec { 
     executable "cmd" 
     args "/c", "git rev-list HEAD | find /c /v \"\"" 
     standardOutput = revision; 
    } 
    revision = revision as String 
    revision = revision.trim() 
}; 

您可以更改代碼需要你。

0

同樣的錯誤也發生在我身上。

在以前的build.gradle類似的代碼

exec { 
     commandLine 'git', 'describe', '--tags' 
    } 

然後我'git'

前加入'cmd'和錯誤了。

下面

是碼加法的代碼之後

exec { 
     commandLine 'cmd', 'git', 'describe', '--tags' 

    } 
相關問題