Travis CI构建失败./gradlew汇编

时间:2017-01-23 15:18:12

标签: java android travis-ci

我尝试使用Travis CI和Codecov构建项目,但是当我使用Travis CI构建时出现此错误

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 31.202 secs

The command "eval ./gradlew assemble" failed. Retrying, 2 of 3.

这是我的.travis.yml

language: java

jdk:
  - oraclejdk8

sudo: required

before_install:
 - chmod +x gradlew

script:
  - ./gradlew clean build -i --continue

after_success:
  - bash <(curl -s https://codecov.io/bash) -t myToken

我已经对before_install了解了很多,但它并没有改变任何事情......

3 个答案:

答案 0 :(得分:4)

您应该在.travis.yml文件中将“语言”设置为android,如下面的链接所示。

请参阅此处的Travis文档:Building an Android Project

答案 1 :(得分:0)

您可以尝试在travis文件中的行下方编写

jdk:openjdk8

您可以检查oracle JDK和Open Jdk之间的区别。没关系,因为两者都获得了oracle的许可,而获得了开放GNU PL的许可,但是如果您希望有特定的区别,可以访问-https://www.baeldung.com/oracle-jdk-vs-openjdk

答案 2 :(得分:-1)

我解决了这个问题:

language: android
sudo: false

before_script:
  - echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
  - emulator -avd test -no-skin -no-audio -no-window &
  - android-wait-for-emulator
  - adb shell input keyevent 82 &

android:
  components:
    # Update Android SDK Tools
    - tools

    - build-tools-25.0.1
    - android-25

    # Support library
    - extra-android-support
    - extra-android-m2repository

jdk:
  - oraclejdk8

sudo: required

before_install:
 - chmod +x gradlew

after_success:
  - bash <(curl -s https://codecov.io/bash) -t token