ayltai/Newspaper

Cannot Lanucnh Emulator

Closed this issue · 3 comments

Error coming in CircleCi : EglOsGlLibrary: Could not open GL library libGLESv2.so [libGLESv2.so: cannot open shared object file: No such file or directory]
EglOsEglDispatcher: Could not open EGL library libEGL.so [libEGL.so: cannot open shared object file: No such file or directory]
Received 'segmentation fault' signal

// MY circle.yml file : -

Reference : https://github.com/ayltai/Newspaper/blob/master/.circleci/config.yml

version: 2

references:

Cache

cache_key: &cache_key
key: cache-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
restore_cache: &restore_cache
restore_cache:
<<: *cache_key
save_cache: &save_cache
save_cache:
<<: *cache_key
paths:
- ~/.gradle
- ~/.m2

Workspace

workspace: &workspace
~/workspace
attach_debug_workspace: &attach_debug_workspace
attach_workspace:
at: *workspace
attach_release_workspace: &attach_release_workspace
attach_workspace:
at: *workspace
persist_debug_workspace: &persist_debug_workspace
persist_to_workspace:
root: *workspace
paths:
- app/build/outputs/androidTest-results
- app/build/outputs/apk
- app/build/outputs/code-coverage
- app/build/test-results
persist_release_workspace: &persist_release_workspace
persist_to_workspace:
root: *workspace
paths:
- app/build
attach_firebase_workspace: &attach_firebase_workspace
attach_workspace:
at: *workspace
persist_firebase_workspace: &persist_firebase_workspace
persist_to_workspace:
root: *workspace
paths:
- firebase

Docker image configurations

android_config: &android_config
working_directory: *workspace
docker:
- image: circleci/android:api-27-alpha
environment:
TERM: dumb
_JAVA_OPTIONS: "-Xmx2048m -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m"'

gcloud_config: &gcloud_config
working_directory: *workspace
docker:
- image: google/cloud-sdk:latest
environment:
TERM: dumb

Keys

Android Key Store

export_android_key: &export_android_key
run:
name: Export Android key store environment variable
command: echo 'export ANDROID_KEY_STORE="$ANDROID_KEY_STORE"' >> $BASH_ENV
decode_android_key: &decode_android_key
run:
name: Decode Android key store
command: echo $ANDROID_KEY_STORE | base64 -di > key-store.jks

Google Services

export_gservices_key: &export_gservices_key
run:
name: Export Google Services key environment variable
command: echo 'export GOOGLE_SERVICES_KEY="$GOOGLE_SERVICES_KEY"' >> $BASH_ENV
decode_gservices_key: &decode_gservices_key
run:
name: Decode Google Services key
command: echo $GOOGLE_SERVICES_KEY | base64 -di > app/google-services.json

Google Cloud Service

export_gcloud_key: &export_gcloud_key
run:
name: Export Google Cloud Service key environment variable
command: echo 'export GCLOUD_SERVICE_KEY="$GCLOUD_SERVICE_KEY"' >> $BASH_ENV
decode_gcloud_key: &decode_gcloud_key
run:
name: Decode Google Cloud credentials
command: echo $GCLOUD_SERVICE_KEY | base64 -di > client_secrets.json

Fabric

export_fabric_key: &export_fabric_key
run:
name: Export Fabric key
command: echo 'export FABRIC_KEY="$FABRIC_KEY"' >> $BASH_ENV
decode_fabric_key: &decode_fabric_key
run:
name: Decode Fabric key
command: echo $FABRIC_KEY | base64 -di > app/fabric.properties

jobs:
build_debug:
<<: *android_config
steps:
- checkout
- 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" }}

    - store_artifacts:
        path: app/build/reports
        destination: reports
    - run:
        name: Gradle build (debug)
        command: ./gradlew -PciBuild=true :app:assembleDebug :app:assembleAndroidTest
    - *persist_debug_workspace
    - store_artifacts:
        path: app/build/outputs/apk/
        destination: /apk/
      
## Build release APK

