在CircleCI中构建android应用程序测试时找不到gradlew

时间:2018-01-10 13:32:35

标签: android gradle circleci

我有一个Android项目,我想通过在CircleCI 2.0中部署来构建和测试。

执行构建时,我收到错误

*$#!bin/bash -eo pipefail
.gradlew androidDependencies
/bin/bash: ./gradlew: No such file or directory
Exited with Code 127*

version: 2
jobs:
  build:
    working_directory: ~/AndroidDemo
    docker:
      # Android the primary container
      - image: circleci/android:api-25-alpha
environment:
  JVM_OPTS: -Xmx3200m
steps:
  - checkout
  #- restore_cache:
  #    key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
  - run:
      name: Download Dependencies
      command: ./gradlew androidDependencies
 # - save_cache:
  #    paths:
   #     - ~/.gradle
   #   key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}

  #- run:
  #    name: Run UnitTest
  #    command: ./gradlew testDemoDebugUnitTest
  - run:
      name: Setup emulator
      command: sdkmanager "system-images;android-24;default;armeabi-v7a" && echo "no" | avdmanager create avd -n test -k "system-images;android-24;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 connectedDemoDebugAndroidTest
  - store_artifacts:
      path: app/build/reports
      destination: reports
  - store_test_results:
      path: app/build/test-results

我在config.yml文件中设置了工作目录

// AndroidDemo是我的项目所在的地方

working_directory:〜/ AndroidDemo

1 个答案:

答案 0 :(得分:0)

由于不支持1.0,我尝试重构配置文件并移至Circle CI 2.0。

circle.yml文件应放在CircleCI应该克隆的根目录下。

权限应授予gradlew。

chmod +x gradlew

测试下:执行gradlew如下:

./gradlew -Pandroid.testInstrumentationRunnerArguments.class=com.example.android_demo.MyTestsTestSuite connectedAndroidTest -PdisablePreDex

这对我有用。