Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
339 views
in Technique[技术] by (71.8m points)

firebase - Building flutter app remotely through Github Actions Continuous Integration platform cannot find GoogleService-Info.plist file

If I build my app in release mode locally it works, but when I try to do it remotely with continuous integration on Github Actions, I get the error:

error: Build input file cannot be found: '/Users/runner/work/Downloads/GoogleService-Info.plist' (in target 'Runner' from project 'Runner')

Locally the file is in path /Users/benjamin/Downloads/GoogleService-Info.plist. Is the path /Users/runner/work/Downloads/GoogleService-Info.plist potentially incorrect? Any idea how to find out what it should be and how to set it to that? Since it seems kind of like it is trying to store it in the same folder structure but not on my computer. Can I just upload the file to the continuous integration server on Github Actions?

It is run on Github Actions with this workflow file:

flutter-ci.yml:

name: Flutter CI

on:
    push:
        branches: [master]
    pull_request:
        branches: [master]

jobs:
    build:
        runs-on: macos-latest
        steps:
            - uses: actions/checkout@v2
            - uses: subosito/flutter-action@v1
              with:
                  channel: "stable"

            - name: Cache Gradle modules
              uses: actions/cache@v2
              env:
                  cache-number: ${{ secrets.CACHE_NUMBER }}
              with:
                  path: |
                      ~/android/.gradle
                      ~/.gradle/cache
                      # ~/.gradle/wrapper
                  key: ${{ runner.os }}-gradle-${{ env.cache-number }}-${{ hashFiles('android/build.gradle') }}-${{ hashFiles('android/app/build.gradle') }}
                  restore-keys: |
                      ${{ runner.os }}-gradle-${{ env.cache-name }}-${{ hashFiles('android/build.gradle') }}
                      ${{ runner.os }}-gradle-${{ env.cache-name }}-
                      ${{ runner.os }}-gradle-
                      ${{ runner.os }}-

            - name: Cache CocoaPods modules
              uses: actions/cache@v2
              env:
                  cache-number: ${{ secrets.CACHE_NUMBER }}
              with:
                  path: Pods
                  key: ${{ runner.os }}-pods-${{ env.cache-number }}-${{ hashFiles('ios/Podfile.lock') }}
                  restore-keys: |
                      ${{ runner.os }}-pods-${{ env.cache-name }}-
                      ${{ runner.os }}-pods-
                      ${{ runner.os }}-

            - name: Cache Flutter modules
              uses: actions/cache@v2
              env:
                  cache-number: ${{ secrets.CACHE_NUMBER }}
              with:
                  path: |
                      /Users/runner/hostedtoolcache/flutter
                      # ~/.pub-cache
                  key: ${{ runner.os }}-pub-${{ env.cache-number }}-${{ env.flutter_version }}-${{ hashFiles('pubspec.lock') }}
                  restore-keys: |
                      ${{ runner.os }}-pub-${{ env.flutter_version }}-
                      ${{ runner.os }}-pub-
                      ${{ runner.os }}-

            - name: Get flutter dependencies.
              run: make dependencies

            - name: Check for any formatting and statically analyze the code.
              run: make format-analyze

            - name: Run widget tests for our flutter project.
              env:
                  CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
              run: |
                  make unit-test
                  make codecov

            - name: Build ipa and apk
              run: |
                  flutter precache
                  make build-android-prd
                  make build-ios-prd

When that file says "make" it is referencing this make file:

makefile:

.PHONY: setup
setup:
    flutter channel stable
    flutter upgrade
    flutter pub get
    npm install
    cd ios/ && pod install && cd ..

.PHONY: dependencies
dependencies:
    flutter pub get

.PHONY: analyze
analyze:
    flutter analyze

.PHONY: format 
format:
    flutter format lib/

.PHONY: format-analyze
format-analyze:
    flutter dartfmt -n lib
    flutter analyze

.PHONY: build-runner
build-runner:
    flutter packages pub run build_runner build --delete-conflicting-outputs

.PHONY: extract-arb
extract-arb:
    flutter pub pub run intl_translation:extract_to_arb --suppress-last-modified --output-dir=l10n-arb lib/l10n/message.dart

.PHONY: gen-intl
gen-intl:
    flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/l10n/message.dart l10n-arb/intl_messages_*.arb

.PHONY: run-dev
run-dev:
    flutter run --flavor development --dart-define=FLAVOR=development --target lib/main.dart

.PHONY: run-prd
run-prd:
    flutter run --release --flavor production --dart-define=FLAVOR=production --target lib/main.dart

.PHONY: build-android-dev
build-android-dev:
    flutter build apk --flavor development --dart-define=FLAVOR=development --target lib/main.dart

.PHONY: build-android-prd
build-android-prd:
    flutter build apk --release --flavor production --dart-define=FLAVOR=production --target lib/main.dart

.PHONY: build-ios-dev
build-ios-dev:
    cd ios/ && pod install && cd ..
    flutter build ios --no-codesign --flavor development --dart-define=FLAVOR=development --target lib/main.dart

.PHONY: build-ios-prd
build-ios-prd:
    cd ios/ && pod install && cd ..
    flutter build ios --release --no-codesign --flavor production --dart-define=FLAVOR=production --target lib/main.dart

.PHONY: unit-test
unit-test:
    flutter test --coverage --coverage-path=./coverage/lcov.info

.PHONY: codecov
codecov:
    ./scripts/codecov.sh ${CODECOV_TOKEN}

