gpt4 book ai didi

android - 由于缺少 android SDK,Jenkins 构建失败

转载 作者:IT老高 更新时间:2023-10-28 22:19:31 26 4
gpt4 key购买 nike

正如标题所说,我的 jenkins 构建失败,因为没有找到 android sdk,尽管它位于环境路径中。

这是控制台日志

Started by user anonymous
Building in workspace /Users/lmnapp/.jenkins/jobs/Android_app_master/workspace
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://bitbucket.org/xxxxx-xxx/xxxx-android-app.git # timeout=10
Fetching upstream changes from https://bitbucket.org/xxxx-mob/xxxx-android-app.git
> git --version # timeout=10
using .gitcredentials to set credentials
> git config --local credential.helper store --file=/var/folders/gj/xxxxxxxx/T/xxxxx.credentials # timeout=10

+ export ANDROID_HOME=/Users/lmnapp/android-sdk-macosx
+ ANDROID_HOME=/Users/lmnapp/android-sdk-macosx
+ export ANDROID_SDK=/Users/lmnapp/android-sdk-macosx/platforms
+ ANDROID_SDK=/Users/lmnapp/android-sdk-macosx/platforms
+ export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/Users/lmnapp/android-sdk-macosx/tools:/Users/lmnapp/android-sdk-macosx/platform-tools:/Users/lmnapp/android-sdk-macosx
+ PATH=/usr/bin:/bin:/usr/sbin:/sbin:/Users/lmnapp/android-sdk-macosx/tools:/Users/lmnapp/android-sdk-macosx/platform-tools:/Users/lmnapp/android-sdk-macosx
+ export AVD_NAME=jenkinsGoogleApi18_1
+ AVD_NAME=jenkinsGoogleApi18_1
+ echo displayPath
displayPath
+ echo ....
....
+ echo ....
....
+ echo /usr/bin:/bin:/usr/sbin:/sbin:/Users/lmnapp/android-sdk-macosx/tools:/Users/lmnapp/android-sdk-macosx/platform-tools:/Users/lmnapp/android-sdk-macosx
/usr/bin:/bin:/usr/sbin:/sbin:/Users/lmnapp/android-sdk-macosx/tools:/Users/lmnapp/android-sdk-macosx/platform-tools:/Users/lmnapp/android-sdk-macosx
+ adb start-server
[Gradle] - Launching build.
[workspace] $ /Users/lmnapp/.jenkins/jobs/Android_app_master/workspace/gradlew assembleProductionRelease
Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
java.lang.RuntimeException: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
at com.android.build.gradle.internal.SdkHandler.getAndCheckSdkFolder(SdkHandler.java:103)
at com.android.build.gradle.internal.SdkHandler.getSdkLoader(SdkHandler.java:113)
at com.android.build.gradle.internal.SdkHandler.initTarget(SdkHandler.java:87)
at com.android.build.gradle.BasePlugin.ensureTargetSetup(BasePlugin.groovy:467)
at com.android.build.gradle.BasePlugin.access$0(BasePlugin.groovy)
at com.android.build.gradle.BasePlugin$_createTasks_closure9.doCall(BasePlugin.groovy:372)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:278)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
at groovy.lang.Closure.call(Closure.java:423)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:83)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy12.afterEvaluate(Unknown Source)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:79)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:65)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:504)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:83)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:47)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:55)

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/lmnapp/.jenkins/jobs/Android_app_master/workspace/project/build.gradle' line: 120

* What went wrong:
A problem occurred evaluating project ':project'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

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

BUILD FAILED

如您所见,路径显然已正确设置了 android_home。

我正在尝试通过 jenkins 中的 gradle 构建它。

这是我已配置此作业执行的预执行 shell 命令

export ANDROID_HOME=/Users/lmnapp/android-sdk-macosx
export ANDROID_SDK=/Users/lmnapp/android-sdk-macosx/platforms
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME
export AVD_NAME=jenkinsGoogleApi18_1

echo displayPath
echo ....
echo ....

echo $PATH

最佳答案

修复它。

  1. 转到 Jenkins > 管理 Jenkins > 配置系统
  2. 勾选“环境变量”
  3. 添加名称:ANDROID_HOME,值 -> 你的 android sdk 目录
  4. 点击“添加”
  5. 向下滚动点击保存

关于android - 由于缺少 android SDK,Jenkins 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29216244/

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