【发布时间】:2017-12-18 11:37:16
【问题描述】:
我有一个使用 theMovieDB.org API 播放电影的 Android 应用。
我为 travic CI 加密了我的 theMovieDB.org API_KEY:
gem install --user travis
travis encrypt API_KEY = my_api_key --add
因此,基本上,它会创建一个安全密钥并将其存储在 .travis.yml 中。 但这似乎不起作用。我收到以下错误:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
我知道我收到此错误是因为 travis CI 无法找出我的 API_KEY。因为每当我直接使用我的密钥时,travis CI 都会通过构建。 但不幸的是,没有用上面的代码加密那个 KEY。 我正在做他们在文档中提到的一切。
这是我的 .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
【问题讨论】:
-
该错误清楚地表明您的编译失败。是什么让您认为这与 API 密钥有关?在您的程序运行之前,不会使用该密钥。
-
因为当我在没有 API_KEY 的 Android Studio 上编译我的项目时,它给了我完全相同的错误。并且使用 API_key 它成功地在模拟器和实际设备上编译和运行。那么还有什么原因呢?
-
而且当我将 API_KEY 保存在 gradle.properties 文件中,然后在 travis CI 上构建时,它不会给我错误,而是构建成功。但出于安全原因,我不能将我的 API_KEY 保存在 GitHub 存储库中,对吧?
标签: android travis-ci api-key themoviedb-api