Continuous Deployment throwing error using Github action - android

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

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.
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:

Check first:
that your gradlew clean is executed from the root folder of your project,
and that your settings.gradle is not in your .gitignore in that same repository.
The root folder is MyApplication, not My Application.
You can add a ./MyApplication/gradlew tasks to see how gradle is configured.

Related

GitHub Actions ./gradlew build job succeed but does not create build directory

I am trying to make CI process with GitHub Actions for Android project. Before making a real process, the goal is to build gradle and debug apk file automatically.
The job succeed for each step, however, neither build directory nor apk file is being created.
I read various posts and tried each post suggests, but nothing gave me a solution.
What part do I need to change to get the desired result?
Firstly, Below is log I got from ./gradlew build command. It says that the process definitely has gotten into :app:build
> Task :app:lintDebug
> Task :app:lint
> Task :app:check
> Task :app:build
BUILD SUCCESSFUL in 1m 22s
And here is a GitHub Actions Job I made.
Android_CI_Test.yml
name: Android CI Test
on:
pull_request:
branches:
- main
- release
- dev
- staging
push:
branches:
- main
- release
jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- name: Set Up java
id: set_up_java
uses: actions/setup-java#v3
with:
java-version: 11
distribution: "corretto"
- name: Set Android SDK
uses: android-actions/setup-android#v2
- name: Cache Gradle
uses: actions/cache#v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/buildSrc/**/*.kt') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grand Gradlew Permission
id: grand_gradlew_permission
run: chmod +x ./gradlew
- name: Validate Gradlew
id: validate_gradlew
uses: gradle/wrapper-validation-action#v1
- name: Set Up Gradle
id: set_up_gradle
uses: gradle/gradle-build-action#v2
- name: Build
id: build_gradle
run: ./gradlew build
- name: Build debug APK
id: build_debug_apk
run: ./gradlew assembleDebug --stacktrace
I tried changing Grand Gradlew Permission to chmod +x ./gradlew , changing Build debug APK to bash ./gradlew assembleDebug or ./gradlew app:assembleDebug but none of them has succeeded.

Create a Github action workflow for android

I am using this workflow but getting error in this
name: react-native-android-build-aab
on:
push:
branches:
- master
jobs:
install-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Install npm dependencies
run: |
npm install
build-android:
needs: install-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Install npm dependencies
run: |
npm install
- name: Build Android Release
run: |
cd android && ./gradlew bundleRelease
- name: Upload Artifact
uses: actions/upload-artifact#v1
with:
name: app-release.aab
path: app/build/outputs/
Upload Artifact error
0s
Run actions/upload-artifact#v1
Error: Path does not exist /home/runner/work/appwe/appwe/app/build/outputs/
Error: Exit code 1 returned from process: file name '/home/runner/runners/2.294.0/bin/Runner.PluginHost', arguments 'action "GitHub.Runner.Plugins.Artifact.PublishArtifact, Runner.Plugins"'.
Tried multiple solutions but nothing worked. if try the above github action with .apk it works fine. So please let me know how can i create a bundle with action. Thanks

cannot access './gradlew': No such file or directory Github actions

I am using workflow on GithubActions but getting the following error:
chmod: cannot access './gradlew': No such file or directory
Error: Process completed with exit code 1.
Following is my workflow.yml file
name: Android CI
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew build
I tried you change chmod command in a different way but non of execution succeed, but same workflow on my other project is working file i don't know whats the issue, Any help highly appreciated. Thanks
I tried to change chmod command in a different way
That wouldn't change the fact the file itself (gradlew) seems to be missing.
I would check if it is anywhere (run: find / -type f -name "gradlew"), considering the actions/setup-java is supposed to include Gradle.
That would be just for testing, as a first step:
- name: Look for gradlew
run: find / -type f -name "gradlew"
- name: Change wrapper permissions
...
If it is in the $PATH, this issue suggests:
I changed
"./gradle build" to "gradle build" in Build with Gradle step.
That solved the issue. (see gradle-publish.yml)
Instead of using ./gradlew, try using gradle. This worked for me.
This solution here helped me solve the same problem. You just have to change the gradlew file permission using this code: Run this on the terminal
git update-index --chmod=+x gradlew
git commit -m "Make gradlew executable"
I also removed chmod +x from my workflow.yml file after changing the gradlew file permissions
I have faced the same issue and I found someone change it to
name: gradlew
run: gradle
enter image description here
with removing "./" and "w"
and worked for me
It's possible that you don't initialise wrapper.
You can try clone your repository from scratch and the exetuce ./gradlew build command. If it's failed. Try use the
gradle wrapper
This command init your wrapper and you can see which files was generated and required for ./gradlew
Finally, You have two options:
Run gradle wrapper locally and push required files
or
Add extra step to init wrapper during the workflow
...
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Init gradle wrapper
run: gradle wrapper
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Build with Gradle wrapper
run: ./gradlew build

android with github actions

I'm trying to automate my versioning in android using actions, its my first time using this technology
so I have 3 commands:
./gradlew bumpPatch
./gradlew bumpMinor
./gradlew bumpMajor
How can I determinate which one execute from a PR to master for example :
branch fix/foo --> execute ./gradlew bumpPatch
branch feat/foo --> execute ./gradlew bumpMinor
branch perf/foo --> execute ./gradlew bumpMajor
and how I can do it.
I'm following semantic release so maybe it's better execute the command from the commit message but still don't know how to do both so help it's appreciated.
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 gradlew
- name: Build with Gradle
run: ./gradlew build
Use the following workflow. It only triggers on pull requests against main. It uses conditional steps (if) with an expression that uses the function startsWith.
name: Android CI
on:
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 gradlew
- run: ./gradlew bumpPatch
if: startsWith(github.head_ref, 'fix/')
- run: ./gradlew bumpMinor
if: startsWith(github.head_ref, 'feat/')
- run: ./gradlew bumpMajor
if: startsWith(github.head_ref, 'perf/')
- name: Build with Gradle
run: ./gradlew build

Add artifact from github actions to releases

So im trying to implement a release section on my yml file for a generated artifact, explaining myself: i would like to add an artifact to my releases with my yml file.
Here's the only yml file am working on for an android app:
name: Android CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- run: mkdir -p app/build/outputs/apk/release
- run: echo hello > app/build/outputs/apk/release/app-release-unsigned.apk
- uses: actions/upload-artifact#v2
with:
name: my-artifact
path: app/build/outputs/apk/release/app-release-unsigned.apk
- name: set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
- name: Permition Gradlew
run: chmod +x gradlew
- name: Build Gradlew
run: ./gradlew assembleRelease
The actions/upload-artifact#v2 Action is meant for uploading artifacts to GitHub Actions workflow runs, not for adding assets to a GitHub release. If you want to add build assets to a GitHub release, you should instead use the softprops/action-gh-release example described here. I've modified the example to match your specific scenario:
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Upload Release Asset
jobs:
build:
name: Upload Release Asset
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout#v2
- name: Build project
run: |
mkdir -p app/build/outputs/apk/release
echo hello > app/build/outputs/apk/release/app-release-unsigned.apk
- name: Release with Notes
uses: softprops/action-gh-release#v1
with:
files: app/build/outputs/apk/release/app-release-unsigned.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
You can repeat the final step as needed with different paths for adding further artifacts to the release.

Categories

Resources