This is the bit that is failing:

.PHONY: build-ios-prd
build-ios-prd:
    cd ios/ && pod install && cd ..
    flutter build ios --release --no-codesign --flavor production --dart-define=FLAVOR=production --target lib/main.dart

Here is the full information about the error on Github Actions:

Run flutter precache
  flutter precache
  make build-android-prd
  make build-ios-prd
  shell: /bin/bash -e {0}
  env:
    FLUTTER_HOME: /Users/runner/hostedtoolcache/flutter/1.22.5-stable/x64
Downloading Android Maven dependencies...                          21.1s
Downloading android-arm-profile/darwin-x64 tools...                 0.5s
Downloading android-arm-release/darwin-x64 tools...                 0.2s
Downloading android-arm64-profile/darwin-x64 tools...               0.2s
Downloading android-arm64-release/darwin-x64 tools...               0.1s
Downloading android-x64-profile/darwin-x64 tools...                 0.2s
Downloading android-x64-release/darwin-x64 tools...                 0.1s
Downloading android-x86 tools...                                    1.0s
Downloading android-x64 tools...                                    0.8s
Downloading android-arm tools...                                    0.4s
Downloading android-arm-profile tools...                            0.2s
Downloading android-arm-release tools...                            0.2s
Downloading android-arm64 tools...                                  0.5s
Downloading android-arm64-profile tools...                          0.2s
Downloading android-arm64-release tools...                          0.2s
Downloading android-x64-profile tools...                            0.2s
Downloading android-x64-release tools...                            0.2s
Downloading android-x86-jit-release tools...                        0.3s
Downloading ios tools...                                            1.6s
Downloading ios-profile tools...                                    1.2s
Downloading ios-release tools...                                    6.5s
flutter build apk --release --flavor production --dart-define=FLAVOR=production --target lib/main.dart
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64,android-x64
        Learn more on: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
        Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleProductionRelease'...              
WARNING: [Processor] Library '/Users/runner/.gradle/caches/modules-2/files-2.1/io.flutter/flutter_embedding_release/1.0.0-ae90085a8437c0ae94d6b5ad2741739ebc742cb4/e616dc757061a6a0f83cca53130d72608e2fded5/flutter_embedding_release-1.0.0-ae90085a8437c0ae94d6b5ad2741739ebc742cb4.jar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.

 Example of androidX reference: 'androidx/annotation/NonNull'

 Example of support library reference: 'android/support/annotation/NonNull'

Note: /Users/runner/hostedtoolcache/flutter/1.22.5-stable/x64/.pub-cache/hosted/pub.dartlang.org/firebase_analytics-6.3.0/android/src/main/java/io/flutter/plugins/firebaseanalytics/FirebaseAnalyticsPlugin.java uses or overrides a deprecated API.

Note: Recompile with -Xlint:deprecation for details.
Running Gradle task 'assembleProductionRelease'...                157.0s (!)
? Built build/app/outputs/flutter-apk/app-production-release.apk (42.9MB).
cd ios/ && pod install && cd ..
Analyzing dependencies
cloud_firestore: Using Firebase SDK version '6.33.0' defined in 'firebase_core'
firebase_analytics: Using Firebase SDK version '6.33.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '6.33.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '6.33.0' defined in 'firebase_core'
Adding spec repo `trunk` with CDN `https://cdn.cocoapods.org/`
Downloading dependencies
Installing BoringSSL-GRPC (0.0.7)
Installing Firebase (6.33.0)
Installing FirebaseAnalytics (6.8.3)
Installing FirebaseAuth (6.9.2)
Installing FirebaseCore (6.10.3)
Installing FirebaseCoreDiagnostics (1.7.0)
Installing FirebaseFirestore (1.18.0)
Installing FirebaseInstallations (1.7.0)
Installing Flutter (1.0.0)
Installing GTMSessionFetcher (1.5.0)
Installing GoogleAppMeasurement (6.8.3)
Installing GoogleDataTransport (7.5.1)
Installing GoogleUtilities (6.7.2)
Installing PromisesObjC (1.2.11)
Installing abseil (0.20200225.0)
Installing cloud_firestore (0.14.4)
Installing cloud_firestore_web (0.1.0)
Installing firebase_analytics (6.3.0)
Installing firebase_analytics_web (0.1.0)
Installing firebase_auth (0.18.4-1)
Installing firebase_auth_web (0.1.0)
Installing firebase_core (0.5.3)
Installing firebase_core_web (0.1.0)
Installing gRPC-C++ (1.28.2)
Installing gRPC-Core (1.28.2)
Installing integration_test (0.0.1)
Installing leveldb-library (1.22)
Installing nanopb (1.30906.0)

Installing path_provider (0.0.1)
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.debug-production.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.debug-production.xcconfig` in your build configuration (`Config/Production.xcconfig`).

[!]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As the error suggests, the Google-Info.plist is not available in the provided path. This happens since your username is not the same as the username used by Github actions and also, you have not loaded it to the Downloads directory. I would suggest checking it into your version control and place it inside the ios directory. Remember to update your references

You could store it somewhere and download it to your Github Actions instance. But loading it directly with the rest of your files is much easier and convenient

Warning!

Google-Info.plist can be checked into source control. But others can misuse it if your services are not well protected by security rules. For open source projects, it is suggested to guide others to setup their own Firebase project. If you are using a private repository then this does not apply. Learn more here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...