build_release:
  <<: *android_config
  steps:
    - checkout
    - *restore_cache
    - run:
        name: Download dependencies
        command: ./gradlew androidDependencies
    - run:
        name: Gradle build (release)
        command: ./gradlew -PciBuild=true :app:assembleRelease
    - *persist_release_workspace
    - store_artifacts:
        path: app/build/outputs/apk/
        destination: /apk/
    - store_artifacts:
        path: app/build/outputs/mapping/
        destination: /mapping/
      
 ## Run unit tests

test_unit:
  <<: *android_config
  steps:
    - checkout
    - *restore_cache
    - run:
        name: Download dependencies
        command: ./gradlew androidDependencies
    - run:
        name: Run unit tests
        command: ./gradlew -PciBuild=true :app:testDebugUnitTest
    - run:
        name: Run Tests
        command: ./gradlew lint test
    - *persist_debug_workspace
    - store_artifacts:
        path: app/build/reports/
        destination: /reports/
    - store_test_results:
        path: app/build/test-results/
        destination: /test-results/

 ## Run instrumented tests

test_instrumented:
  <<: *gcloud_config
  steps:
    - *attach_debug_workspace
    - *export_gcloud_key
    - *decode_gcloud_key
    - run:
        name: Set Google Cloud target project
        command: gcloud config set project mobius-enterprise-e6854
    - run:
        name: Authenticate with Google Cloud
        command: gcloud auth activate-service-account firebase-adminsdk-vflyj@mobius-enterprise-e6854.iam.gserviceaccount.com --key-file client_secrets.json
    - run:
        name: Run instrumented test on Firebase Test Lab
        command: echo y | apt-get install ant && ant -version clean emma debug install test && gcloud firebase test android run --type instrumentation --app app/build/outputs/apk/debug/app-debug.apk --test app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk --device model=Nexus5X,version=26,locale=en_US,orientation=portrait --environment-variables  EMMA_INSTRUMENT=true,coverage=true,coverageFile=/sdcard/coverage.ec --directories-to-pull=/sdcard  --timeout 20m
        no_output_timeout: 1200
    - run:
        name: Create directory to store test results
        command: mkdir firebase
    - run:
        name: Download instrumented test results from Firebase Test Lab
        command: gsutil -m cp -r -U "`gsutil ls gs://test-lab-ubqdpqunat3jx-k45t9wpaarc4a | tail -1`*" /root/workspace/firebase/
    - *persist_firebase_workspace
    - store_artifacts:
        path: firebase/
        destination: /firebase/

 ## Submit JaCoCo coverage report

report_coverage:
  <<: *android_config
  steps:
    - checkout
    - *restore_cache
    - run:
        name: Download dependencies
        command: ./gradlew androidDependencies
    - *attach_debug_workspace
    - *attach_firebase_workspace
    - run:
        name: Move Firebase coverage report
        command:  mkdir -p app/build/outputs/code-coverage/connected && cp firebase/Nexus5X-26-en_US-portrait/artifacts/coverage.ec app/build/outputs/code-coverage/connected/coverage.ec
    - run:
        name: Setup emulator
        command: sdkmanager "system-images;android-22;default;armeabi-v7a" && echo "no" | avdmanager create avd -n test -k "system-images;android-22;default;armeabi-v7a" --device 'Nexus 4'
    - 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 on -skin 768x1280
        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
          adb shell settings put global window_animation_scale 0
          adb shell settings put global transition_animation_scale 0
          adb shell settings put global animator_duration_scale 0
    - run:
        name: Generate JaCoCo report
        command: ./gradlew createDebugCoverageReport
    - store_artifacts:
        path: app/build/reports/
        destination: /reports/

workflows:
version: 2
workflow:
jobs:
- build_debug
- build_release
- test_unit
- test_instrumented:
requires:
- build_debug
- report_coverage:
requires:
- test_unit
- test_instrumented
#- deploy:
# filters:
# branches:
# only:
# - master
#requires:
# - build_release
#- test_unit
#- test_instrumented

CircleCI 2.0 does not support running Android emulator inside their container because they use Docker. That's why this project shows you how to do it in Firebase Test Lab.

Closing this as this is not related to this project.

@sarthak-kapoor25 - did you find a solution to this issue?