Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-38618

NullPointerException when installing Android SDK

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Not A Defect
    • Labels:
      None
    • Environment:
      Mac OS 10.11.6
      Jenkins 2.7.2
      Android Emulator Plugin 2.15
    • Similar Issues:

      Description

      I get a NullPointerException when trying to automatically install the Android SDK. The only other plugin I have added to Jenkins is the Node JS plugin.

      [android] No Android SDK found; let's install it automatically...
      [android] Going to install required Android SDK components...
      [android] Installing the 'platform-tool' SDK component(s)...
      $ /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android update sdk -u -a -t platform-tool
      /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android: line 30: dirname: command not found
      /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android: line 33: basename: command not found
      /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android: line 40: dirname: command not found
      /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android: line 44: dirname: command not found
      /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android: line 48: basename: command not found
      $ /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android list sdk --extended
      /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android: line 30: dirname: command not found
      /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android: line 33: basename: command not found
      /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android: line 40: dirname: command not found
      /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android: line 44: dirname: command not found
      /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android: line 48: basename: command not found
      [android] Installing the 'tool,extra-android-m2repository,extra-google-m2repository' SDK component(s)...
      $ /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android update sdk -u -a -t tool,extra-android-m2repository,extra-google-m2repository
      /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android: line 30: dirname: command not found
      /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android: line 33: basename: command not found
      /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android: line 40: dirname: command not found
      /Users/Shared/Jenkins/Home/tools/android-sdk/tools/android: line 44: dirname: command not found
      FATAL: null
      java.lang.NullPointerException
      at hudson.plugins.android_emulator.util.Utils.getToolCommand(Utils.java:398)
      at hudson.plugins.android_emulator.util.Utils.runAndroidTool(Utils.java:449)
      at hudson.plugins.android_emulator.util.Utils.runAndroidTool(Utils.java:442)
      at hudson.plugins.android_emulator.util.Utils.runAndroidTool(Utils.java:436)
      at hudson.plugins.android_emulator.SdkInstaller.isPlatformInstalled(SdkInstaller.java:311)
      at hudson.plugins.android_emulator.SdkInstaller.installPlatform(SdkInstaller.java:257)
      at hudson.plugins.android_emulator.SdkInstaller.installDependencies(SdkInstaller.java:242)
      at hudson.plugins.android_emulator.AndroidEmulator.setUp(AndroidEmulator.java:264)
      at hudson.model.Build$BuildExecution.doRun(Build.java:156)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
      at hudson.model.Run.execute(Run.java:1741)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:98)
      at hudson.model.Executor.run(Executor.java:410)
      Finished: FAILURE

        Attachments

          Activity

          Hide
          orrc Christopher Orr added a comment -

          I guess the plugin could be more robust against failures to install the SDK, but the underlying problem seems to be that standard tools like "dirname" and "basename" are not available on your system.

          These are both available to me in /usr/bin on my OS X 10.11.6 system, so that's something to look into…

          Show
          orrc Christopher Orr added a comment - I guess the plugin could be more robust against failures to install the SDK, but the underlying problem seems to be that standard tools like "dirname" and "basename" are not available on your system. These are both available to me in /usr/bin on my OS X 10.11.6 system, so that's something to look into…
          Hide
          erfa Erik Fahlén added a comment -

          Hm, interesting, it actually works when I disable the Node JS plugin. But if I disable the Android Emulator Plugin and keep Node JS active, I can run "dirname ." in the build without problems. So the Node JS plugin doesn't always cause it.

          Could it be that Android Emulator and Node JS together do something weird with the path when both are enabled?

          Show
          erfa Erik Fahlén added a comment - Hm, interesting, it actually works when I disable the Node JS plugin. But if I disable the Android Emulator Plugin and keep Node JS active, I can run "dirname ." in the build without problems. So the Node JS plugin doesn't always cause it. Could it be that Android Emulator and Node JS together do something weird with the path when both are enabled?
          Hide
          orrc Christopher Orr added a comment -

          The NodeJS plugin appears to break other plugins as well; see JENKINS-20636, JENKINS-28578.

          Looking at the source code, the NPM wrapper part of the plugin seems to blindly overwrite the PATH environment variable:
          https://github.com/jenkinsci/nodejs-plugin/blob/nodejs-0.2.1/src/main/java/jenkins/plugins/nodejs/tools/NpmPackagesBuildWrapper.java#L83-L86

          Since then, Nicolas De Loof has rewritten parts of the plugin, and added Pipeline support, but this work has not yet been released…

          Show
          orrc Christopher Orr added a comment - The NodeJS plugin appears to break other plugins as well; see JENKINS-20636 , JENKINS-28578 . Looking at the source code, the NPM wrapper part of the plugin seems to blindly overwrite the PATH environment variable: https://github.com/jenkinsci/nodejs-plugin/blob/nodejs-0.2.1/src/main/java/jenkins/plugins/nodejs/tools/NpmPackagesBuildWrapper.java#L83-L86 Since then, Nicolas De Loof has rewritten parts of the plugin, and added Pipeline support, but this work has not yet been released…

            People

            • Assignee:
              orrc Christopher Orr
              Reporter:
              erfa Erik Fahlén
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: