【问题标题】:CircleCI using absolute path, not relativeCircleCI 使用绝对路径,而不是相对路径
【发布时间】:2016-11-14 02:00:39
【问题描述】:

我正在使用 CircleCI 构建一个 Android 应用程序,并在项目中编译一个 Android 库作为依赖项。但是,我在 CircleCI 构建期间收到以下错误:

A problem occurred configuring project ':aModule'.
> The SDK directory '/home/myname/Android/Sdk' does not exist.

看起来 CircleCI 正在尝试使用一些构建工具来编译模块,但由于它在我的机器上使用绝对路径而失败。如果可能,我将如何配置 CircleCI 以使用 Android SDK 的本地路径?

如果需要,这也是我的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "com.myapp.app"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "0.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),     'proguard-rules.pro'
        }
    }
}

repositories {
    maven {
        url "http://dl.bintray.com/glomadrian/maven"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    wearApp project(':wear')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:cardview-v7:24.0.0'
    compile 'com.github.medyo:fancybuttons:1.8.1'
    compile 'com.github.glomadrian:roadrunner:1.0@aar'
    compile 'com.afollestad.material-dialogs:core:0.8.6.1'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.16'
    compile 'com.android.support:design:24.0.0'
    compile 'com.github.PhilJay:MPAndroidChart:v3.0.0-beta1'
    compile 'joda-time:joda-time:2.9.4'
    compile project(':aModule')
}

* 更新:SDK 路径是在我项目的 local.properties 中设置的

【问题讨论】:

标签: android gradle android-gradle-plugin build-automation circleci


【解决方案1】:

对我来说,解决方案是在 circle.yml 文件中使用以下内容

#
# Build configuration for Circle CI
#

general:
    artifacts:
        - /home/ubuntu/your-app-name/app/build/outputs/apk/

machine:
  environment:
    ANDROID_HOME: /usr/local/android-sdk-linux
    GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
  java:
    version: oraclejdk8

checkout:
  post:
    - git submodule sync
    - git submodule update --init

dependencies:
    pre:
        - echo y | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-25.0.2,android-25,extra-google-m2repository,extra-google-google_play_services,extra-android-m2repository,extra-android-support
        - chmod +x gradlew
        - ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies

test:
    override:
        - (./gradlew assemble):
            timeout: 360

gradlew 和设置 ANDROID_HOME=/usr/local/android-sdk-linux 的权限似乎是需要的......

但我已经使用circleci 大约 30 分钟...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-23
    • 1970-01-01
    • 1970-01-01
    • 2010-09-17
    相关资源
    最近更新 更多