On the path of cultivation of a cool Android open source project (bottom)

Source: Internet
Author: User

Use of Travis CI

Official website: http://travis-ci.org/

PS: This is public, if you need to use a private, use a. com domain name.
Need to be reminded that: each time the code is submitted will be re-download the required resource files Oh, so the time is very long, wait patiently.

What's the use of Travisci?

TRAVIS-CI is the automated CI tool, similar to the one that big companies often use Jenkins, but Travis-ci is in the cloud, but support GitHub, but also free, we can do a lot of things with travis-ci, not just compile to see if the project has problems. For example, after the project is built, we can package and release the APK to both dandelion, fir, or email to the relevant developers and business tasks. Do some simple processing, easy to loose. This part of the content to the back as soon as possible, in writing an article.

Add GitHub project to Travis-ci
    1. After entering the Travis website, login using GitHub account, after success:
    2. Click the plus sign to see all of your GitHub:
      , if you don't have a project or if you don't have a new project, click the Sync Account button on the top right.
    3. Click here:

      Open Travis build. Click this to configure the project:
    4. The default is empty:
Add the. travis.yml file that TRAVIS-CI requires in your project
    1. Create a. travis.yml file directly under the project root directory.
    2. Add code directly inside the file:

. travis.yml File Source Codes

language: androidjdk: oraclejdk8sudo: falseandroid:  components:    - tools    - build-tools-25.0.2    - android-25    - extra-android-m2repository    - extra-android-support  licenses:      - android-sdk-license-.+      - ‘.+‘before_install:  - chmod +x gradlew  - mkdir "$ANDROID_HOME/licenses" || true  - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"  - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"script:  - ./gradlew assembleRelease

Because the text is long and long, it does not explain the meaning for the time being, so you can look at the official documentation.

Push project to GitHub, TRAVIS-CI automatic monitoring build
    1. Submit to the code and push to GitHub. Auto-build of Travis is automatically triggered.
    2. The following black section is the build process:
      , the white dots on the black box will turn green when clicked, and will automatically scroll to the bottom.

Have a cup of coffee, slowly wait for it, the hardest time has passed, the moment is the time to enjoy.

Back to the home page refresh, you can see:

It means that we have built it successfully.

Travis.yml need to be aware of.

The first time to use the Travis trial, always encountered that some Android protocol is not accepted and build failure, resulting in a day or two, and once wanted to give up, but finally insisted on down, through a variety of search, groping, guessing, finally fix. In fact, the original project is this: Https://github.com/gdky005/TestJitpack, there are a lot of bitter history, from the submission of records can be seen, interested can study, may be able to solve your current problems.

Travis CI protocol Problem Solving method: Http://stackoverflow.com/questions/37615379/travis-ci-build-doesnt-work-with-android-constraint-layout

The most important part is here:

machine:  environment:      ANDROID_HOME: /usr/local/android-sdk-linuxdependencies:  pre:    - mkdir -p "$ANDROID_HOME/licenses"    - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"    - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
Add Travis-ci badge to GitHub

The moment of excitement comes again, let's find out where the badge is.

Let's choose the MARKDONW format:

and copy on.

Also modify readme.md as above.

After adding a space, paste it directly:

What you need to explain here is that if you change it, the icon will be wrapped as well. This will ensure that all the icons are on one line.

Back to the project homepage will be able to find:

Added Travis badge success.

By the way! Above is the most elementary building process, if you encounter unit testing will not be, you have to refer to my open source project Testjitpack. But a little messy, the back of the finishing.

Use of Circle CI

Official website: https://circleci.com/

What is the difference between Circle ci and Travis ci? Need to use it together?

Circle CI is relatively better than Travis CI, at least on the interface. SSH connections are also provided, and the build process is relatively transparent and intuitive. For example:

Travis CI documents more than Circle CI, circle ci data is few.

Travis CI utilization rate is still very high, but Circle ci relatively younger, in line with the mainstream of scientific and technological sense, more intelligent.

When it comes to whether you need to use it together, it's OK, but I have a lot of projects that are used at the same time when I look at GitHub's mainstream projects, and there's no harm in having a skill. In fact, it will be Travis ci, in addition Circle CI is really simple, but the basic grammar is not the same.

Add Project to Circle CI

1. Log in to the main page:

Search for the project you just created under your own account in project.
2. Generally choose Ubuntu directly:

Click Green Build Project.

3. You can see:

But this time it's definitely going to fail because we haven't added the files that Circle needs.

Add the Circle.yml file required by the Circle CI in your project
    1. Add the Circle.yml file at the root of the project;
    2. Add the circle's code to the file:

CIRCLE.YML Source code:

machine:  java:      version: oraclejdk8  environment:      ANDROID_HOME: /usr/local/android-sdk-linuxdependencies:  pre:    - mkdir -p "$ANDROID_HOME/licenses"    - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"    - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"  override:    - echo y | android update sdk --no-ui --filter "android-25"    - echo y | android update sdk --no-ui --filter "build-tools-25.0.2"    - echo y | android update sdk --no-ui --filter "extra-android-m2repository"    - echo y | android update sdk --no-ui --filter "extra-android-support"    - echo y | android update sdk --no-ui --filter "extra-google-m2repositor"    - ./gradlew dependencies || truetest:  override:    - ./gradlew build
Push project to GitHub, Circle CI automatic monitoring build

1. When the code is submitted, it is automatically executed when it is published to Github,circle CI.
2.

When you click here, you will see:

The description has started to build, download what you need:

3. Some steps in the build:

The display is more intuitive than Travis.

4. See

Describes the build success.

Add Circle CI badge to GitHub

Let's find the badge of Circle CI and add it to our GitHub.

We copy the markdown link of the badge and put it into the page of our main project.

Back to the Project home page after refresh:

Very happy, has been added successfully.

What do you add next?

Many of the open source projects on GitHub use Codecov to show unit test results.

Use of Codecov

According to the instructions in the article: we can see an open-source GitHub project Https://github.com/codecov/example-android, but looks dizzy, and groped for a while.

We then built it directly using Trivas CI.

Add items don't say, after entering, click Project Changes to find your project:

After production reports, you can see the results when you enter the site.

Generate reports with Jacoco

Codecov does not support its own build of the test coverage report for Android, it can do is to receive Jacoco generated reports and to visualize

1) Add dependencies to the app's Build.gradle file

        Jacoco generated report dependent Androidtestcompile (' com.android.support.test:runner:0.5 ', {Exclude group: ' Com.android . Support ', module: ' Support-annotations '})//Set the dependency to use JUnit 4 rules androidtestcompile (' COM.A ndroid.support.test:rules:0.5 ', {Exclude group: ' Com.android.support ', module: ' Support-annotations '})//E Spresso-contrib for DatePicker, Recyclerview, Drawer actions, accessibility checks, Countingidlingresource ANDROIDTESTC Ompile (' com.android.support.test.espresso:espresso-contrib:2.2.2 ', {Exclude group: ' Com.android.support ', module: ' support-annotations ' Exclude group: ' Com.android.support ', module: ' support-v4 ' exclude group: ' Com.android . Support ', module: ' appcompat-v7 ' exclude group: ' Com.android.support ', module: ' Design ' exclude group: ' com . Android.support ', module: ' Recyclerview-v7 '}) androidtestcompile (' Com.android.support.test.espresso: espresso-core:2.2.2 ', {exclude Group: ' Com.android.support ', module: ' Support-annotations '}) 

2) set in the Gradle file for the module (app in Androidbadge Project) that needs to build the test coverage report.

debug{        testCoverageEnabled true}

3) You can try to generate a report locally:

./gradlew :app:createDebugAndroidTestCoverageReport 生成测试报告。  app 就是咱们项目中要测试的 module

Test report address: app/build/reports/coverage/debug/index.html.

