-2

I have an android app which shows movies using theMovieDB.org API.

I've done the following for encrypting my theMovieDB.org API_KEY for travic CI:

    gem install --user travis
    travis encrypt API_KEY = my_api_key --add

So, basically, it creates a secure key and stores it in .travis.yml. But it does not seem to work. I'm getting following error:

    Execution failed for task ':app:compileDebugJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.

I know I'm getting this error because travis CI couldn't figure out my API_KEY. Because whenever I use my key directly, travis CI passes the build. But unfortunately not with encrypting that KEY with above code. I'm doing everything they've mentioned in the Documentation.

This is my .tavis.yml:

language: android

env:
  global:
    secure: some_lengthy_secure_key

android:
    components:
            - platform-tools
            - build-tools-25.0.3
            - android-25
            - extra-android-m2repository
script:
    - ./gradlew build

before_install:
    - chmod +x gradlew

branches:
    only:
            - master

This is my Project: https://github.com/Parag2385/PopularMovies-P

Parag Pawar
  • 827
  • 3
  • 12
  • 23
  • The error clearly indicates that your *compilation* is failing. What makes you think that has anything to do with the API key? That key won't be used until your program runs. – Jonathon Reinhart Dec 18 '17 at 11:41
  • Because when I compile my project on Android studio without API_KEY it gives me the exact same error. And with API_key it successfully complies and run on emulator and also on the actual device. So what else reason could be there? – Parag Pawar Dec 18 '17 at 12:16
  • And also when I keep my API_KEY in gradle.properties file, and then build on travis CI it does not give me the error, instead build passes successfully. But for security reason, I can't keep my API_KEY in a GitHub repo, right? – Parag Pawar Dec 18 '17 at 12:21

1 Answers1

0

I would agree with the commenters that your diagnosis does not seem to match the error that you describe. Anyhow:

Could you remove the spaces around travis encrypt API_KEY = my_api_key --add, so that it becomes:

travis encrypt 'API_KEY=my_api_key' --org -r Parag2385/PopularMovies-P

Please note some additional changes:

  • Added quotes around the variable assignment. Please check that there are no single quotes in the key.
  • Added some things to ensure the right project on the right endpoint is selected
  • removed the --add thing, so please copy the resulting string into the appropriate place in .travis.yml. This is so you have the opportunity to remove the previous, wrong entry :)
joepd
  • 4,681
  • 2
  • 26
  • 27