【问题标题】:CircleCI - SDK location not found for Android Studio projectCircleCI - 未找到 Android Studio 项目的 SDK 位置
【发布时间】:2018-04-04 17:45:32
【问题描述】:

尝试在 CircleCI 上构建项目时,在 gradle 构建过程中出现以下错误。这个问题的原因是什么?我正在运行 CircleCI 2.0

FAILURE:构建失败并出现异常。

  • 出了什么问题:配置项目 ':app' 时出现问题。

    未找到 SDK 位置。使用 local.properties 文件中的 sdk.dir 或使用 ANDROID_HOME 环境变量定义位置。

  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。

  • 通过https://help.gradle.org获得更多帮助

BUILD FAILED in 18s Exited with code 1

这是我的 config.yml 的样子:

# Java Gradle CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-java/ for more details
#
version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/openjdk:8-jdk

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/postgres:9.4

    working_directory: ~/repo

    environment:
      # Customize the JVM maximum heap limit
      JVM_OPTS: -Xmx3200m
      TERM: dumb

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "build.gradle" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run: gradle dependencies

      - save_cache:
          paths:
            - ~/.m2
          key: v1-dependencies-{{ checksum "build.gradle" }}

      # run tests!
      - run: gradle test

【问题讨论】:

    标签: android circleci


    【解决方案1】:

    CircleCI 为 Android 提供了一个 sample configuration,它可以处理您遇到的 SDK 问题。我不确定为什么他们在设置要关注的新项目时不显示此选项。

    基本上,当您在 CircleCI 上设置一个新项目时,您可能选择了 Gradle (Java) 选项。这并不是专门针对 Android 的,所以这就是它抱怨缺少 SDK 的原因。

    上面链接的示例配置如下所示(最重要的部分是指定的 docker 映像,CircleCI 文档对每一行的作用都有很好的解释):

    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
    

    希望你能尽快建设好!

    【讨论】:

    • 谢谢,它对我有用。我还必须取消注释文件中的权限部分:# - run: # name: Chmod permissions #if permission for Gradlew Dependencies fail, use this. # command: sudo chmod +x ./gradlew
    • 对我来说,我收到此错误,配置错误:发生 2 个错误:* 解析配置文件时出错:yaml:第 17 行:找不到预期的 ':' * 找不到名为 @987654324 的作业@ 在配置文件的 jobs: 部分运行。如果您希望工作流运行,请检查您的配置是否包含名为“workflows:”的顶级键
    • 嘿@SreedevR,这听起来像您的 config.yml 文件可能不正确。你有它的链接让我看看吗?
    【解决方案2】:

    我用过这个,它对我有用。 最初一直存在索引问题。代码未正确编入索引。这可能是某人的问题

    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: 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 Tests
          command: ./gradlew lint test
      - store_artifacts:
          path: app/build/reports
          destination: reports
      - store_test_results:
          path: app/build/test-results
    

    【讨论】:

      猜你喜欢
      • 2015-03-30
      • 1970-01-01
      • 2013-10-16
      • 2020-10-30
      • 1970-01-01
      • 2014-10-25
      • 2014-03-05
      • 1970-01-01
      • 2015-11-17
      相关资源
      最近更新 更多