The Enablement of Android-based Travis CI
Although we haven’t released our first version of android app, we still need a CI tool to help us have good quality of code. The Travis CI is an excellent CI tool in this area. And the most important is “IT’S FREE for OPEN SOURCE PROJECT”. That’s so great.
I am responsible for enabling the travis CI in WikiCards which is an android project. Before that, we had created a test project based on android test framework in android-test folder.
- ANDROID_SDKS=android-19,sysimg-19 ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a
- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
- emulator -avd test -no-skin -no-audio -no-window &
- adb shell input keyevent 82 &
You may find most of them are the same as the example. And yes, it is copied from example and it works pretty good.
The main difference is we use our-owned wait_for_emulator.sh, which is modified from another open source project. If we use the default android-wait-for-emulator, we may not really wait for emulator to run. It just runs when the emulator is created.
Another one is that we still use ant to build the android project for us. But the ant always returns 0 even if there is some failure in test case of build. That’s a serious problem. So, we write our owned travis.sh script to catch all unit tests logs and exam them line by line to tell travis if our test cases passed or not.