I have used the Gitlab for run the CI plan.
Problem sequence:
Run the CI plan, with below yaml script, now CI getting passed
Again run the CI plan, now CI getting failed with below error code
warning: failed to remove MediaDrmCts/app/build/outputs/apk/debug/output.json: Invalid argument
Environment:
Gitlab runner in Windows PC
Shell
Yaml Code:
assembleDebug:
stage: build
script:
- echo 'start building...'
- cd MediaDrmCts
- ./gradlew clean assemble
artifacts:
paths:
- MediaDrmCts/app/build/outputs/
debugTests:
stage: test
script:
- cd MediaDrmCts
- ./gradlew -Pci --console=plain :app:testDebug
Error Log:
Please help us to resolve the issue?
This could be related to the issues in GitLab with killing processes on Windows:
tl;dr the windows runner (current version is around ~13.6 with no fix yet) can't kill the full tree of processes started in the job properly, so processes holding file locks are left around for the next job/pipeline to fail on when it attempts to clean up
https://gitlab.com/gitlab-org/gitlab-runner/-/issues/3185
https://gitlab.com/gitlab-org/gitlab-runner/-/issues/3121
I've had similar issues in the past and a workaround is to clean up troublesome directories in the job that makes them, rather than letting the git clean command clean them up in the next job.
One option:
debugTests:
stage: test
script:
- cd MediaDrmCts
- ./gradlew -Pci --console=plain :app:testDebug
after_script:
- if (Test-Path ./MediaDrmCts/app/build) { Remove-Item ./MediaDrmCts/app/build -Recurse -Force; }
...
Another option
If your builds aren't sensitive to how clean the repo folder is, then you can try turning off the git clean -ffdx step in your .gitlab-ci.yml file:
...
variables:
GIT_CLEAN_FLAGS: none
...
which will tell the GitLab runner not to attempt cleaning up the repository of extra files before each run.
Keep in mind that this may have some unintended consequences, such as the wrong files being left over from previous runs on other branches, so be wary, and have good tests!
Related
I am using the Gitlab-ci for the creating the build on the push,I have also creating the .gitlab-ci.yml inside my root directory. With each push the code on the Gitlab , i am getting the following message which are as follow
This job is stuck because you don't have any active runners that can run this job.
I have already enable the Shared Runners in the Setting getting above problem like Not having active member.
Please check my gitlab-ci.yml file data
image: jangrewe/gitlab-ci-android
stages:
- build
before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod +x ./gradlew
cache:
key: ${CI_PROJECT_ID}
paths:
- .gradle/
build:
stage: build
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/
My all push suspended to create the build , please check it once.
Even though i have created the runner manually but they become fail to execute and getting following excetion
ERROR: Job failed (system failure): getting Kubernetes config: invalid configuration: no configuration has been provided
Please help me to short out from the problem. Thanks
If you have active shared-runner, then try to give the tags of the runner in the .gitlab-ci.yml. Say if the tag for the shared-runner is dev-ci, then find below the updated code:
image: jangrewe/gitlab-ci-android
stages:
- build
before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod +x ./gradlew
cache:
key: ${CI_PROJECT_ID}
paths:
- .gradle/
build:
stage: build
tags:
- dev-ci
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/
Screenshot of the runner tags:
Setting up a runner
Before setting up a runner for your project, you need to first:
Install gitlab-runner on a server separate than where GitLab is installed.
Register a runner [there are 3 types of runners: shared, group and specific runners. Depending on requirement, you can choose which runner to register.]
While registering the runner, you need to give tags and the type of runner executor you need.
After registering the runner, go to Project >> Settings >> CI/CD >> Runners, you can see the runner is online. If in case you are using Group or Shared runner, then you need to enable the runner in Project settings.
In your case, you can use Specific Runner with Docker as Runner-Executor and then, in the .gitlab-ci.yml use the tags you provided while registering the runner.
I am writing a Gradle task around Robolectric in Android Studio. How can I delete the jars that it downloads at runtime? I need a clean slate to test my task.
I tried running clean but that didn't cause the jar to be redownloaded on next run.
Is there a command I can run? Or where can I find the directory for downloaded jars?
I could not find a designated clean command, but I found a workaround:
Run test with debug flag -d; can be set either in Preferences>Compiler>Command-line Options, or run from terminal with ./gradlew :app:testDebugUnitTest -d --tests com.package.YourTestClass.testMethod > gradle_log.txt 2>&1
In the logs, search for this: Dependency cache location:
The destination directory be specified on that line. Then you can just remove it rm -r /var/folders/directoryname
I'm building a hybrid app with cordova. The setup has been tested with simple application. Both android and iOS build works fine.
After switching to a more complex application, the following error occurred. I googled and found some suggested solution but none of the worked.
I'm new to this so any suggestion appreciated.
:processArmv7DebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processArmv7DebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/local/Cellar/android-sdk/24.4.1_1/build-tools/23.0.2/aapt'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 28.659 secs
ERROR building one of the platforms: Error code 1 for command: /Users/wliang/work/hzoom/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/wliang/work/hzoom/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
You may not have the required environment or OS to build this project
Error: Error code 1 for command: /Users/wliang/work/hzoom/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/wliang/work/hzoom/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
In my case I discovered the error with the follow command:
cordova build android -- --gradleArg=--info
I have found:
Executing task ':processArmv7DebugResources' (up-to-date check took 0.009 secs) due to:
Input file /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/assets/armv7/debug/www/libs/long/dist/long.min.js.gz has been added.
Starting process 'command '/Users/astaniscia/Library/Android/sdk/build-tools/24.0.2/aapt''. Working directory: /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android Command: /Users/astaniscia/Library/Android/sdk/build-tools/24.0.2/aapt package -f --no-crunch -I /Users/astaniscia/Library/Android/sdk/platforms/android-23/android.jar -M /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/manifests/full/armv7/debug/AndroidManifest.xml -S /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/res/merged/armv7/debug -A /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/assets/armv7/debug -m -J /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/generated/source/r/armv7/debug -F /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/res/resources-armv7-debug.ap_ --debug-mode --custom-package com.navionics.poc -0 apk --output-text-symbols /Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/symbols/armv7/debug --no-version-vectors
Successfully started process 'command '/Users/astaniscia/Library/Android/sdk/build-tools/24.0.2/aapt''
Unable to add '/Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/assets/armv7/debug/www/libs/long/dist/long.min.js.gz': file already in archive (try '-u'?)
ERROR: unable to process assets while packaging '/Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/res/resources-armv7-debug.ap_'
:processArmv7DebugResources FAILED
:processArmv7DebugResources (Thread[Daemon worker Thread 16,5,main]) completed. Took 0.312 secs.
and this line helped me
Unable to add '/Users/astaniscia/Workspace/webapp3.0/webapp3.0/platforms/android/build/intermediates/assets/armv7/debug/www/libs/long/dist/long.min.js.gz': file already in archive (try '-u'?)
for me solve the problem... I removed the gzip and now all work fine!
I had the same issue and this is what I found to be the issue.
The bower components folder - which normally defaults to www/lib/ using cordova - was the culprit in my case.
I had modified one of the bower components, to do that I had to first run npm install inside the specific package that I was updating. After doing that there was a node_modules folder inside the specific component I was updating i.e. www/lib/{name_of_component}/node_modules. Basically this specific node_modules folder is only used for build tools concerning the specific component, and thus it is not needed once you are done updating it and want to build the whole app. Some of the modules inside that specific component's node_modules may conflict with the projects node_modules i.e. {your_app}/node_modules - this can cause problems. In my case the conflict was with the semver module.
So in my case the solution was to delete that specific node_modules folder. After that I could build my app without any issues.
Hopefully this helps.
This is an old issue, but I recently came upon the same one and hope my experience might help someone else in the future.
After a solid day of looking around I realized it had to do with my plugins. For some reason there was an unused dependency in package.json that wouldn't allow it to build.
In my case, it was Firebase, and after removing it from package.json and the plugins folder I ran
cordova platform remove android
and
cordova platform add android
then built it again and all of a sudden it was up and running!
This error shows up because you have one or several accentuated filenames in your project folder. In my case, it was an image with the char "ç".
This topic can help rename automatically: https://superuser.com/questions/617517/remove-all-illegal-characters-from-all-filenames-in-a-given-folder
For me it was the node_modules folder inside www that caused the problem.
The solution is to copy your www to another folder and exclude node_modules and you will be fine.
The thing that worked for me :
cordova plugin add cordova-android-support-gradle-release
Thanks to lohith95
from https://forum.ionicframework.com/t/android-build-broken-after-gradle-dependencies-update-execution-failed-for-task-processdebugresources-com-android-ide-common-process-processexception-failed-to-execute-aapt/109982/170
This is might because you use crosswalk,
You can try the following commands:
sudo ionic cordova platform remove android
sudo rm -rf ./node_modules
sudo npm install --unsafe-perm=true --allow-root
sudo npm install --unsafe-perm node-sass
sudo ionic cordova platform add android#6.4.0
sudo ionic cordova plugin add cordova-android-support-gradle-release
sudo ionic cordova build android
I just updated my gradle from version 2.2 to latest one 2.8. I didn't have any issue with findbugs on version 2.2.
I'm working on an Android project that contains two modules. In order to use find bugs in both modules I have following configuration on main build.gradle file of root directory.
configure(allprojects) {
apply plugin: 'findbugs'
task findbugs(type: FindBugs) {
ignoreFailures = false
effort = "max"
classes = fileTree('build/intermediates/classes/')
source = fileTree('src/main/java')
classpath = files()
excludeFilter = file("exclude.xml")
reportLevel = "high"
reports {
xml.enabled = false
html.enabled = true
}
}
}
When I run ./gradlew findbugs on my local machine everything is fine and build is successful however when I push my PR to Github and Trivis tries to build then I get error:
:findbugs UP-TO-DATE
:passenger-app:findbugs
:passenger-sdk:findbugs FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':passenger-sdk:findbugs'.
> FindBugs rule violations were found. See the report at: file:///home/travis/build/project-name/passenger-android/passenger-sdk/build/reports/findbugs/findbugs.html
I'm really confused why I have no problem on my local machine while Travis shows error! I tried to print out the contents findbugs.html on Travis but I got permission denied :(
I'm using java 1.8 while Travis is using 1.7. Does problem relates to this? Thanks
Update:
In order to print the contents of findbugs.html on Trivis I created a print_findbugs.sh and this is its contents.
#!/usr/bin/env bash
echo '**********************'
echo '*** Print Findbugs ***'
echo '**********************'
echo file:///home/travis/build/company/passenger-android/passenger-sdk/build/reports/findbugs/findbugs.html
Then I set sudo true in my .travis.yml file. What I have in this file.
sudo: true
language: android
android:
components:
- build-tools-23.0.1
- android-23
- extra-android-support
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
env:
global:
// some settings are there
before_cache:
# Delete the gradle lock file which forces creation of a new build cache
- rm ~/.gradle/caches/modules-2/modules-2.lock
cache:
directories:
- ~/.gradle
before_script:
# Overwrite the keystore if it is a pull request
- ./before_script.sh
script:
# Override Travis default script to not run connectedCheck until this bug is fixed:
# https://code.google.com/p/android/issues/detail?id=59592
- ./gradlew clean build findbugs -PdisablePreDex
- ./print_findbugs.sh
before_deploy:
# Clean up the output folder
# Link up the new builds into individual html files
- ./before_deploy.sh
after_deploy:
# Upload to...
and finally my travis prints:
:findbugs UP-TO-DATE
:passenger-app:findbugs
:passenger-sdk:findbugs
FindBugs rule violations were found. See the report at: file:///home/travis/build/company/passenger-android/passenger-sdk/build/reports/findbugs/findbugs.html
BUILD SUCCESSFUL
Total time: 8 mins 9.966 secs
The command "./gradlew clean build findbugs -PdisablePreDex" exited with 0.
$ ./print_findbugs.sh
/home/travis/build.sh: line 41: ./print_findbugs.sh: Permission denied
The command "./print_findbugs.sh" exited with 126.
before_cache
$ rm ~/.gradle/caches/modules-2/modules-2.lock
cache.2
Done. Your build exited with 1.
I don't use it and I need more information about the permission denied.
Html reports
In the past, I printed html reports using Travis-ci, point 5 here. I downloaded lynx using apt-get (it's not possible now using container-infrastructure and sudo: false) and converted and printed the reports.
before_script:
# - echo 'LOGCAT'
# Check logcat debug output: http://developer.android.com/tools/help/logcat.html
# Check debugging log: http://developer.android.com/tools/debugging/debugging-log.html
# Comment the lines belows to debug output and redirect it to a file. Custom tags for your app.
- adb -e logcat *:W | tee logcat.log > /dev/null 2>&1 &
after_failure:
# - echo 'FAILURE'
# Check apt configuration: http://docs.travis-ci.com/user/ci-environment/#apt-configuration
# Comment out the lines below to show log about tests with app name customized on exports section.
- sudo apt-get install -qq lynx
- export MOD_NAME=yourappmodulename
- export LOG_DIR=${TRAVIS_BUILD_DIR}/${MOD_NAME}/build/outputs/reports/androidTests/connected/
- lynx --dump ${LOG_DIR}com.android.builder.testing.ConnectedDevice.html > myConnectedDevice.log
- lynx --dump ${LOG_DIR}com.android.builder.testing.html > myTesting.log
- for file in *.log; do echo "$file"; echo "====================="; cat "$file"; done || true
Xml reports
Can be used in both, legacy and container based infrastructure.
I read you can enable xml reports like this:
reports {
xml.enabled = true
html.enabled = true
}
You can easily print xml reports on Travis-ci using cat like here:
- cat ${TRAVIS_BUILD_DIR}/ui/espresso/*/app/build/outputs/androidTest-results/connected/* # logs
Adding * will include all the subfolders at this point.
You need to first find locally the folder for the xml reports, in my case is not the same folder than html, and add to your travis.yml file something like this:
after_failure:
- cat /home/travis/build/*/passenger-android/passenger-sdk/build/reports/findbugs/*
This doesn't solve your issue but perhaps helps to find reason.
Update:
I suggest you to try to use cat and the xml version without the script first.
A good explanation about the permission issue here and how to solve it making the file executable:
before_script:
- chmod +x yourscript
Update 2:
A better approach to fix the permission denied issue explained here.
Use this and commit the changes:
git update-index --chmod=+x yourscript
In my case, ignoreFailures was true, but nevertheless the findbugs task was failing after upgrading gradle because build.gradle was depending on findbugs:annotations:3.0.0 instead of findbugs:findbugs-annotations:3.0.1. (Note: annotations vs. findbugs-annotations, which is a new artifact.
Finally I was able to get everything passed.
I first used following command rather than simple $ ./gradlew findbugs.
./gradlew clean aGD findbugs -PdisablePreDex
aGD is abbreviation of my task something like assembleDebug.
I could see a lot of complains by gradle. Probably Travis was showing this (afterDebug) but since it prints html page in console is not human readable. So I added filters into Findbug's exclude file (ref) in order to pass Findbugs check.
I was successful! Once I pushed my code, Travis failed again.
But since I printed out Findbug's output on Travis and there was only an issue I could find it in my code and Fix it. After that Travis didn't failed and passed my PR.
So the problem is still exist unfortunately. I can get Findbugs passed on my local project while Travis sometimes finds more issues. I'm suspicious that Travis is able to load recent versions of Findbugs but mine isn't able, due to cache things. But yes, this is my assumption!
Now I'm configuring Travis CI for my Gradle-based Android project. Is it possible to temporary disable tests launch from Travis to just know - if project could be built or not?
By default, Travis-ci executes ./gradlew build connectedCheck if no script: section is found.
Failed tests are ignored if you add the next code to all your tested modules (build.gradle files).
project.gradle.taskGraph.whenReady {
connectedAndroidTest {
ignoreFailures = true
}
}
Another option is to skip the install stage and only to use ./gradlew build (or ./gradle build without gradle wrapper) so tests are not performed.
install:
# Check install section: http://docs.travis-ci.com/user/build-configuration/#install
# If you'd like to skip the install stage entirely, set it to true and nothing will be run.
- true
script:
# By default Travis-ci executes './gradlew build connectedCheck' if no 'script:' section found.
- ./gradlew build
You can use the -x command line argument which excludes any task (see this answer).
gradle build -x test
Check output of
./gradlew tasks
and then use:
./gradlew assemble
Like in this thread:
Gradle build without tests