title: Jenkins build failed due to missing android SDK
body: <p>As the title says my jenkins build fails due to not finding the android sdk dispite it being located in the environments path.</p>
  
  <p>Here is the console logs</p>
  
  <pre><code>Started by user anonymous
  Building in workspace /Users/lmnapp/.jenkins/jobs/Android_app_master/workspace
   &gt; git rev-parse --is-inside-work-tree # timeout=10
  Fetching changes from the remote Git repository
   &gt; 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
   &gt; git --version # timeout=10
  using .gitcredentials to set credentials
   &gt; 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'.
  &gt; 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
  </code></pre>
  
  <p>As u can see, the path clearly has android_home set correctly.</p>
  
  <p>I am trying to build this via gradle in jenkins.</p>
  
  <p>This is teh pre executed shell commands i have configured this job to do</p>
  
  <pre><code>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
  </code></pre>