Travis CI Android构建失败,显示gradlew文件不存在。

3

我的travis ci构建一直失败,错误信息如下:

$ chmod +x /.gradlew chmod: cannot access ‘/.gradlew’: No such file or directory The command "chmod +x /.gradlew" failed and exited with 1 during .

我尝试了所有的建议,不同的yml文件,但无法解决这个错误。

我的travis yml在根目录下,以下是我的文件夹结构:

根目录:/src .gitignore .travis.yml

src:/client /server

客户端:/app /gradle/wrapper build.gradle gradle.properties gradlew gradlew.bat settings.gradle

以下是我的travis.yml文件:

sudo: false
language: android
jdk:
  - oraclejdk8
android:
  components:
    - tools
    - platform-tools
    - tools

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

    # The SDK version used to compile your project
    - android-25
    - extra-google-google_play_services
    - extra-google-m2repository
    - extra-android-m2repository
    - addon-google_apis-google-19

before_install:
  - chmod +x /.gradlew
script:
- "/.gradlew clean build"
notifications:
  email: false

这是我的build.gradle文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://maven.google.com" }
    }
}
task wrapper(type: Wrapper) {
    gradleVersion = '2.3.3'
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

有什么建议吗?谢谢。
2个回答

2
为了调试这个问题,您可以更改before_install部分以打印当前目录并列出其内容。

before_install:
  - pwd
  - ls -la
  - chmod +x /.gradlew


这实际上很有帮助,我发现它不在正确的目录中,现在我做了before_install:
  • cd src/client
  • pwd
  • ls -la
  • chmod +x /.gradlew
它在正确的目录中列出了所有内容,但仍然显示找不到gradlew,尽管gradlew文件确实存在。
- John Fraks
我通过在 before_script 中添加 cd src/client 而非 before install,使其正常工作了!感谢您的帮助。 - John Fraks
@JohnFraks,请分享一下你的 .travis.yml 文件。 - Lutaaya Huzaifah Idris

0

添加这个 .yml 文件

- name: Check Directory
  run: - pwd
       - ls -la
       - cd android && chmod +x ./gradlew
- name: Build Command
        run: cd android && chmod +x ./gradlew

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接