Mindjet
Mindjet

Reputation: 51

Travis fails to build Android project, no local.properties

Here is the thing. I've built my project on the Travis CI several times, but got the same problem every time.

The error log:

What went wrong: A problem occurred evaluating root project 'LiteReader'. /home/travis/build/Mindjet/LiteReader/local.properties (No such file or directory)

It's true that the project I uploaded has no local.properties, I've excluded it because it contains information specific to local configuration.

It's my .travis.yml

language: android
cache: bundler

android:
  components:
    - tools
    - build-tools-25.0.2
    - android-25
    - extra-android-m2repository
    - extra-android-support

before_install:
  - chmod +x gradlew

script:
      ./gradlew checkstyle build

How can I solve this problem? Please help, Thanks.

Upvotes: 3

Views: 2566

Answers (3)

Marwa Eltayeb
Marwa Eltayeb

Reputation: 2131

I have the same problem with GitHub Actions CI

The issue is /local.properties (No such file or directory) and it is solved in this way:

- name: Touch local properties
  run: touch local.properties

- name: Add Api Key
  run: echo "apiKey=\"\"" >> local.properties

This will create the file and add your variables (ex: empty API key) to it Then add the code to run the test and it will pass without errors.

- name: Run Tests
  run: ./gradlew test

Upvotes: 5

unnamedhorse
unnamedhorse

Reputation: 1823

A bit late to the party, but I ran into the same issue and found a simpler solution:

before_script:
  - touch local.properties

This will create the file, before running the script, but without the need to create and add a "fake" file into your project.

Upvotes: 6

Petar Marijanovic
Petar Marijanovic

Reputation: 89

I am using CircleCI instead of Travis but I had the same problem :) I fixed it like this, it should do the trick for you, if you can do something like that in Travis (I don't see a reason why you couldn't).

TL;DR

  1. Create the "local.properties.ci" in the same directory of "local.properties"
  2. Put fake data in it so the CI build can pass
  3. Add it to Git
  4. Add the code below in circle.yml:

checkout: post: - cp local.properties.ci local.properties

Upvotes: 1

Related Questions