简体   繁体   中英

ConstraintLayout issue with circleci on Android

I am having the following build failure on circleci for my android project :

  • What went wrong: A problem occurred configuring project ':app'. You have not accepted the license agreements of the following SDK components: [Solver for ConstraintLayout 1.0.0-beta4, ConstraintLayout for Android 1.0.0-beta4]. Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager. Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

I am using the following circle.yml for build:

test:
override:
    - (./gradlew assemble):
        timeout: 360

dependencies:
    pre:
  # Android SDK Platform 24
  - if [ ! -d "/usr/local/android-sdk-linux/platforms/android-25" ]; then echo y | android update sdk --no-ui --all --filter "android-25"; fi
  # Android SDK Build-tools, revision 25.0.1
  - if [ ! -d "/usr/local/android-sdk-linux/build-tools/25.0.1" ]; then echo y | android update sdk --no-ui --all --filter "build-tools-25.0.1"; fi
  # Android Support Repository, revision 40 / Local Maven repository for Support Libraries
  - if [ ! -d "/usr/local/android-sdk-linux/extras/android/m2repository/com/android/support/support-v4/25.0.1" ]; then echo y | android update sdk --no-ui --all --filter "extra-android-m2repository"; fi
  # Google Support Repository, revision 40 / Local Maven repository for Support Libraries
  - if [ ! -d "/usr/local/android-sdk-linux/extras/google/m2repository/com/google/firebase/firebase-core/10.0.1" ]; then echo y | android update sdk --no-ui --all --filter "extra-google-m2repository"; fi
  - mkdir $ANDROID_HOME/licenses; ls -l $ANDROID_HOME/licenses
  - cp --force licenses/* $ANDROID_HOME/licenses; ls -l $ANDROID_HOME/licenses


cache_directories:
  - /usr/local/android-sdk-linux/platforms/android-25
  - /usr/local/android-sdk-linux/build-tools/25.0.1
  - /usr/local/android-sdk-linux/extras/android/m2repository
  - /usr/local/android-sdk-linux/extras/google/m2repository

override:
# Adding true flag because of this issue with ConstraintLayout https://code.google.com/p/android/issues/detail?id=212128
  - ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies || true
machine:
    java:
        version: oraclejdk8
    environment:
        ANDROID_HOME: /usr/local/android-sdk-linux

What might be the cause of this problem ?

It seems that android is deprecated or being replaced with sdkmanager as a package manager. For example, in my case, sdkmanager has access(lists) to the ConstraintLayout and ConstraintLayout Solver packages, but android does not.

For more info on sdkmanager , visit the official docs

In my case, I also had to update the sdk tools using android in order to have sdkmanager installed. The install location is not in the tools folder, though, but tools/bin , so I also had to access sdkmanager directly, as it wasn't included in $PATH on my CI machine.

Applying all this to your case:

  # Android SDK Platform 24
  - if [ ! -d "/usr/local/android-sdk-linux/platforms/android-25" ]; then echo y | android update sdk --no-ui --all --filter "android-25"; fi
  # Android SDK Build-tools, revision 25.0.1
  - if [ ! -d "/usr/local/android-sdk-linux/build-tools/25.0.1" ]; then echo y | android update sdk --no-ui --all --filter "build-tools-25.0.1"; fi
  # Android Support Repository, revision 40 / Local Maven repository for Support Libraries
  - if [ ! -d "/usr/local/android-sdk-linux/extras/android/m2repository/com/android/support/support-v4/25.0.1" ]; then echo y | android update sdk --no-ui --all --filter "extra-android-m2repository"; fi
  # Google Support Repository, revision 40 / Local Maven repository for Support Libraries
  - if [ ! -d "/usr/local/android-sdk-linux/extras/google/m2repository/com/google/firebase/firebase-core/10.0.1" ]; then echo y | android update sdk --no-ui --all --filter "extra-google-m2repository"; fi

  # Android Tools latest (has sdkmanager)
  - if [ ! -d "/usr/local/android-sdk-linux/tools/bin/sdkmanager" ]; then echo y | android update sdk --no-ui --all --filter "tools"; fi
  # ConstraintLayout
  - if [ ! -d "/usr/local/android-sdk-linux/extras/m2repository/com/android/support/constraint/constraint-layout/1.0.0-beta4" ]; then echo y | /usr/local/android-sdk-linux/tools/bin/sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout;1.0.0-beta4"; fi
  # ConstraintLayout Solver
  - if [ ! -d "/usr/local/android-sdk-linux/extras/m2repository/com/android/support/constraint/constraint-layout-solver/1.0.0-beta4" ]; then echo y | /usr/local/android-sdk-linux/tools/bin/sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-beta4"; fi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM