The emulator plugin can't connect the adb server as already discussed in ticket. I don't know if it is a misconfiguration problem or the previously mentioned problems still exists?

      [EnvInject] - Loading node environment variables.
      Baue in Arbeitsbereich /var/lib/jenkins/jobs/xxx/workspace
      Updating https://abc.xyz/xxx/trunk/src_androidstudio at revision '2015-03-17T08:58:35.873 +0100'
      At revision 693
      no change for https://abc.xyz/xxx/trunk/src_androidstudio since the previous build
      [android] Using Android SDK: /opt/android-sdk_r24.0.2-linux
      [android] Waiting 30 seconds before starting emulator...
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb start-server
      * daemon not running. starting it now on port 9278 *
      * daemon started successfully *
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb start-server
      $ /opt/android-sdk_r24.0.2-linux/tools/emulator -snapshot-list -no-window -avd hudson_de-DE_160_WXGA800_android-19_armeabi-v7a
      [android] Starting Android emulator and creating initial snapshot
      [android] Erasing existing emulator data...
      $ /opt/android-sdk_r24.0.2-linux/tools/emulator -no-boot-anim -ports 9276,9277 -avd hudson_de-DE_160_WXGA800_android-19_armeabi-v7a -no-snapshot-load -no-snapshot-save -wipe-data -no-window -no-audio -gpu off
      Failed to Initialize backend EGL display
      Could not initialize emulated framebuffer$ /opt/android-sdk_r24.0.2-linux/platform-tools/adb connect localhost:9277
      connected to localhost:9277
      [android] Waiting for emulator to finish booting...
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb -s localhost:9277 shell getprop init.svc.bootanim
      error: device offline
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb connect localhost:9277
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb -s localhost:9277 shell getprop init.svc.bootanim
      error: device offline
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb connect localhost:9277
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb -s localhost:9277 shell getprop init.svc.bootanim
      error: device offline
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb disconnect localhost:9277
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb connect localhost:9277
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb -s localhost:9277 shell getprop init.svc.bootanim
      error: device offline
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb connect localhost:9277
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb -s localhost:9277 shell getprop init.svc.bootanim
      error: device offline
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb connect localhost:9277
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb -s localhost:9277 shell getprop init.svc.bootanim
      error: device offline
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb disconnect localhost:9277
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb connect localhost:9277
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb -s localhost:9277 shell getprop init.svc.bootanim
      error: device offline
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb connect localhost:9277
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb -s localhost:9277 shell getprop init.svc.bootanim
      error: device offline
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb connect localhost:9277
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb -s localhost:9277 shell getprop init.svc.bootanim
      error: device offline
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb disconnect localhost:9277
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb connect localhost:9277
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb -s localhost:9277 shell getprop init.svc.bootanim
      error: device offline
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb connect localhost:9277
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb -s localhost:9277 shell getprop init.svc.bootanim
      error: device offline
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb connect localhost:9277
      [android] Interrupted while waiting for emulator to finish booting.
      [android] Emulator was shut down before it finished booting
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb disconnect localhost:9277
      [android] Stopping Android emulator
      Creating filesystem with parameters:
          Size: 69206016
          Block size: 4096
          Blocks per group: 32768
          Inodes per group: 4224
          Inode size: 256
          Journal blocks: 1024
          Label: 
          Blocks: 16896
          Block groups: 1
          Reserved block group size: 7
      Created filesystem with 11/4224 inodes and 1302/16896 blocks
      emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
      $ /opt/android-sdk_r24.0.2-linux/platform-tools/adb kill-server
      [...]
      

          [JENKINS-27456] Emulator can't connect to adb server!?

          + 1 - Jenkins 1.613 and plugin 2.13.1
          Shouldn't adb wait-for-device be used to wait until device is online (optionally with some timeout) and then only adb -s <serial> shell getprop init.svc.bootanim without connecting and disconnecting each time?

          Karol W⁠rotniak added a comment - + 1 - Jenkins 1.613 and plugin 2.13.1 Shouldn't adb wait-for-device be used to wait until device is online (optionally with some timeout) and then only adb -s <serial> shell getprop init.svc.bootanim without connecting and disconnecting each time?

          Juan Sotuyo added a comment -

          I have figured out this issue, a PR has been proposed https://github.com/jenkinsci/android-emulator-plugin/pull/51

          localhost:xxxx will not work unless xxxx is in the range 5554-5680 (and must be even). Otherwhise the device will be listed, can be connected, but won't ever appear as anything other than offline.

          On the ther hand, using emulator-yyyy with the console port rather than the adb port seems to work for any port number that emulator -ports accepts. However, the emulator-yyy alternative was dropped due to JENKINS-11952

          Juan Sotuyo added a comment - I have figured out this issue, a PR has been proposed https://github.com/jenkinsci/android-emulator-plugin/pull/51 localhost:xxxx will not work unless xxxx is in the range 5554-5680 (and must be even). Otherwhise the device will be listed, can be connected, but won't ever appear as anything other than offline. On the ther hand, using emulator-yyyy with the console port rather than the adb port seems to work for any port number that emulator -ports accepts. However, the emulator-yyy alternative was dropped due to JENKINS-11952

          jsotuyod: Have you seen this comment (with a pull request virtually identical to yours) and the two comments after it?
          https://issues.jenkins-ci.org/browse/JENKINS-11952?focusedCommentId=222878

          Otherwhise the device will be listed, can be connected, but won't ever appear as anything other than offline.

          Well, I can say that's not true, as I just tried a build with the latest plugin and the emulator started fine.

          I'll repeat my comment from the other issue:

          The code in this pull request doesn't guarantee that the first port will be even, so I'll have to be skeptical about your claims

          But if it turns out that this change nevertheless helps, then that's good to know. So what are the results you are seeing? Which OS are the emulator builds running on, and what is the emulator config? How many builds were failing previously, compared to now, and is that with builds whose user port is actually even?

          Particularly of interest is the emulator config; I have the vague feeling that newer Android versions are more likely to fail to start than older ones.

          Christopher Orr added a comment - jsotuyod : Have you seen this comment (with a pull request virtually identical to yours) and the two comments after it? https://issues.jenkins-ci.org/browse/JENKINS-11952?focusedCommentId=222878 Otherwhise the device will be listed, can be connected, but won't ever appear as anything other than offline. Well, I can say that's not true, as I just tried a build with the latest plugin and the emulator started fine. I'll repeat my comment from the other issue: The code in this pull request doesn't guarantee that the first port will be even, so I'll have to be skeptical about your claims But if it turns out that this change nevertheless helps, then that's good to know. So what are the results you are seeing? Which OS are the emulator builds running on, and what is the emulator config? How many builds were failing previously, compared to now, and is that with builds whose user port is actually even? Particularly of interest is the emulator config; I have the vague feeling that newer Android versions are more likely to fail to start than older ones.

          Juan Sotuyo added a comment -

          That's weird, on both my local machine and CI server, with adb 1.0.32 the behavior is really consistent with the emulator output when using `-port` (both Ubuntu 14.04).

          As for the even number check, it's true I don't guarantee it. Actually I confess I didn't even checked it. In all my tests it just happened to be even, so I assumed it was already being done somewhere else in the code. I'll be more than glad to add such checks if we agree to move forward on this direction.

          As for emulator config, on my local machine I've been using an already created (in default SDK folder location) Nexus_5_API_21_x86, with snapshots disabled. On CI server, I'm creating a brand new local Google Inc.:Google APIs:21, xhdpi, WVGA, google_apis/x86_64 image. Haven't tried older images (probably pre android 4.2 are the biggest change, since that's when debug access / multiuser got revamped).

          Juan Sotuyo added a comment - That's weird, on both my local machine and CI server, with adb 1.0.32 the behavior is really consistent with the emulator output when using `-port` (both Ubuntu 14.04). As for the even number check, it's true I don't guarantee it. Actually I confess I didn't even checked it. In all my tests it just happened to be even, so I assumed it was already being done somewhere else in the code. I'll be more than glad to add such checks if we agree to move forward on this direction. As for emulator config, on my local machine I've been using an already created (in default SDK folder location) Nexus_5_API_21_x86, with snapshots disabled. On CI server, I'm creating a brand new local Google Inc.:Google APIs:21, xhdpi, WVGA, google_apis/x86_64 image. Haven't tried older images (probably pre android 4.2 are the biggest change, since that's when debug access / multiuser got revamped).

          Boaz Brudner added a comment -

          Is there a resolution for this issue?

          This is now is significantly impacting us.

          Boaz Brudner added a comment - Is there a resolution for this issue? This is now is significantly impacting us.

          Andy Piper added a comment -

          The command:
          adb -s localhost:9277 shell
          is completely wrong. The docs say:
          -s <specific device> - directs command to the device or emulator with the given
          serial number or qualifier. Overrides ANDROID_SERIAL
          So this is not a host and port, it's an identifier. If I run the create command that jenkins uses I get the identifier:
          emulator-5554
          If I use this to connect all is good. So I believe the plugin is completely broken in its current behaviour.
          The docs are also wrong ANDROID_SERIAL lists hosts:port but it should be an identifier. I don't currently see a way of setting this, but I haven't looked very hard.

          Andy Piper added a comment - The command: adb -s localhost:9277 shell is completely wrong. The docs say: -s <specific device> - directs command to the device or emulator with the given serial number or qualifier. Overrides ANDROID_SERIAL So this is not a host and port, it's an identifier. If I run the create command that jenkins uses I get the identifier: emulator-5554 If I use this to connect all is good. So I believe the plugin is completely broken in its current behaviour. The docs are also wrong ANDROID_SERIAL lists hosts:port but it should be an identifier. I don't currently see a way of setting this, but I haven't looked very hard.

          Andy Piper added a comment -

          According to this:
          http://stackoverflow.com/questions/2214377/how-to-get-serial-number-or-id-of-android-emulator-after-it-runs
          The emulator name is "emulator-X" where X is the console port defined when you start the emulator.

          Andy Piper added a comment - According to this: http://stackoverflow.com/questions/2214377/how-to-get-serial-number-or-id-of-android-emulator-after-it-runs The emulator name is "emulator-X" where X is the console port defined when you start the emulator.

          Related to https://issues.jenkins-ci.org/browse/JENKINS-11952 ... I see this is where a change took place to fix some instability but as noted here with the latest version downloaded from the job (Downloading and installing Android SDK from http://dl.google.com/android/android-sdk_r24.0.2-linux.tgz) the syntax localhost:<adb port> doesn't appear to be valid:

          /android_gradle_integration_matrix/label/trust-reg-3.cisco.com
          $ /home/testuser/tools/android-sdk/tools/android list target
          [android] Using Android SDK: /home/testuser/tools/android-sdk
          $ /home/testuser/tools/android-sdk/platform-tools/adb start-server
          * daemon not running. starting it now on port 8711 *
          * daemon started successfully *
          $ /home/testuser/tools/android-sdk/platform-tools/adb start-server
          [android] Starting Android emulator
          $ /home/testuser/tools/android-sdk/tools/emulator -ports 8709,8710 -prop persist.sys.language=en -prop persist.sys.country=US -avd hudson_en-US_160_HVGA_android-16_armeabi-v7a -no-snapshot-load -no-snapshot-save -no-window -noaudio
          $ /home/testuser/tools/android-sdk/platform-tools/adb connect localhost:8710
          unable to connect to localhost:8710: Connection refused
          [android] Waiting for emulator to finish booting...
          $ /home/testuser/tools/android-sdk/platform-tools/adb -s localhost:8710 shell getprop init.svc.bootanim
          error: device 'localhost:8710' not found
          $ /home/testuser/tools/android-sdk/platform-tools/adb connect localhost:8710
          $ /home/testuser/tools/android-sdk/platform-tools/adb -s localhost:8710 shell getprop init.svc.bootanim
          error: device 'localhost:8710' not found
          $ /home/testuser/tools/android-sdk/platform-tools/adb connect localhost:8710
          $ /home/testuser/tools/android-sdk/platform-tools/adb -s localhost:8710 shell getprop init.svc.bootanim
          error: device 'localhost:8710' not found
          $ /home/testuser/tools/android-sdk/platform-tools/adb disconnect localhost:8710
          error: no such device 'localhost:8710'
          $ /home/testuser/tools/android-sdk/platform-tools/adb connect localhost:8710
          $ /home/testuser/tools/android-sdk/platform-tools/adb -s localhost:8710 shell getprop init.svc.bootanim
          error: device 'localhost:8710' not found
          $ /home/testuser/tools/android-sdk/platform-tools/adb connect localhost:8710
          $ /home/testuser/tools/android-sdk/platform-tools/adb -s localhost:8710 shell getprop init.svc.bootanim
          error: device 'localhost:8710' not found
          $ /home/testuser/tools/android-sdk/platform-tools/adb connect localhost:8710
          $ /home/testuser/tools/android-sdk/platform-tools/adb -s localhost:8710 shell getprop init.svc.bootanim
          error: device 'localhost:8710' not found
          ....
          

          Run it manually on the same box with the notes from above:

          [testuser@trust-reg-3 ~]$ /home/testuser/tools/android-sdk/platform-tools/adb devices
          List of devices attached
          emulator-5035   device
          [testuser@trust-reg-3 ~]$ /home/testuser/tools/android-sdk/platform-tools/adb -s emulator-5035 shell
          root@android:/ # exit
          

          The fix looks as simple as the below diff; but seems we would need to either make a decision of push the throttle down to keep the train going with the latest release or add different contextes to support the older versions for those where localhost:<port> is a more valid stable way to connect to the emulator.

          jonatstr-onec:/ws/jonatstr-rtp/workspace/android-emulator-plugin > git diff src/main/java/hudson/plugins/android_emulator/AndroidEmulatorContext.java
          diff --git a/src/main/java/hudson/plugins/android_emulator/AndroidEmulatorContex
          index 1d3eac9..1e5d992 100644
          --- a/src/main/java/hudson/plugins/android_emulator/AndroidEmulatorContext.java
          +++ b/src/main/java/hudson/plugins/android_emulator/AndroidEmulatorContext.java
          @@ -55,7 +55,7 @@ public class AndroidEmulatorContext {
                          adbPort = ports[1];
                          adbServerPort = ports[2];
          
          -               serial = String.format("localhost:%d", adbPort);
          +               serial = String.format("emulator-%d", adbPort);
                  }
          
                  public void cleanUp() {
          (END)
          

          Jonathan Strickland added a comment - Related to https://issues.jenkins-ci.org/browse/JENKINS-11952 ... I see this is where a change took place to fix some instability but as noted here with the latest version downloaded from the job (Downloading and installing Android SDK from http://dl.google.com/android/android-sdk_r24.0.2-linux.tgz ) the syntax localhost:<adb port> doesn't appear to be valid: /android_gradle_integration_matrix/label/trust-reg-3.cisco.com $ /home/testuser/tools/android-sdk/tools/android list target [android] Using Android SDK: /home/testuser/tools/android-sdk $ /home/testuser/tools/android-sdk/platform-tools/adb start-server * daemon not running. starting it now on port 8711 * * daemon started successfully * $ /home/testuser/tools/android-sdk/platform-tools/adb start-server [android] Starting Android emulator $ /home/testuser/tools/android-sdk/tools/emulator -ports 8709,8710 -prop persist.sys.language=en -prop persist.sys.country=US -avd hudson_en-US_160_HVGA_android-16_armeabi-v7a -no-snapshot-load -no-snapshot-save -no-window -noaudio $ /home/testuser/tools/android-sdk/platform-tools/adb connect localhost:8710 unable to connect to localhost:8710: Connection refused [android] Waiting for emulator to finish booting... $ /home/testuser/tools/android-sdk/platform-tools/adb -s localhost:8710 shell getprop init.svc.bootanim error: device 'localhost:8710' not found $ /home/testuser/tools/android-sdk/platform-tools/adb connect localhost:8710 $ /home/testuser/tools/android-sdk/platform-tools/adb -s localhost:8710 shell getprop init.svc.bootanim error: device 'localhost:8710' not found $ /home/testuser/tools/android-sdk/platform-tools/adb connect localhost:8710 $ /home/testuser/tools/android-sdk/platform-tools/adb -s localhost:8710 shell getprop init.svc.bootanim error: device 'localhost:8710' not found $ /home/testuser/tools/android-sdk/platform-tools/adb disconnect localhost:8710 error: no such device 'localhost:8710' $ /home/testuser/tools/android-sdk/platform-tools/adb connect localhost:8710 $ /home/testuser/tools/android-sdk/platform-tools/adb -s localhost:8710 shell getprop init.svc.bootanim error: device 'localhost:8710' not found $ /home/testuser/tools/android-sdk/platform-tools/adb connect localhost:8710 $ /home/testuser/tools/android-sdk/platform-tools/adb -s localhost:8710 shell getprop init.svc.bootanim error: device 'localhost:8710' not found $ /home/testuser/tools/android-sdk/platform-tools/adb connect localhost:8710 $ /home/testuser/tools/android-sdk/platform-tools/adb -s localhost:8710 shell getprop init.svc.bootanim error: device 'localhost:8710' not found .... Run it manually on the same box with the notes from above: [testuser@trust-reg-3 ~]$ /home/testuser/tools/android-sdk/platform-tools/adb devices List of devices attached emulator-5035 device [testuser@trust-reg-3 ~]$ /home/testuser/tools/android-sdk/platform-tools/adb -s emulator-5035 shell root@android:/ # exit The fix looks as simple as the below diff; but seems we would need to either make a decision of push the throttle down to keep the train going with the latest release or add different contextes to support the older versions for those where localhost:<port> is a more valid stable way to connect to the emulator. jonatstr-onec:/ws/jonatstr-rtp/workspace/android-emulator-plugin > git diff src/main/java/hudson/plugins/android_emulator/AndroidEmulatorContext.java diff --git a/src/main/java/hudson/plugins/android_emulator/AndroidEmulatorContex index 1d3eac9..1e5d992 100644 --- a/src/main/java/hudson/plugins/android_emulator/AndroidEmulatorContext.java +++ b/src/main/java/hudson/plugins/android_emulator/AndroidEmulatorContext.java @@ -55,7 +55,7 @@ public class AndroidEmulatorContext { adbPort = ports[1]; adbServerPort = ports[2]; - serial = String.format("localhost:%d", adbPort); + serial = String.format("emulator-%d", adbPort); } public void cleanUp() { (END)

          Christopher Orr added a comment - https://github.com/jenkinsci/android-emulator-plugin/pull/58

          This should be working in version 2.14 of the plugin, which was released last week.

          Christopher Orr added a comment - This should be working in version 2.14 of the plugin, which was released last week.

            orrc Christopher Orr
            arbyter Marcus Sümnick
            Votes:
            2 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated:
              Resolved: