How to display HTML-formatted output files in Travis? - android

I'm trying to deploy an Android library on Bintray using Travis-CI. But when I upload my repo... I got this:
Ran lint on variant release: 6 issues found
Ran lint on variant debug: 6 issues found
Wrote HTML report to file:///home/travis/build/leandroBorgesFerreira/MoreCLoseButton/app/build/outputs/lint-results-debug.html
Wrote XML report to file:///home/travis/build/leandroBorgesFerreira/MoreCLoseButton/app/build/outputs/lint-results-debug.xml
:app:lint FAILED
Normally I would go to my project out put and read the lint-results-debug.html... But I don't know how to access this file in Travis.
So, How can I access outputs/lint-results-debug.html in Travis??
Any help is welcome!
Edit
my .travis.yml:
language: android
jdk: oraclejdk8
sudo: false
addons:
apt:
packages:
- lynx
android:
components:
- platform-tools
- tools
- build-tools-25.0.0
- android-25
- extra-android-m2repository
script:
- if [ -f /home/travis/build/leandroBorgesFerreira/MoreCLoseButton/app/build/outputs/lint-results-debug.html ]; then lynx -dump /home/travis/build/leandroBorgesFerreira/MoreCLoseButton/app/build/outputs/lint-results-debug.html; fi
- ./gradlew -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" build
bintrayUpload --stacktrace --info
env:
global:
- secure: [...]
- secure: [...]

You can use lynx -dump to dump a plain-text rendering of any HTML file output from a Travis run.
To make Travis install lynx -dump: To the top of your .travis.yml, add this:
addons:
apt:
packages:
- lynx
Assuming the HTML file is an error log of some kind, you can make Travis show the output by putting something like the following in the script part of your .travis.yml:
after_failure:
- if [ -f /home/travis/build/…/foo.html ]; then lynx -dump /home/travis/build/…/foo.html; fi

While sideshowbarker gave a generic answer, I'd like to point out that Android lint has an option for console output, so you can do this in your build.gradle:
android {
lintOptions {
textReport = true
//textOutput "stdout" // default location, perfect for travis
}
}
Which removes the need for an extra dependency, and an extra script; plus it's reproducible on local machine easily.
One can take this a step further (in case spamming console on local machine is to be avoided) and do
android {
lintOptions {
textReport = project.property("lint.output.console").toBoolean()
}
}
and in gradle.properties: lint.output.console=false
and in .travis.yml: gradlew -Plint.output.console=true build

Related

Gitlab CI :- Getting pending status after push on the gitlab

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.

Not able to make release APK React Native Android app

i want to make release for android application in react native so when i generate build i got below error message like
Error:Execution failed for task ':app:bundleReleaseJsAndAssets'.
A problem occurred starting process 'command 'node''
see attachment also
any idea how can i solve this ? your all suggestions are appreciable
After spending 2 days I resolved it, Please follow the below steps:-
1) Stop Running Gradle
$ cd RectNatoveProjectName & cd android (Open your project and go to android folder)
$ ./gradlew --stop (Run this command to stop old running Gradle service )
2) Update the android app build gradle
project.ext.react = [
nodeExecutableAndArgs : ["/usr/local/bin/node"]
];
3) Get Node details
$ which node
> (Result will be like "/usr/username/.nvm/versions/node/v10.7.0/bin/node")
4) Link node (very imp step copy the above result in step 3)
- ln -s /usr/username/.nvm/versions/node/v10.7.0/bin/node /usr/local/bin/node
5) If Step - 4 return file exist
- then to go the folder /usr/local/bin/ and delete the "node" file and perform the step -4 again.
6) If Step - 4 run successfully then this node issue will be resolved.
It can have following possible solutions:
1] You need to change the node executable path in your build.gradle(i.e android/app/build.gradle) file as follows:
project.ext.react = [
nodeExecutableAndArgs : ["/usr/local/bin/node"]
];
Or
2] You need to close your Android Studio and need to run below command from project root directory:
cd android
./gradlew assembleRelease
Or
3] You need to simply run "./gradlew --stop" command and then run "./gradlew assembleRelease" command
Add the below following code in app/build.gradle at the end of the file.
afterEvaluate{
android.applicationVariants.all { variant ->
variant.ext.bundleJsAndAssets.enabled = false
}
}

Test FAILED when running Robotium tests on circle-ci

