简体   繁体   English

Android项目上与Travis CI的Gradle依赖关系

[英]Gradle dependencies with Travis CI on Android project

I'm having troubles building an Android project with Gradle on Travis CI. 我在使用Travis CI上的Gradle构建Android项目时遇到了麻烦。

I have declared my dependencies like this on my build.gradle: 我在build.gradle上声明了我的依赖项:

dependencies {
    compile 'com.android.support:appcompat-v7:18.0.0'
    compile 'com.android.support:support-v4:18.0.0'
    freeCompile files (
        'libs/GoogleAdMobAdsSdk-6.4.1.jar'
    )
}

This is my .travis.yml script: 这是我的.travis.yml脚本:

script: 
  - TERM=dumb ./gradlew build
  - TERM=dumb ./gradlew connectedInstrumentTest

And I'm getting this on Travis: 我在特拉维斯得到这个:

A problem occurred configuring project ':FlavorTest'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':FlavorTest:_FreeDebugCompile'.
      > Could not find com.android.support:appcompat-v7:18.0.0.
        Required by:
            cloaked-octo-spice:FlavorTest:unspecified
      > Could not find com.android.support:support-v4:18.0.0.
        Required by:
            cloaked-octo-spice:FlavorTest:unspecified

On my local project all seems to work fine. 在我的本地项目上似乎一切正常。 I need to do something else in order to get the dependencies on Travis? 为了获得Travis的依赖,我还需要做些其他事情吗?

Thanks for the help in advance. 我在这里先向您的帮助表示感谢。

I got this solved with some help. 我得到了一些帮助解决了这个问题。 It seems that Gradle couldn't find the Android Support dependencies on the local repository, those needed to be installed with the following command: 似乎Gradle无法在本地存储库中找到Android Support依赖项,需要使用以下命令安装这些依赖项:

android update sdk --filter extra-android-support --no-ui --force > /dev/null
android update sdk --filter extra-android-m2repository --no-ui --force > /dev/null

You can check my .travis.yml file on this public repository ( https://github.com/Ruenzuo/cloaked-octo-cyril ), hope this helps someone else. 您可以在此公共存储库( https://github.com/Ruenzuo/cloaked-octo-cyril )上查看我的.travis.yml文件,希望这可以帮助其他人。

An easier way : 更简单的方法

android:
  components:
    - extra-android-m2repository

You must remeber to accept the license . 您必须记住接受许可 For example adding: 例如添加:

android:
  licenses:
    - android-sdk-license-.+

The answer above is correct. 上面的答案是正确的。 I just thought it'd be worth posting another solution with a travis.yml example. 我只是觉得用travis.yml示例发布另一个解决方案是值得的。 You can find a good one at Pestrada's github site: https://github.com/pestrada/android-tdd-playground/blob/master/.travis.yml 您可以在Pestrada的github网站找到一个好的: https//github.com/pestrada/android-tdd-playground/blob/master/.travis.yml

The relevant lines are: 相关的路线是:

  # Install required components.
  # For a full list, run `android list sdk -a --extended`
  # Note that sysimg-18 downloads the ARM, x86 and MIPS images (we should optimize this).
  # Other relevant API's

  - echo yes | android update sdk --filter platform-tools --no-ui --force > /dev/null
  - echo yes | android update sdk --filter android-18 --no-ui --force > /dev/null
  - echo yes | android update sdk --filter android-19 --no-ui --force > /dev/null
  - echo yes | android update sdk --filter sysimg-19 --no-ui --force > /dev/null
  - echo yes | android update sdk --filter extra-android-support --no-ui --force > /dev/null
  - echo yes | android update sdk --filter extra-android-m2repository --no-ui --force > /dev/null

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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