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
Related
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.
I set up a simple CI work in Github Action for my Android project (Kotlin) that would init unit testing before merging with the master (main) branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout#v3
# Setup JAVA
- name: set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
# Execute unit tests
- name: Unit Test
run: chmod +x ./gradlew test
But whenever i push any commit into directory, i receive next error which fails Unit tests and block merging:
Run chmod +x ./gradlew test
chmod +x ./gradlew test
shell: /usr/bin/bash -e {0}
env:
JAVA_HOME_8.0.342_x64: /opt/hostedtoolcache/jdk/8.0.342/x64
JAVA_HOME: /opt/hostedtoolcache/jdk/8.0.342/x64
JAVA_HOME_8_0_342_X64: /opt/hostedtoolcache/jdk/8.0.342/x64
chmod: cannot access 'test': No such file or directory
Error: Process completed with exit code 1.
I tried to manually set up a directory with tests using working-directory: app/src/ but it throws the same type of error.
What I am doing wrong?
Will provide more info on request. Thanks in advance.
ANSWER: To run unit test in pre-merge, you need to set the correct directory, with the working-directory:, In my case it's :
./app/src/
Changes in workflow .yaml
# List all files (Optional)
- name: ls
run: ls -alrth
- name: add permisiion to gradlew
run: chmod +x ./gradlew
# Execute unit tests
- name: run unit tests
working-directory: ./app/src/
run: chmod +x ./test
I would make multiple RUN commands to ensure where I am and what is in the current folder:
run: pwd
run: ls -alrth
run: chmod +x ./gradlew
run: chmod +x ./test
AS noted by the OP GremlinShX, a working-directory: ./app/src was missing.
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.
According to this answer I should run te following command in order to build an apk and sign it?
./gradlew assembleRelease -Pandroid.injected.signing.store.file=$KEYFILE -Pandroid.injected.signing.store.password=$STORE_PASSWORD -Pandroid.injected.signing.key.alias=$KEY_ALIAS -Pandroid.injected.signing.key.password=$KEY_PASSWORD
And using the android studio I made the following key configuration that is used for building the app:
The generated files in /home/pcmagas/Kwdikas/androidKeys/h330s_fu is contained using the following 2 files:
h300s_fu
private_key.pepk
And the action responsible for building and signing the apk is:
name: pr
on:
push:
branches: [master]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout latest code
uses: actions/checkout#v1
- name: Set up JDK 8
uses: actions/setup-java#v2
with:
java-version: '8'
distribution: 'adopt'
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: test
run: ./gradlew test
- name: build
run: ./gradlew buildRelease
- name: Assemble Release Bundle
run: ./gradlew assembleRelease
Hence the environmental variables:
$KEYFILE
$STORE_PASSWORD
$KEY_ALIAS
$KEY_PASSWORD
Must be configured with github secrets. But what values should I configure for them? I mean what role has the h300s_fu file and the private_key.pepk one?
I'm newbie in bitbucket pipeline and I'm following these steps in: https://bitbucket.org/blog/automate-publishing-your-android-application-with-bitbucket-pipelines-and-gradle to deploy using the android image.
But when I trying to deploy in my bitbucket pipeline repo, returns this error message : './gradlew: No such file or directory '
below my 'bitbucket-pipelines.yml'
definitions:
caches:
npm: ~/.npm
pipelines:
branches:
develop:
- step:
name: Build
image: bitbucketpipelines/android-ci-image
caches:
- gradle
script:
- ls
- echo "$SIGNING_JKS_FILE" | base64 -d > android-signing-keystore.jks
- ./gradlew app:assembleRelease
artifacts:
- app/build/outputs/**
What can I do to resolve this error?
Tks
This means you are missing some gradle wrapper files on your repository. You will need to add gradlew and the folder gradle/wrapper/ to your repository. Check your .gitignore to see if it is currently being ignored. These files are mandatory on the repository if you want to use a pipeline. If you don't have that file and folder locally, you can follow this steps to generate the wrapper:
Make sure you have gradle installed on your machine (e.g. on Mac OSX)
brew install gradle
After that you can generate the wrapper files with this command:
gradle wrapper --gradle-version 6.5
Replace 6.5 with whichever gradle version you use on your project. You can check it on the file gradle-wrapper.properties on the distributionUrl.