Here is my circleci config file:
# Build configuration file for Circle CI
# needs to be named `circle.yml` and should be in the top level dir of the repo
general:
artifacts:
- "~/build_output.zip" # Save APK's, Lint Results, and Test Results
machine:
environment:
ANDROID_HOME: /usr/local/android-sdk-linux
java:
version: oraclejdk8
dependencies:
cache_directories:
- ~/.android
- ~/android
override:
- (echo "Downloading Android SDK v24...")
- (source environmentSetup.sh && getAndroidSDK)
test:
override:
# start the emulator
- emulator -avd circleci-android22 -no-audio -no-window:
background: true
parallel: true
# wait for it to have booted
- circle-android wait-for-boot
# unlock the emulator screen
- sleep 30
- adb shell input keyevent 82
# run tests against the emulator.
- ./gradlew connectedAndroidTest
# run jUnit tests
- ./gradlew test
# copy the build outputs to artifacts
- cp -r app/build/outputs $CIRCLE_ARTIFACTS
# copy the test results to the test results directory.
- cp -r app/build/outputs/androidTest-results/* $CIRCLE_TEST_REPORTS
Here is a test method:
#Test
public void test_ListRepos_ClickOnOneRepo_DisplayDetailWithOnlyThisRepo() {
Given:
{
final String lsOneRepoJSONData = mLocalifyClient.localify().loadRawFile(fr.guddy.androidstarter.test.R.raw.repos_octocat);
final MockResponse loMockResponseWithOneRepo = new MockResponse().setResponseCode(200);
loMockResponseWithOneRepo.setBody(lsOneRepoJSONData);
mMockWebServer.enqueue(loMockResponseWithOneRepo);
try {
mMockWebServer.start(4000);
} catch (#NonNull final Exception loException) {
loException.printStackTrace();
}
mActivity = mActivityTestRule.launchActivity(null);
}
When:
{
mSolo.clickOnText("git-consortium");
}
Then:
{
mSolo.assertCurrentActivity("should be on ActivityRepoDetail", ActivityRepoDetail.class);
final boolean lbFoundTheRepo = mSolo.waitForText("This repo is for demonstration purposes only.", 1, 5000L, true);
assertThat(lbFoundTheRepo).isTrue();
}
}
And I get test failures in the following builds: https://circleci.com/gh/RoRoche/AndroidStarter/tree/master
Running the same commands locally, I get the following results:
junit.framework.AssertionFailedError:
[
GIVEN A single GitHub repo from the API
WHEN Click on its name and on the back button
THEN It should display the list
]
[
Message: Text string: 'git-consortium' is not found!
]
at junit.framework.Assert.fail(Assert.java:50)
at com.robotium.solo.Clicker.clickOnText(Clicker.java:451)
at com.robotium.solo.Solo.clickOnText(Solo.java:1502)
at fr.guddy.androidstarter.tests.ui.TestActivityRepoList.test_DetailRepos_ClickOnBack_DisplayListRepos(TestActivityRepoList.java:156)
Any idea of how can I configure my circleci build to make it pass?
Thanks in advance.
Looking right at the top of one of your failed builds you'll see the following message: "Your build has exceeded the memory limit of 4G on 1 container.".
Your builds are running out of memory. I'd try and reduce the amount of memory used if possible (https://circleci.com/docs/oom/). If that's a blocker (which sometimes happens with Android), I'd contact CircleCI support to see if they can help you out.

NDK GCC : Could not determine GCC version

I'm trying to execute an Android sample that uses JNI to call C code from a Android Java Activity.
( Hello-jni) using Android Studio in ubuntu 15.04
I get the following error while building my project :
Error:Execution failed for task ':app:
compileHello-jniArm64- v8aDebugAllSharedLibraryHello-jniMainC'.
> No tool chain is available to build for platform 'arm64-v8a':
- Tool chain 'ndk-gcc' (GNU GCC): Could not determine GCC version:
failed to execute aarch64-linux-android-gcc -dM -E -.
Running gradle with the --info flag to determine the command being run:
gradlew :app:compileHello-jniArm64- v8aDebugAllSharedLibraryHello-jniMainC --info
In the output you should see a command containing aarch64-linux-android-gcc -dM -E - with a full path. Check that you do actually have this binary at the path shown (it should have been included in the android ndk).
Assuming you do, try running the command yourself. It will read from stdin and print a bunch of constants to stdout (gradle is trying to parse the version from this), but you want to see stderr:
echo '' | ./aarch64-linux-android-gcc -dM -E - 1>/dev/null
If the command fails, an error should be shown which can hint at the problem. In my case it was trying to include a folder 4.9.x but I had a folder named 4.9. Most likely there will be a different problem with your setup.

After upgrading Gradle to v2.8 Travis doesn't pass Findbugs

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!

Categories

Resources