'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'


Solution 1:[1]

Check first:

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1