to build apk I'm running the command from terminal:
> ./gradlew app:assembleDebug
So I put the command to MyProject/myBashFile.shand run from terminal:
> bash myBashFile.sh
File myBashFile.sh:
#!/bin/bash
./gradlew app:assembleDebug
But when I put the file to dir MyProject/bushFiles/myBashFile.sh and trying to run the command:
> bash bushFiles/myBashFile.sh
Error is:
./gradlew: No such file or directory
Found solution in result MyProject/bushFiles/myBashFile.sh is:
#!/bin/bash
././gradlew app:assembleDevelop
Related
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 new to Android builds with AppCenter and wish to execute all my Apps JUnits.
My app consists of multiple modules that each have their associated JUnits.
However my main App module has no JUnits.
I've tried creating an appcenter-post-build.sh script to execute command ./gradlew test
which fails as follows:-
[command]/bin/bash /Users/runner/work/1/s/app/appcenter-post-build.sh
/Users/runner/work/1/s/app/appcenter-post-build.sh: line 5: ./gradlew: No such file or directory
##[error]The process '/bin/bash' failed with exit code 127
##[error]Bash failed with error: The process '/bin/bash' failed with exit code 127
is there any way I can execute all my Apps modules JUnits via a post build script?
try to add this in your shell script.
cd $APPCENTER_SOURCE_DIRECTORY
chmod a+x ./gradlew
The error on the above title only occurs on this specific project, when I build a Blank project it doesn't get this error. I've tried the other solutions to this problem but I just can't seem to get this working.
Heres the error message:
No scripts found for hook "after_prepare".
No scripts found for hook "before_compile".
ANDROID_HOME=C:\Users\ME\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_211
Running command: cmd "/s /c ""C:\Program Files (x86)\gradle-5.6.2\bin\gradle.bat" -p C:\Windows\System32\QRID2\qrid\platforms\android wrapper -b C:\Windows\System32\QRID2\qrid\platforms\android\wrapper.gradle""
Command finished with error code ENOENT: cmd /s /c ""C:\Program Files (x86)\gradle-5.6.2\bin\gradle.bat" -p C:\Windows\System32\QRID2\qrid\platforms\android wrapper -b C:\Windows\System32\QRID2\qrid\platforms\android\wrapper.gradle"
cmd: Command failed with exit code ENOENT
Error: cmd: Command failed with exit code ENOENT
at ChildProcess.whenDone (C:\Windows\System32\QRID2\qrid\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
at ChildProcess.emit (events.js:198:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
This means ENOENT Error NO ENTity|ENTry so such derectory
check your gradle is located in C:\Program Files (x86)\gradle-5.6.2
Do you have the gradle installed on your machine?
Try it:
1 - download the gradle from the site gradle.org.
Download the .zip file and extract to disk C:\
2 - Set the Gradle Environment Variables.
In order for the Gradle executable to be visible on the Windows command line, you must set the GRADLE_HOME variable and expose it in the system path.
Example:
variable name: GRADLE_HOME
variable value: c:\gradle-2.5
and then add GRADLE_HOME to Path
;%GRADLE_HOME%\bin
Restart your PC and use de command line
gradle -version
To see if it works
I have a Github repository, which is builded on CircleCI. I get following error:
export TERM="dumb" if [ -e ./gradlew ]; then ./gradlew
dependencies;else gradle dependencies;fi bash: line 2: ./gradlew:
Permission denied
export TERM="dumb" if [ -e ./gradlew ]; then ./gradlew
dependencies;else gradle dependencies;fi returned exit code 126
Action failed: gradle dependencies
I can't get what is this caused by, because I give necessary permissions in circle.yml file.
test:
override:
- echo y | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-21.1.2,android-21,extra-google-m2repository,extra-google-google_play_services,extra-android-support
- chmod 777 gradlew
- chmod a+x gradlew
- ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies
- ./gradlew testVanillaDebugUnitTest -PdisablePreDex
- echo "y" | sudo /opt/google-cloud-sdk/bin/gcloud beta test android run --app app/build/outputs/apk/app-vanilla-debug.apk --test app/build/outputs/apk/app-vanilla-debug-androidTest.apk --device-ids Nexus5 --os-version-ids 22 --locales en --orientations portrait
run: chmod +x gradlew
run: ./gradlew assemble
So, first set permission, then run the command you want
Looking at you circle.yml (found here), the failure is not from lines #25 or #26, it's line #14.
Please notice that order of execution is
dependencies:pre
dependencies:post
test:override
test:post
So what you need to do is remove lines 23, 24 and add chmod +x gradlew as the first command in dependencies:pre
Using Travis CI for an existing Android project calling
$ ./gradlew build connectedCheck
I get this error:
/home/travis/build.sh: line 45: ./gradlew: Permission denied
The command "./gradlew build connectedCheck" failed and exited with 126 during .
It depends by the exec-permission to your unix gradlew script.
It can be fixed using the command:
git update-index --chmod=+x gradlew
A little desciption to understand the problem.
First of all you can check your permissions using:
git ls-tree HEAD
You will see:
100644 blob xxxxxxxxxxx gradlew
As you can see the file has 644 permission.
Fix it by setting the executable flag on your gradlew file changing it to 755:
git update-index --chmod=+x gradlew
Just commit and push the changes:
git commit -m "permission access for travis"
[master e80ab1b] gradlew permission access for travis
1 file changed, 0 insertions(+), 0 deletions(-)
mode change 100644 => 100755 gradlew
A last check running git ls-tree again to see the change:
git ls-tree HEAD
You can see:
100755 blob xxxxxxxxxxxxx gradlew
Another way to solve this issue is to use:
before_install:
- chmod +x gradlew
This kind of solution doesn't change the permission in your git repo, but just changes the permission runtime in the execution.
script:
- chmod +x ./gradlew build connectedCheck
Thanks all.
This code is available.
The key focus is on chmod +x