我正在尝试使用此 circle.yml 文件在CircleCI上构建Android应用
machine:
java:
version: oraclejdk8
environment:
# Java options
JAVA_OPTS: "-Xms512m -Xmx2048m"
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
dependencies:
pre:
# Download and install latest(26.0.2) sdk-tools revision
- wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
- mkdir sdk
- unzip -d sdk sdk-tools-linux-3859397.zip
# Accepts SDK licenses
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
# Install Android SDKs and additional repositories
- echo y | sdk/tools/bin/sdkmanager --channel=2 "build-tools;25.0.3" "platform-tools" "tools"
- echo y | sdk/tools/bin/sdkmanager --channel=2 "extras;google;m2repository" "extras;android;m2repository" "extras;google;google_play_services"
test:
override:
# Generate a debug-apk
- ./gradlew assembleAppseeOffDebug -PdisablePreDex
# Copy the generated apk files to Circle-CI Artifacts
- cp -r app/build/outputs/apk/ $CIRCLE_ARTIFACTS
# Copy the test results to Circle-CI Artifacts
- cp -r app/build/outputs/androidTest-results/* $CIRCLE_TEST_REPORTS
问题是在gradle构建阶段,我遇到了这个错误
Could not find com.google.firebase:firebase-messaging:11.0.1.
Searched in the following locations:
file:/usr/local/android-sdk-linux/extras/m2repository/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
file:/usr/local/android-sdk-linux/extras/m2repository/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
file:/usr/local/android-sdk-linux/extras/google/m2repository/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
file:/usr/local/android-sdk-linux/extras/google/m2repository/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
file:/usr/local/android-sdk-linux/extras/android/m2repository/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
file:/usr/local/android-sdk-linux/extras/android/m2repository/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
http://dl.bintray.com/populov/maven/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
http://dl.bintray.com/populov/maven/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
https://jcenter.bintray.com/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
https://jcenter.bintray.com/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
https://oss.sonatype.org/content/repositories/snapshots/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
https://oss.sonatype.org/content/repositories/snapshots/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
https://jitpack.io/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
https://jitpack.io/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
https://maven.fabric.io/public/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
https://maven.fabric.io/public/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
https://zendesk.artifactoryonline.com/zendesk/repo/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.pom
https://zendesk.artifactoryonline.com/zendesk/repo/com/google/firebase/firebase-messaging/11.0.1/firebase-messaging-11.0.1.jar
我是否在circle.yml文件中没有声明任何sdk依赖项?
答案 0 :(得分:1)
问题在于执行程序(oraclejdk8),它没有安装正确的Android SDK和Google存储库。
我通过从CircleCI 1.0迁移到2.0并将bitriseio/docker-android:latest(默认安装了正确的存储库)设置为docker image来解决问题。
这是我的最终 config.yml
version: 2
jobs:
build:
working_directory: /opt/working
docker:
- image: bitriseio/docker-android:latest
environment:
# Java options
JAVA_OPTS: "-Xms512m -Xmx2048m"
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
steps:
- checkout
- run:
name: Accepts License
command: echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
- run:
name: Assemble & Test
command: ./gradlew assembleDebug testDebugUnitTest
- store_artifacts:
path: app/build/reports/tests/
destination: tests_reports/
- store_test_results:
path: "app/build/test-results/testDebugUnitTest/"
- store_artifacts:
path: app/build/outputs/apk/
destination: apks/