# Android Instrumented Test crash on Emulator

**URL:** <https://discuss.circleci.com/t/android-instrumented-test-crash-on-emulator/25637>\
**Category:** Build Environment\
**Created:** [October 8, 2018, 2:50pm UTC](https://discuss.circleci.com/t/android-instrumented-test-crash-on-emulator/25637 "2018-10-08T14:50:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![salihgueler](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@salihgueler](https://discuss.circleci.com/u/salihgueler)\
**Post date:** [October 8, 2018, 2:50pm UTC](https://discuss.circleci.com/t/android-instrumented-test-crash-on-emulator/25637/1 "2018-10-08T14:50:22Z")

</div>

Hi,

I am building my application with CircleCI. My Instrument tests were running just fine until I extended those with more complicated tests including IdlingResource and wait for response over 3 minutes, then I started to get this error on the console.

```auto
com.salihgueler.SampleActivityTest > sampleActivityTest[test(AVD) - 5.0.2] FAILED 
Test failed to run to completion. Reason: 'Instrumentation run failed due to 'Process crashed.''. Check device logcat for details
Tests on test(AVD) - 5.0.2 failed: Instrumentation run failed due to 'Process crashed.'
:app:connectedDebugAndroidTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:connectedDebugAndroidTest'.
> There were failing tests. See the report at: file:///home/circleci/code/app/build/reports/androidTests/connected/index.html

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

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 40s
112 actionable tasks: 54 executed, 58 up-to-date
Exited with code 1

```

And here is my yaml file

```auto
version: 2
jobs:
  build:
    working_directory: ~/code
    docker:
      - image: circleci/android:api-25-alpha
    environment:
      JVM_OPTS: -Xmx3200m
    steps:
      - checkout
      - run:
          name: "Pull Submodules"
          command: |
            git submodule init
            git submodule update --recursive
      - restore_cache:
          key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
# - run:
# name: Chmod permissions #if permission for Gradlew Dependencies fail, use this.
# command: sudo chmod +x ./gradlew
      - run:
          name: Download Dependencies
          command: ./gradlew androidDependencies
      - save_cache:
          paths:
            - ~/.gradle
          key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
      - run:
          name: Run LintTests
          command: ./gradlew lint test
      - run:
          name: Run UnitTests
          command: ./gradlew testDebugUnitTest
      - run:
          name: Setup emulator
          command: sdkmanager "system-images;android-21;default;armeabi-v7a" && echo "no" | avdmanager create avd -n test --device 8 -k "system-images;android-21;default;armeabi-v7a"
      - run:
          name: Launch emulator
          command: export LD_LIBRARY_PATH=${ANDROID_HOME}/emulator/lib64:${ANDROID_HOME}/emulator/lib64/qt/lib && emulator64-arm -avd test -noaudio -no-boot-anim -no-window -accel auto -verbose
          background: true
      - run:
          name: Wait emulator
          command: |
            # wait for it to have booted
            circle-android wait-for-boot
            # unlock the emulator screen
            sleep 30
            adb shell input keyevent 82
      - run:
          name: Run EspressoTests
          command: ./gradlew connectedDebugAndroidTest
      - store_artifacts:
          path: app/build/reports
          destination: reports
      - store_test_results:
          path: app/build/test-results

```

I have tried almost everything and unless I have simplified tests, it’s not working. I am open to every suggestion. Thank you for your help.

Best,

Salih.

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [October 8, 2018, 3:59pm UTC](https://discuss.circleci.com/t/android-instrumented-test-crash-on-emulator/25637/2 "2018-10-08T15:59:04Z")

</div>

Try getting an SSH session after your failing build, and enter `dmesg` on the console. This will give you some system messages - see if it mentions a “child sacrificed” or similar - in serious low memory situations, the kernel is forced kill a process.

Also, it says “Check device logcat”, did you do that? I imagine you need the `--stacktrace` option, as the error suggests.

---

<div class="post-metadata">

**Author:** ![salihgueler](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@salihgueler](https://discuss.circleci.com/u/salihgueler)\
**Post date:** [October 9, 2018, 7:41am UTC](https://discuss.circleci.com/t/android-instrumented-test-crash-on-emulator/25637/3 "2018-10-09T07:41:28Z")

</div>

Hi @halfer first of all thank you for the answer.  
EDIT: I have connected with SSH and it seems to not give any crash logs regarding to Android than I would assume it’s related to `in serious low memory situations` problem.  
I tried to call stack trace but it’s giving me some general gradle errors which doesn’t have anything to do with my code. I also tried to dump the logcat errors so I can see it and I have not seen anything there either.  
I have not tried the `dmesg` approach. But if we have low memory issue, what should we do (sorry an Circle newbee here) ?

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [October 9, 2018, 11:26am UTC](https://discuss.circleci.com/t/android-instrumented-test-crash-on-emulator/25637/4 "2018-10-09T11:26:12Z")

</div>

OK, well please try `dmesg` first, so that we can see if that is the problem.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [January 7, 2019, 11:26am UTC](https://discuss.circleci.com/t/android-instrumented-test-crash-on-emulator/25637/5 "2019-01-07T11:26:16Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
