gpt4 book ai didi

android - 命令git完成,退出值非零128

转载 作者:行者123 更新时间:2023-12-03 03:51:54 25 4
gpt4 key购买 nike

当我将Android项目从Eclipse迁移到Android Studio时,使用travis ci构建项目时,它具有以下错误。

FAILURE: Build failed with an exception.
* Where:
Build file '/home/travis/build/Logan676/seadroid/app/build.gradle' line: 20
* What went wrong:
A problem occurred evaluating project ':app'.
Process 'command 'git'' finished with non-zero exit value 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:4.4.0@aar'
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文件。

最佳答案

我从代码中的git命令输出中捕获了修订属性中的修订(unix / first exec /和windows / second exec /的通用代码,命令git必须从控制台运行)

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()
};

您可以根据需要更改代码。

关于android - 命令git完成,退出值非零128,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27100088/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com