如何在Visual Studio Team Services上设置Android构建

时间:2018-07-28 19:44:18

标签: android azure-devops azure-pipelines gradlew

我对VSTS和整个Microsoft Online Services平台还很陌生。

尝试在VSTS存储库上初始化构建时遇到问题。我已经从下拉菜单中选择了默认的Android构建设置,但是它不起作用。每次尝试构建时,我都进入gradlew build阶段,并且收到错误消息:Error: D:\a\1\s\gradlew.bat failed with return code: 1

我可以使用android Studio IDE构建代码,但是现在我需要使用VSTS。 ` 任何帮助将非常感激。谢谢!

编辑:这是构建的完整日志

2018-07-28T19:23:31.6824618Z ##[section]Starting: gradlew build
2018-07-28T19:23:31.6830050Z ==============================================================================
2018-07-28T19:23:31.6830213Z Task         : Gradle
2018-07-28T19:23:31.6830359Z Description  : Build using a Gradle wrapper script
2018-07-28T19:23:31.6830487Z Version      : 2.137.1
2018-07-28T19:23:31.6830608Z Author       : Microsoft Corporation
2018-07-28T19:23:31.6830766Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613720)
2018-07-28T19:23:31.6830930Z ==============================================================================
2018-07-28T19:23:33.2899535Z SonarQube analysis is enabled.
2018-07-28T19:23:33.2900156Z Checkstyle analysis is enabled.
2018-07-28T19:23:33.2900406Z FindBugs analysis is enabled.
2018-07-28T19:23:33.2900654Z PMD analysis is enabled.
2018-07-28T19:23:33.2900905Z SYSTEMVSSCONNECTION exists true
2018-07-28T19:23:33.2901941Z [command]C:\Windows\system32\cmd.exe /D /S /C "D:\a\1\s\gradlew.bat build sonarqube -I D:\a\_tasks\Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4\2.137.1\node_modules\codeanalysis-common\checkstyle.gradle -I D:\a\_tasks\Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4\2.137.1\node_modules\codeanalysis-common\findbugs.gradle -I D:\a\_tasks\Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4\2.137.1\node_modules\codeanalysis-common\pmd.gradle"
2018-07-28T19:24:05.3436260Z Downloading https://services.gradle.org/distributions/gradle-4.6-all.zip
2018-07-28T19:24:29.2233239Z Unzipping C:\Users\VssAdministrator\.gradle\wrapper\dists\gradle-4.6-all\bcst21l2brirad8k2ben1letg\gradle-4.6-all.zip to C:\Users\VssAdministrator\.gradle\wrapper\dists\gradle-4.6-all\bcst21l2brirad8k2ben1letg
2018-07-28T19:25:41.8632779Z Starting a Gradle Daemon (subsequent builds will be faster)

{我们使用的软件包的一系列下载,出于字符限制的考虑而省略}

2018-07-28T19:26:20.6092629Z Applying the Checkstyle plugin to project s
2018-07-28T19:26:20.6792218Z Applying the FindBugs plugin to project s
2018-07-28T19:26:20.6792841Z Applying the PMD plugin to all projects
2018-07-28T19:26:23.9485033Z Applying the Checkstyle plugin to project volve
2018-07-28T19:26:23.9621010Z Applying the FindBugs plugin to project volve
2018-07-28T19:26:23.9621425Z Applying the PMD plugin to all projects
2018-07-28T19:26:28.6406403Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6407012Z support library package not found: android.support.constraint.motion.
2018-07-28T19:26:28.6407656Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6407994Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6408285Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6408525Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6408784Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6409785Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6410031Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6410325Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6410567Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6410830Z support library package not found: android.support.constraint.
2018-07-28T19:26:39.5509667Z Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
2018-07-28T19:26:39.6403284Z registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
2018-07-28T19:26:39.7610924Z registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
2018-07-28T19:26:39.7830309Z Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
2018-07-28T19:26:39.7922748Z registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
2018-07-28T19:26:39.8933520Z registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
2018-07-28T19:26:39.9253837Z 
2018-07-28T19:26:39.9254479Z FAILURE: Build failed with an exception.
2018-07-28T19:26:39.9254716Z 
2018-07-28T19:26:39.9254905Z * What went wrong:
2018-07-28T19:26:39.9255123Z Task 'sonarqube' not found in root project 's'.
2018-07-28T19:26:39.9255269Z 
2018-07-28T19:26:39.9255429Z * Try:
2018-07-28T19:26:39.9255675Z Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
2018-07-28T19:26:39.9255897Z 
2018-07-28T19:26:39.9256078Z * Get more help at https://help.gradle.org
2018-07-28T19:26:39.9256222Z 
2018-07-28T19:26:39.9256413Z BUILD FAILED in 2m 49s
2018-07-28T19:26:40.5195018Z Error: D:\a\1\s\gradlew.bat failed with return code: 1
2018-07-28T19:26:40.5195970Z     at ChildProcess.<anonymous> (D:\a\_tasks\Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4\2.137.1\node_modules\vsts-task-lib\toolrunner.js:569:30)
2018-07-28T19:26:40.5196934Z     at emitTwo (events.js:106:13)
2018-07-28T19:26:40.5197445Z     at ChildProcess.emit (events.js:191:7)
2018-07-28T19:26:40.5198292Z     at maybeClose (internal/child_process.js:886:16)
2018-07-28T19:26:40.5198771Z     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
2018-07-28T19:26:40.6483964Z ##[warning]No test result files matching D:\a\1\s\**\TEST-*.xml were found, so publishing JUnit test results is being skipped.
2018-07-28T19:26:40.6494902Z ##[error]Error: D:\a\1\s\gradlew.bat failed with return code: 1
2018-07-28T19:26:40.6541754Z ##[section]Finishing: gradlew build

1 个答案:

答案 0 :(得分:1)

您可以使用 Android构建模板在VSTS中构建Android项目。

enter image description here

Gradle任务的详细配置,如下所示:

  • 渐变包装:NextInt: LongSummaryStatistics{count=20, sum=6793762162, min=315793916, average=339688108.100000, max=618922475} Split: LongSummaryStatistics{count=20, sum=26073528, min=740860, average=1303676.400000, max=5724370} 文件的相对路径
  • 工作目录:<?php # /* $ php -f db-connect-test.php */ echo"preparing to connect"; $dbname = '#########'; $dbuser = '#########'; $dbpass = '#########'; $dbhost = 'localhost'; $connect = @mysqli_connect($dbhost, $dbuser, $dbpass, $dbname) or die("Unable to Connect to '$dbhost'"); echo"<html>"; echo"<title>test page</title>"; echo"<body>"; echo"<h2> test page</h2>"; /* check connection */ if ($conn->connect_error) { die("Connection failed: " . mysqli_connect_error()); } else{ echo"Successfully Connected <p>"; } if(mysqli_ping($connection)){ echo "got it<p>"; } $sql = "SELECT * FROM `announcements`"; $result = mysqli_query($dbname, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { echo 'date: ' . $row['date'] . '\tTitle: ' . $row['title'] . '\tBody: ' . $row['body'] .'<br />'; } } else { echo "0 results<p>"; $sql = "SHOW TABLES"; $result = mysqli_query($dbname, $sql); if (!$result) { echo "DB Error, could not list tables<p>"; echo 'MySQL Error: ' . mysqli_error(); } else{ while ($row = mysqli_fetch_row($result)) { echo "Table: {$row[0]}<p>"; } } } $conn->close(); echo"</body>"; echo"</html>"; ?> 文件所在的目录。默认情况下,它使用gradlew目录。
  • 任务:构建

就像android项目的文件结构为intro_android_demo(回购根目录中的gradlew文件)一样,Gradle任务配置应如下所示:

enter image description here