gradle Azure devops -未找到SDK位置,使用ANDROID_SDK_ROOT环境定义位置

oewdyzsn  于 11个月前  发布在  Android
关注(0)|答案(1)|浏览(112)

我得到下面的错误,而试图在一个自我托管的Ubuntu代理运行Android应用程序.我得到这个错误,因为Android SDK是不存在于Ubuntu代理?如果是这样,有没有任何解决办法?我没有得到这个问题,而同一个应用程序在macos代理运行.
任何帮助都非常感谢

2022-07-28T23:36:24.0840286Z ##[section]Starting: Build Task
2022-07-28T23:36:24.0850273Z ==============================================================================
2022-07-28T23:36:24.0850626Z Task         : Gradle
2022-07-28T23:36:24.0850911Z Description  : Build using a Gradle wrapper script
2022-07-28T23:36:24.0851183Z Version      : 3.205.0
2022-07-28T23:36:24.0851592Z Author       : Microsoft Corporation
2022-07-28T23:36:24.0851981Z Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/gradle
2022-07-28T23:36:24.0852397Z ==============================================================================
2022-07-28T23:36:24.4320361Z ##[warning]Used 'chmod' method for gradlew file to make it executable.
2022-07-28T23:36:24.4933143Z [command]/azp/_work/1/s/gradlew assembleDebug
2022-07-28T23:36:25.2820472Z Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details
2022-07-28T23:36:33.1825697Z 
2022-07-28T23:36:33.1828123Z > Configure project :app
2022-07-28T23:36:33.1831681Z WARNING: DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.dataBinding'.
2022-07-28T23:36:33.1834823Z It will be removed in version 5.0 of the Android Gradle plugin.
2022-07-28T23:36:33.1836236Z VersionCode is set to 999
2022-07-28T23:36:33.1837886Z releaseVersion is set to 1.1.0
2022-07-28T23:36:33.2796793Z WARNING: DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.dataBinding'.
2022-07-28T23:36:33.2797944Z It will be removed in version 5.0 of the Android Gradle plugin.
2022-07-28T23:36:33.9796986Z 
2022-07-28T23:36:33.9798819Z FAILURE: Build failed with an exception.
2022-07-28T23:36:33.9799385Z 
2022-07-28T23:36:33.9799910Z * What went wrong:
2022-07-28T23:36:33.9801449Z A problem occurred configuring project ':app'.
2022-07-28T23:36:33.9802801Z > SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/azp/_work/1/s/local.properties'.
2022-07-28T23:36:33.9803386Z 
2022-07-28T23:36:33.9803681Z * Try:
2022-07-28T23:36:33.9804986Z 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.
2022-07-28T23:36:33.9805350Z 
2022-07-28T23:36:33.9805674Z * Get more help at https://help.gradle.org
2022-07-28T23:36:33.9806648Z 
2022-07-28T23:36:33.9807103Z Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
2022-07-28T23:36:33.9807912Z Use '--warning-mode all' to show the individual deprecation warnings.
2022-07-28T23:36:33.9808507Z See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
2022-07-28T23:36:33.9808801Z 
2022-07-28T23:36:33.9809086Z BUILD FAILED in 9s
2022-07-28T23:36:34.4381110Z Error: The process '/azp/_work/1/s/gradlew' failed with exit code 1
2022-07-28T23:36:34.4386504Z     at ExecState._setResult (/azp/_work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/3.205.0/node_modules/azure-pipelines-task-lib/toolrunner.js:944:25)
2022-07-28T23:36:34.4390433Z     at ExecState.CheckComplete (/azp/_work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/3.205.0/node_modules/azure-pipelines-task-lib/toolrunner.js:927:18)
2022-07-28T23:36:34.4393277Z     at ChildProcess.<anonymous> (/azp/_work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/3.205.0/node_modules/azure-pipelines-task-lib/toolrunner.js:840:19)
2022-07-28T23:36:34.4394910Z     at ChildProcess.emit (events.js:198:13)
2022-07-28T23:36:34.4396280Z     at maybeClose (internal/child_process.js:982:16)
2022-07-28T23:36:34.4397383Z     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
2022-07-28T23:36:34.4415403Z ##[error]Code analysis failed. Gradle exit code: -1. Error: Error: The process '/azp/_work/1/s/gradlew' failed with exit code 1
2022-07-28T23:36:34.4472252Z ##[section]Finishing: Build Task

字符串

jgovgodb

jgovgodb1#

找不到SDK位置。请使用ANDROID_SDK_ROOT环境变量或通过在项目的本地属性文件“/azp/_work/1/s/local.properties”中设置sdk.dir路径来定义位置。
此错误的原因是未安装Android SDK或未在自托管代理上配置Android环境。
您需要检查您的自托管代理上是否安装了Android SDK。
如果没有,您可以使用以下命令安装Android SDK。

sudo apt update && sudo apt install android-sdk

字符串
Android SDK在Linux上的位置可以是以下任意位置:

/home/AccountName/Android/Sdk

/usr/lib/android-sdk

/Library/Android/sdk/

/Users/[USER]/Library/Android/sdk


然后您可以通过设置环境变量或在/azp/_work/1/s/local.properties中设置sdk.dir路径来设置Android环境。
举例来说:

设置环境变量

1.编辑您的~/.zshrc或~/.bashrc或. 2.添加SDK路径:

export ANDROID_HOME=$HOME/Android/Sdk
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools


3.运行命令:

source $HOME/.bashrc

echo $ANDROID_SDK_ROOT

相关问题