Report data to Codecov
    1. Log in to https://codecov.io/using your GitHub account and provide authorization to the app.
    2. Add a command to the. travis.yml file to pass the test coverage report to Codecov.

      After_success:
      -Bash < (curl-s Https://codecov.io/bash)

Codecov requires unit testing, so you must add the emulator to the configuration file

Because it has been modified many times, the process is very cumbersome, directly to the configuration file, I believe we can see at a glance.

The complete configuration file is:

Language:androidjdk:oraclejdk8sudo:falseenv:global:-android_api_level=25-android_build_tools_version=25 .0.2-android_abi=armeabi-v7a-android_tag=google_apis-adb_install_timeout=20 # minutes (2 minutes by D Efault) Android:components:-Platform-tools-tools # To install Android SDK tools 25.1.x-build-tools-$ANDROI      d_build_tools_version-android-$ANDROID _api_level-sys-img-armeabi-v7a-google_apis-$ANDROID _api_level licenses: -android-sdk-license-.+-'. + ' Before_install:-chmod +x gradlew-mkdir "$ANDROID _home/licenses" | |  True-echo-e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID _home/licenses/android-sdk-license"-echo-e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID _home/licenses/android-sdk-preview-license" before_ Script: # Create and start Emulator-echo No | Android Create AVD--force-n test-t "android-" $ANDROID _api_level--abi $ANDROID _abi--tag $ANDROID _tag-emulator-AVD Test-no-skin-no-window &-android-wait-for-emulator-adb Shell input keyevent &script:-./gradlew A Ssemblerelease-./gradlew:app:createdebugandroidtestcoveragereport--info--stacktraceafter_success:-Bash < ( Curl-s Https://codecov.io/bash)
Codecov Summary

TRAVIS-CI support for Android unit test is not very good, because the need to turn on the virtual machine, the process is 10 minutes (my test time), very time-consuming. Sometimes it is not connected, and a run down is estimated to be about 20 minutes. So, stability is really not very high. If you do not do unit testing, but just publish and so on, the stability is still high.

Unit testing should be, the standard here is to say that each class and method must be detected, or even if there is no coverage. I have simply written an example of the project here, and the rest of you play it yourself.

So do you want to use unit testing or project-based decisions?

Get Codecov's Badge

Use of Api_level

Let Codecov slowly build it, let's go ahead.

Official website: HTTPS://ANDROID-ARSENAL.COM/API

What's the use of Api_level?

Api_level is a benefit to developers on the Arsenal website, and our Android Open source project generally has a minimum build. Usually we are in the MD file written in support version is 14+ and many other styles, but not eye-catching, with Api_level, open the Open source project home to know, the minimum version is how much. It's easy to understand without looking at the documentation. Some of the features and modifications of the corresponding API can also be shown here.

Api_level How to play?

If the minimum supported version of your open source project is: 14, then choose here:

Copy this down and put it in our MD document.

Use of Codacy

Official website: https://www.codacy.com

What is Codacy?

Codacy Programming Code automatic Review service platform, can help us to analyze the existence of the problem or is a bug, mainly including code quality, grammar specifications, functional usability checks.

How to use Codacy?

Go to the official website and add your own required project.

After the completion, wait a while, will send you an email notification, has been completed.

The effect after completion is:

Our rating for this project is B.

What about the Codacy badge?

Copy it down and put it in the MD document of our project manually. More assured some, if you click on the back of the Add badge, will be automatically added to the project, we need to pull request inside processing.

Create a Personality badge

Official website: https://shields.io/

What's the use?

Show your personal charm and reflect some kind of function. For example let's make a personal badge that jumps to my blog.

How to play?

Scroll to the bottom of the page:

Fill in the corresponding places in the corresponding (also support Chinese OH), after the completion of the click on the Make Badge button after the try.

I think my personal icon is this light blue:

Then I'll write directly in color: 7AD6FD

Click Generate an address, first save the following.

What is this principle? (Answer the first question)

The format of the badge is the markdown format:

[![A\](B)\](D)

A represents the content of the page that needs to be displayed, B is the address of the picture, and D is the address of the link that needs to jump after the click.

Craft my own personal icon.

The image address is stored on top of it. Previous content: Author. According to the above specifications, the result is:

[![作者\](https:\//img.shields.io\/badge\/%E4%BD%9C%E8%80%85-gdky005-7AD6FD.svg)\](http:\//www.gdky005.com)

Paste this code into our MD document, and the personality badge will come out, and click on it to get to where we want to go.

Very cool, in fact, can do a lot of such things.

The project address in this article is: Https://github.com/gdky005/AndroidBadge

If you need to step through the process of the project or follow the steps, you can check the corresponding node to see if the code is different, and then modify it yourself, I have deliberately saved the progress. If a record in Git commits:

I believe that the small partners will certainly be able to make more interesting things, then remember to share with me and others, more distinctive, I will attach your links to the Github project.

On the path of cultivation of a cool Android open source project (bottom)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.