Android Instrumented Test crash on Emulator

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.

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

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.

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.

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) ?

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

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