test:
  pre:
    # start the emulator
    - emulator -avd circleci-android22 -no-audio -no-window:
        background: true
        parallel: true
    # wait for it to have booted
    - circle-android wait-for-boot
  override:
    - ./gradlew test assembleDebug
    - ./gradlew connectedAndroidTest
    # Capture screenshot of emulator
    - adb shell screencap -p /sdcard/screen.png
    - adb pull /sdcard/screen.png $CIRCLE_ARTIFACTS
    - adb shell rm /sdcard/screen.png
  post:
    - cp -r app/build/outputs $CIRCLE_ARTIFACTS
    # copy the test results to the test results directory.
    - mkdir -p $CIRCLE_TEST_REPORTS/junit/
    - find app/build/test-results -name "*.xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
    - cp -r my-project/build/outputs/androidTest-results/* $CIRCLE_TEST_REPORTS

test:
  pre:
    # start the emulator
    - emulator -avd circleci-android22 -no-audio -no-window:
        background: true
        parallel: true
    # wait for it to have booted
    - circle-android wait-for-boot
  override:
    - ./gradlew test assembleDebug
    - ./gradlew connectedAndroidTest
    # Capture screenshot of emulator
    - adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > $CIRCLE_ARTIFACTS/screen.png
  post:
    - cp -r app/build/outputs $CIRCLE_ARTIFACTS
    # copy the test results to the test results directory.
    - mkdir -p $CIRCLE_TEST_REPORTS/junit/
    - find app/build/test-results -name "*.xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
    - cp -r my-project/build/outputs/androidTest-results/* $CIRCLE_TEST_REPORTS

Change screenshot code to not save on emulator
Change screenshot code to not save on emulator