【问题标题】:Continuous Deployment throwing error using Github action使用 Github 操作的持续部署引发错误
【发布时间】:2022-02-22 19:27:39
【问题描述】:

我正在尝试使用 github 操作构建调试 APK。但是显示了Task 'clean' not found in root project 'My Application'.。我无法理解出了什么问题。

我已经将 android.yml 放在下面:

我的 android.yml 看起来像这样:

name: Android CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8

      - name: Grant execute permission for gradlew
        run: chmod +x ./MyApplication/gradlew

      - name: Build with Gradle
        run: ./MyApplication/gradlew build

      - name: Build debug APK
        run: ./MyApplication/gradlew clean assembleDebug

      - name: Upload APK
        uses: actions/upload-artifact@v1
        with:
          name: Debug App
          path: ./MyApplication/app/build/outputs/apk/debug/app-debug.apk

编辑:检查任务是成功的,如图所示。

Settings.gradle

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
    }
}
rootProject.name = "My Application"
include ':app'
include ':library'

【问题讨论】:

    标签: android kotlin github continuous-integration github-actions


    【解决方案1】:

    问题是根项目中应该包含“应用程序”。它不应该像另一个文件夹中的“应用程序”那样导致我出现问题。在我的例子中,MyApplication 的所有内容都应该在 CICDSample 下。然后它将构建应用程序。

    这应该是项目结构。

    我的 android.yml 文件如下所示:

    name: Android CI
    
    on:
        push:
            branches: [ main ]
        pull_request:
            branches: [ main ]
    
    jobs:
        build:
    
        runs-on: ubuntu-latest
    
        steps:
            - uses: actions/checkout@v2
    
            - name: set up JDK 11
              uses: actions/setup-java@v2
              with:
                  java-version: '11'
                  distribution: 'temurin'
                  cache: gradle
    
            - name: Grant execute permission for gradlew
              run: chmod +x gradlew
    
            - name: Build with Gradle
              run: ./gradlew build
    
            - name: Checking lint
              run: ./gradlew lint
    
            - name: Build debug APK
              run: ./gradlew clean assembleDebug
    
            - name: Upload APK
              uses: actions/upload-artifact@v1
              with:
                  name: Debug App
                  path: ./app/build/outputs/apk/debug/app-debug.apk
    

    您可以从这里下载工件:

    【讨论】:

    • 好收获。做得好。赞成。
    【解决方案2】:

    先检查:

    您可以添加./MyApplication/gradlew tasks 以查看 gradle 是如何配置的。

    【讨论】:

    • 我已经应用了基本插件,并且 settings.gradle 也不存在于 .gitignore 中。我仍然有同样的问题。运行 ./MyApplication/gradlew 任务只是成功。我已经用它的截图编辑了这个问题。
    • @Anju 成功了吗?它应该显示其配置的任务。可以点击Task: tasks前面的>看是否展开并显示更多细节吗?
    • > 在 Task 前面:tasks is not clickable
    • @Anju 好的。那你的settings.gradle 内容是什么?
    • 在问题中添加了相同的内容。 @VonC​​pan>
    猜你喜欢
    • 2022-07-31
    • 2018-06-16
    • 2012-01-03
    • 2020-12-03
    • 2020-10-21
    • 2021-09-14
    • 2018-11-16
    • 2022-01-03
    • 1970-01-01
    相关资源
    最近更新 更多