5

I am attempting to setup Jenkins for my team's android projects. All of my tests will consistently pass when ran through the IDE; however, through Jenkins test results vary. The build might pass but most of the time will either fail with a similar message below or the build will seem to run indefinitely.

com.example.simpletest.MainActivityTest > testButton1Action[Android SDK built for x86 - 5.0.2] [31mFAILED [0m
    java.lang.RuntimeException: Could not launch intent Intent 
{ act=android.intent.action.MAIN flg=0x10000000 cmp=com.example.simpletest/.MainActivity }
within 45 seconds. Perhaps the main thread has not gone idle within a reasonable amount of time?
There could be an animation or something constantly repainting the screen. Or the
activity is doing network calls on creation? See the threaddump logs. For your reference
the last time the event queue was idle before your activity launch request was 1438954385239
and now the last time the queue went idle was: 1438954385249. If these numbers are the same your activity might be hogging the event queue. at android.support.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:315) Tests on Android SDK built for x86 - 5.0.2 failed: Test run failed to complete. Expected 8 tests, received 4 :app:connectedAndroidTestDebug FAILED

To help simplify things I created a test project that contains an activity with 3 buttons to rule out anything I might have been doing in my original project/tests. Example of a test:

@SmallTest
public void testButton1() throws Exception {
    Button btn = (Button) getActivity().findViewById(R.id.myButton1);

    assertTrue("Incorrect button 1 text!", btn.getText().equals("Button1"));
}

FYI searching for a solution had brought me to here and here neither of which helped obviously.

  • Mac OSX / Android Studio
  • Test lib: Espresso
  • Latest and greatest for Jenkins/plugins

Jenkins

Build Environment

  • Using existing emulator
  • reset emulator state at start-up
  • emulator options: -no-audio

Build

  • executing shell: adb shell input keyevent 82
  • gradle tasks: clean build connectedAndroidTest

Emulator

Name: Nexus5_21-Jenkins
CPU/ABI: Intel Atom (x86)
Path: /Users/someuser/.android/avd/Nexus5_21-Jenkins.avd
Target: Android 5.0.1 (API level 21)
Skin: nexus_5
SD Card: 100M
Snapshot: no
hw.lcd.density: 480
hw.dPad: no
avd.ini.encoding: UTF-8
hw.camera.back: none
disk.dataPartition.size: 200M
hw.gpu.enabled: yes
runtime.network.latency: none
skin.dynamic: yes
hw.keyboard: yes
runtime.network.speed: full
hw.device.hash2: MD5:2fa0e16c8cceb7d385183284107c0c88
hw.ramSize: 1536
tag.id: default
tag.display: Default
hw.sdCard: yes
hw.device.manufacturer: Google
hw.mainKeys: no
hw.accelerometer: yes
hw.trackBall: no
hw.device.name: Nexus 5
hw.sensors.proximity: yes
hw.battery: yes
AvdId: Nexus5_21-Jenkins
hw.sensors.orientation: yes
hw.audioInput: yes
hw.camera.front: none
hw.gps: yes
avd.ini.displayname: Nexus5_21-Jenkins
snapshot.present: no
vm.heapSize: 64
runtime.scalefactor: auto

Currently everything is being run on my machine but ultimately the plan was to install Jenkins on a dedicated machine. At this point I am just trying to figure out what I may be overlooking.

Community
  • 1
  • 1
zec
  • 294
  • 1
  • 9
  • Is it able to turn on the device screen when that happens? I have seen that 45 seconds error when the screen is off – HRVHackers Sep 01 '16 at 06:54
  • @zec were you able to resolve that problem? I've faced the same issue. Tests on Jenkins started failing, but they used to work fine. – andrei_zaitcev Feb 23 '17 at 17:52
  • @andrei_zaitcev haven't investigated further as we went in a different direction. been meaning to revisit as it still bugs me to this day. – zec Mar 17 '17 at 18:28
  • @zec What was the different direction that you went in? – Dinesh Aug 17 '17 at 16:23

0 Answers0