Travis CI Android构建无法检测到Product Flavor目录中的文件

时间:2019-05-01 10:53:22

标签: android travis-ci

我的Android项目有两个产品风味 FlavourOne FlavourTwo 和BuildType Debug Release

我的项目src目录具有

  1. 主要
  2. FlavourOneDebug
  3. FlavourOneRelease
  4. FlavourTwoDebug
  5. FlavourTwoRelease

xxx.xxx.test.constant.FlavourConstant 放置在FlavourOneDebug,FlavourOneRelease,FlavourTwoDebug,FlavourTwoRelease中,而不位于主目录中

放置在主目录中的

xxx.xxx.test.MainActivity 导入 FlavourConstant

这是我的travis.yml

language: android
sudo: required
jdk: oraclejdk8

android:
  components:

  # The BuildTools version used by your project
  - build-tools-26.0.2

  # The SDK version used to compile your project
  - android-26

  # Additional components
  - extra-google-google_play_services
  - extra-google-m2repository
  - extra-android-m2repository

  before_cache:
  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
  - rm -fr $HOME/.gradle/caches/*/plugin-resolution/

  cache:
    directories:
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/
    - $HOME/.android/build-cache

    before_install:
    - mkdir "$ANDROID_HOME/licenses" || true
    - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
    - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"

script:
  - ./gradlew build --stacktrace

Travis CI无法从产品口味目录中引用FlavourConstant。

enter image description here

引用Travis失败的作业https://travis-ci.org/KarthikUCH/MokaTest/jobs/527169383

1 个答案:

答案 0 :(得分:0)

最终设法解决了该问题,这实际上是由风味源集目录命名引起的。

Travis中的Gradle任务期望flavor目录为CaseSensitive。

将目录命名形式flavoruonedebug更改为flavoruoneDebug可解决此问题