Constraint Layout and CircleCI / Travis

Benoît Quenaudon
2 min readOct 16, 2016

--

[Update 2017/03/27] This has been fixed and is working properly now since Android Studio 2.3.0.

At the time of this writing, constraint-layout:1.0.0-alpha9 is out, and it is not possible to build your application on CircleCI (or other continuous integration service I guess). Not possible? Unless you use this ugly and last resort solution.

What the problem is

First, you need to install those dependencies. Either you set the installation command for each one a la carte

- echo y | android update sdk --no-ui --all --filter "tools,build-tools-24.0.2,platform-tools,android-24,extra-android-m2repository"

or you live on the edge and let the android gradle plugin take care of it for you―you still need to import the required license though…

Anyway, once everything is in place and you run your build, here what happens:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to install the following SDK components:
[ConstraintLayout for Android 1.0.0-alpha9, Solver for ConstraintLayout 1.0.0-alpha9]
Please install the missing components using the SDK manager in Android Studio.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

There is an active issue on the Android source project page but it is not likely to be fixed anytime soon.

This seems to be an issue with the underlying SDK manager code. We’ll add more logging in 2.3 previews so we can try to understand what’s going on, as I cannot reproduce the problem.

How to pass through this problem

This is not pretty, I am not proud of it, it is working this very way so I am using it anyway in the meanwhile.

The build fails, but it actually seems to succeeds at what it was supposed to do. I mean that all the required files are there, installed after the failing task ends. I can ./gradlew assemble afterwards and it builds with happy ending. I just make the failing task exit with a success status so the CI is not stopped and… that’s it.

./gradlew dependencies || true

Anyway, I am glad I found a way around this so I can still use constraint layouts in my project and do some CI on the cloud. Here is what my circle.yml looks like now:

dependencies:
pre:
- mkdir -p ${ANDROID_HOME}/licenses
- echo $ANDROID_SDK_LICENSE > ${ANDROID_HOME}/licenses/android-sdk-license
- bash ./misc/download_keystore.sh
override:
# we are cheating because there is a problem with constraint layout ATM
# see: https://code.google.com/p/android/issues/detail?id=212128
- ./gradlew dependencies || true

test:
override:
- ./gradlew clean assemble -Dpre-dex=false --console=plain --stacktrace
- ./gradlew test --console=plain
- ./gradlew lint --console=plain

- cp -r app/build/outputs $CIRCLE_ARTIFACTS
- cp -r app/build/test-results/* $CIRCLE_TEST_REPORTS

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Responses (2)

Write a response