2016-12-02 4 views
4

Ich benutze gitlab-ci, um mein Android-Projekt zu bauen. Nach vielen Recherchen fand ich heraus, wie man SDK-Lizenzen akzeptiert. Aber ich bekomme Lizenz nicht akzeptiert Fehler auf ConstraintLayout Bibliothek. Hier mein .gitlab-ci.yml ist:Wie man Android-Bibliotheklizenzen automatisch von der Befehlszeile akzeptiert?

image: openjdk:8-jdk 

    variables: 
    ANDROID_TARGET_SDK: "25" 
    ANDROID_BUILD_TOOLS: "25.0.0" 
    ANDROID_SDK_TOOLS: "24.4.1" 

    before_script: 
    - apt-get --quiet update --yes 
    - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 
    - wget --quiet --output-document=android-sdk.tgz https://dl.google.com/android/android-sdk_r${ANDROID_SDK_TOOLS}-linux.tgz 
    - tar --extract --gzip --file=android-sdk.tgz 
    - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter android-${ANDROID_TARGET_SDK} 
    - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter platform-tools 
    - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter build-tools-${ANDROID_BUILD_TOOLS} 
    - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-android-m2repository 
    - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-google_play_services 
    - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-m2repository 
    - export ANDROID_HOME=$PWD/android-sdk-linux 
    - chmod +x ./gradlew 
    - chmod +x ./copy_licenses.sh 
    build: 
    script: 
     - ./copy_licenses.sh 
     - ./gradlew assembleDebug 
    artifacts: 
     paths: 
     - app/build/outputs/ 

ich copyed meine Lizenz-Dateien in das $ANDROID_HOME/licenses mit copy_licenses.sh:

#!/bin/bash 
    # fail if any commands fails 
    set -e 
    # debug log 
    set -x 

    cp -a "./android-licenses" "$ANDROID_HOME/licenses" 

nach dieser Ausführung, ich diese Störung erhalte:

FAILURE: Build failed with an exception. 

    * 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 

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

    BUILD FAILED 

Wie akzeptieren ConstraintLayout 1.0.0-beta4 Lizenz von der Kommandozeile?

+0

jede Lösung? Ich habe das gleiche Problem – Jagu

Antwort

-1

Versuchen while true; do echo "y"; sleep 1;done statt echo y

+0

Dies ist kein Problem mit Android SDK-Lizenz akzeptieren. Ich habe das gleiche '.gitlab-ci.yml' in einem anderen Projekt versucht, das' ConstraintLayout' nicht verwendet und der Build erfolgreich ist. – Prime

+0

Es ist möglich, dass Sie mehrere Lizenzen akzeptieren müssen und ich vermute, dass "echo y" das erste tut. – Rince

2

in meinem Fall half die Zugabe before_script: Teil:

- mkdir -p "${ANDROID_HOME}/licenses" 
    - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license" 
    - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "${ANDROID_HOME}/licenses/android-sdk-preview-license" 
    - echo -e "\nd975f751698a77b662f1254ddbeed3901e976f5a" > "${ANDROID_HOME}/licenses/intel-android-extra-license" 
Verwandte Themen