2016-07-05 79 views
9

我現在正在爲我的項目使用CircleCI。另外我在我的項目中實施了約束佈局的新。現在我堅持CircleCI大樓。它顯示了我這個當gradle這個-dependencies運行:CircleCI Android constraintLayout不起作用

File /home/ubuntu/.android/repositories.cfg could not be loaded. 
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: 
    [com.android.support.constraint:constraint-layout:1.0.0-alpha3, com.android.support.constraint:constraint-layout-solver:1.0.0-alpha3]. 
    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 

這是我使用.yml文件中的配置:

#Install android build tools, platforms 
#Supported versions here https://circleci.com/docs/android 
machine: 
    java: 
     version: openjdk8 
    environment: 
     ANDROID_HOME: /usr/local/android-sdk-linux 

dependencies: 
    pre: 
     - echo y | android list sdk 
     - echo y | android update sdk --no-ui --all --filter "tools" 
     - echo y | android update sdk --no-ui --all --filter "platform-tools" 
     - echo y | android update sdk --no-ui --all --filter "build-tools-24.0.0" 
     - echo y | android update sdk --no-ui --all --filter "android-24" 
     - echo y | android update sdk --no-ui --all --filter "extra-google-m2repository" 
     - echo y | android update sdk --no-ui --all --filter "extra-google-google_play_services" 
     - echo y | android update sdk --no-ui --all --filter "extra-android-support" 
     - echo y | android update sdk --no-ui --all --filter "extra-android-m2repository" 
     - (./gradlew -version): 
        timeout: 360 
    override: 
     #- ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies 
     - export TERM="dumb"; if [ -e ./gradlew ]; then ./gradlew clean dependencies -stacktrace;else gradle clean dependencies -stacktrace;fi 

#Pull any submodules 
checkout: 
    post: 
    - git submodule init 
    - git submodule update 

#-PdisablePreDex is a must else gradle just dies due to memory limit 
#Replace 
test: 
    override: 
     - (./gradlew assemble -PdisablePreDex): 
      timeout: 360 
     - cp -r ${HOME}/${CIRCLE_PROJECT_REPONAME}/app/build/outputs/apk/ $CIRCLE_ARTIFACTS 
     - emulator -avd circleci-android22 -no-audio -no-window: 
      background: true 
      parallel: true 
     # wait for it to have booted 
     - circle-android wait-for-boot 
     # run tests against the emulator. 
     - ./gradlew connectedAndroidTest 

#Deploy when tests pass 
deployment: 
    #production: 
    # branch: master 
    # commands: 
    #  - (./gradlew clean assembleRelease crashlyticsUploadDistributionRelease -PdisablePreFex): 
    #   timeout: 720 

    staging: 
     branch: staging 
     commands: 
      - (./gradlew clean assembleStaging crashlyticsUploadDistributionStaging -PdisablePreFex): 
       timeout: 720 

我在生成日誌時

echo y | android update sdk --no-ui --all --filter "extra-android-m2repository" 

命令檢查運行,這裏是結果:

November 20, 2015 
Do you accept the license 'android-sdk-license-c81a61d9' [y/n]: 
Installing Archives: 
    Preparing to install archives 
    Downloading Android Support Repository, revision 33 
    Installing Android Support Repository, revision 33 
    Installed Android Support Repository, revision 33 
    Done. 1 package installed. 

我的類路徑是:

classpath 'com.android.tools.build:gradle:2.2.0-alpha4' 

我不知道我已經做了不正確或者是有什麼我需要增加更多。請建議。 謝謝。

回答

2

TL; DR

您需要從$ANDROID_HOME/licenses許可證複製到CircleCI環境。

您可以壓縮您的許可證並將其存儲在Dropbox(或類似產品)上並修改您的circle.yml文件以下載許可證並將其提取到$ANDROID_HOME

錯誤的最後一段幾乎解釋了它

建設項目之前,你需要接受許可協議並完成使用Android SDK工作室經理缺少的組件的安裝。另外,要學會許可協議從一個工作站轉移到另一個,去http://d.android.com/r/studio-ui/export-licenses.html

+3

謝謝,我終於找到了通過將這些以依賴預先給牌照CI導出方式: - CP -r $ {HOME}/$ {} CIRCLE_PROJECT_REPONAME/Android的SDK許可$ ANDROID_HOME - CP -r $ {HOME}/$ {} CIRCLE_PROJECT_REPONAME/Android的SDK預覽許可證$ ANDROID_HOME 我也把Android的SDK許可和android-sdk-在我的回購預覽許可 – Jutikorn

+1

這是一個偉大的提示!但是我會建議將'android-sdk-license'和'android-sdk-preview-license'的內容作爲兩個獨立的Circle CI環境變量來代替,因爲env vars是受保護的,這對於您的VCS回購。 – dbm

+0

@Jutikorn我可以在哪裏下載呢?我只發現'android-sdk-license' – Spurdow

1

這爲我工作,並且還檢查緩存版本第一:

 
dependencies: 
    pre: 
    # Android SDK Platform 24 
    - if [ ! -d "/usr/local/android-sdk-linux/platforms/android-24" ]; then echo y | android update sdk --no-ui --all --filter "android-24"; fi 
    # Android SDK Build-tools, revision 24.0.1 
    - if [ ! -d "/usr/local/android-sdk-linux/build-tools/24.0.1" ]; then echo y | android update sdk --no-ui --all --filter "build-tools-24.0.1"; fi 
    # Android Support Repository, revision 35/Local Maven repository for Support Libraries 
    - if [ ! -d "/usr/local/android-sdk-linux/extras/android/m2repository/com/android/support/design/24.1.0" ]; then echo y | android update sdk --no-ui --all --filter "extra-android-m2repository"; fi 


    cache_directories: 
    - /usr/local/android-sdk-linux/platforms/android-24 
    - /usr/local/android-sdk-linux/build-tools/24.0.1 
    - /usr/local/android-sdk-linux/extras/android/m2repository 

通過CircleCI從this post兩者員工drazisil

2

我有ConstraintLayout同樣的問題,這是我的工作配置circle.yml

+0

我使用你的.yml文件,但仍然有相同的問題 – codevscolor

+0

最後它的工作。我已經複製了許可證文件夾,它工作:) – codevscolor

2

Alex Fu的回答很好地解釋了問題出在哪裏以及如何處理,但有一個更簡單的解決方案。由於許可證文件實際上只是簡單的文件,其中包含一串十六進制字符,因此您可以在不進行任何複製的情況下創建它們一個例子是把下面的代碼到pre:部分:

- ANDROID_HOME=/usr/local/android-sdk-linux 
- mkdir "$ANDROID_HOME/licenses" || true 
- echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license" 
- echo "84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license" 
- echo "d975f751698a77b662f1254ddbeed3901e976f5a" > "$ANDROID_HOME/licenses/intel-android-extra-license"