圈子CI集成

时间:2017-08-17 17:15:22

标签: android circleci

我基本上正在尝试将Android应用与CircleCI集成。

我根据文档提供了以下2.0版配置文件。

version: 2

jobs:
  build:
    docker:
      - image: circleci/openjdk:8-jdk

      working_directory: ~/repo

      environment:
        ANDROID_HOME: /usr/local/android-sdk-linux
        JVM_OPTS: -Xmx3200m
        TERM: dumb

     dependencies:
       pre:
         - echo y | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-23.0.1,android-23,extra-google-m2repository,extra-google-google_play_services,extra-android-support,extra-libs/android-support-v7-cardview.jar,extra-libraryForFloatingButton,extra-libs/engine.io-client-0.5.0.jar,extra-libs/httpmime-4.2.5.jar,extra-libs/okhttp-2.3.0.jar,extra-libs/okhttp-ws-2.3.0.jar,extra-libs/okio-1.3.0.jar,extra-libs/socket.io-client-0.5.0.jar,extra-com.crashlytics.sdk.android:crashlytics:2.5.5@aar
         - chmod +x gradlew
         - ANDROID_HOME = /usr/local/android-sdk-linux ./gradlew dependencies

    steps:
      - checkout
      - run: gradle dependencies    
      - run: gradle test

我现在收到如下错误。我无法找到任何解决方案以及CircleCI Config 2.0的任何可靠模板。

NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  
It is currently set to /usr/local/android-sdk-linux/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '/usr/local/android-sdk-linux' does not exist.

1 个答案:

答案 0 :(得分:1)

看起来您没有使用适用于Android的正确Docker镜像。 Per documentation它应该是:

docker:
  - image: circleci/android:api-25-alpha

或者预装Android SDK的那种东西。 Here's可用的Docker镜像列表。

以下是我在上面发布的链接中的示例配置:

version: 2
jobs:
  build:
    working_directory: ~/code
    docker:
      - 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 Tests
          command: ./gradlew lint test
      - store_artifacts:
          path: app/build/reports
          destination: reports
      - store_test_results:
          path: app/build/test-results