简体   繁体   中英

Travis CI build failed ./gradlew assemble

I'm trying to build project with Travis CI and Codecov, but I'm getting this error when I build with 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.

This is my .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

I've read this a lot about before_install but it doesn't change anything...

You should set your "language" to android in your .travis.yml file as described in the link below.

Referring to the Travis documentation here: Building an Android Project

You could try writing below line in travis file

jdk: openjdk8

You can check the difference between oracle JDK and Open Jdk though. It should not matter as both are licenced one from oracle and one from open GNU PL but if you want specific difference you could visit - https://www.baeldung.com/oracle-jdk-vs-openjdk

I solved with this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM