Anju
Anju

Reputation: 9479

Continuous Deployment throwing error using Github action

I am trying to build debug APK using github actions. But Task 'clean' not found in root project 'My Application'. is shown. I am not able to understand what went wrong.

I have placed android.yml like below:

enter image description here

My android.yml looks like this:

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

EDIT: Checking tasks is a success as shown in the picture. enter image description here

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'

Upvotes: 1

Views: 711

Answers (2)

Anju
Anju

Reputation: 9479

The problem was the root project should have the 'app' within it. It should not be the case like 'app' within another folder which caused me the issue. Here in my case, all the contents of MyApplication should be under CICDSample. Then it will build the app.

This should be the project structure.

enter image description here

My android.yml file looks like this:

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

You can download the artifact from here:

enter image description here

Upvotes: 1

VonC
VonC

Reputation: 1324757

Check first:

You can add a ./MyApplication/gradlew tasks to see how gradle is configured.

Upvotes: 0

Related Questions