EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 444 forks source link

Plugin with id 'com.google.gms.google-services' not found. #1538

Closed MitchTalmadge closed 4 years ago

MitchTalmadge commented 4 years ago

Hi there. I am attempting to build my Android project through GitLab CI/CD. It builds fine on Windows but not on this Linux image. Specifically, I receive this error:

FAILURE: Build failed with an exception.

* Where:
Script '/builds/project/frontend/node_modules/nativescript-plugin-firebase/platforms/android/include.gradle' line: 95

* What went wrong:
A problem occurred evaluating script.
> Plugin with id 'com.google.gms.google-services' not found.

Here is the configuration I am using:

frontend_android_build:
  stage: build
  image: node:10
  variables:
    ANDROID_COMPILE_SDK: "28"
    ANDROID_BUILD_TOOLS: "28.0.3"
    ANDROID_SDK_TOOLS:   "4333796"  
  before_script:
    - apt-get --quiet update --yes
    - apt-get --quiet install --yes wget tar unzip g++ lib32stdc++6 lib32z1 lib32ncurses5
    - apt-get --quiet install --yes openjdk-8-jdk 
    - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip
    - unzip -d android-sdk-linux android-sdk.zip
    - android-sdk-linux/tools/bin/sdkmanager --update
    - echo y | android-sdk-linux/tools/bin/sdkmanager "tools" >/dev/null
    - echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null
    - echo y | android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
    - echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
    - echo y | android-sdk-linux/tools/bin/sdkmanager "extras;android;m2repository" >/dev/null
    - echo y | android-sdk-linux/tools/bin/sdkmanager "extras;google;m2repository" >/dev/null
    - export ANDROID_HOME=$PWD/android-sdk-linux
    - export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
    # temporarily disable checking for EPIPE error and use yes to accept all licenses
    - set +o pipefail
    - yes | android-sdk-linux/tools/bin/sdkmanager --licenses > /dev/null
    - set -o pipefail
    - npm install nativescript -g --unsafe-perm
    - tns doctor
  script:
    - cd frontend
    - tns install
    - tns build android

I know that my CI configuration is not the responsibility or problem of the maintainers of this repository, I am just looking for help if anyone is able to offer it. I appreciate any help at all.

I am slowly narrowing down the issue and have noticed the following difference between the working and non-working builds:

Working:

Project successfully prepared (android)

Configure firebase

Copy D:\...\project\frontend\App_Resources\Android\google-services.json to D:\...\project\frontend\platforms\android\app\google-services.json.

Building project...

Non-Working:

Project successfully prepared (android)
Building project...

The "Configure firebase" and copying of google-services.json just never seems to happen. I imagine this has something to do with gradle and post-install scripts.

Full build logs:

$ tns doctor
No issues were detected.
Your ANDROID_HOME environment variable is set and points to correct directory.
Your adb from the Android SDK is correctly installed.
The Android SDK is installed.
A compatible Android SDK for compilation is found.
Javac is installed and is configured properly.
The Java Development Kit (JDK) is installed and is configured properly.
Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can use the NativeScript cloud infrastructure.
Component nativescript has 6.3.3 version and is up to date.
$ cd frontend
$ tns install
Copying template files...
Platform ios successfully added. v6.2.0
Copying template files...
Platform android successfully added. v6.1.2
$ tns build android
Preparing project...
Hash: fbb1865cc07704f795a3
Version: webpack 4.30.0
Time: 15030ms
Built at: 01/20/2020 11:59:48 PM
              Asset       Size   Chunks             Chunk Names
          bundle.js    269 KiB   bundle  [emitted]  bundle
       package.json  112 bytes           [emitted]  
         runtime.js   13.9 KiB  runtime  [emitted]  runtime
tns-java-classes.js    0 bytes           [emitted]  
          vendor.js   18.3 MiB   vendor  [emitted]  vendor
Entrypoint bundle = runtime.js vendor.js bundle.js
[../$$_lazy_route_resource lazy recursive] ../$$_lazy_route_resource lazy namespace object 160 bytes {bundle} [built]
[./app.scss] 20 KiB {bundle} [built]
[./app/app-routing.module.tns.ts] 1.07 KiB {bundle} [built]
[./app/app.component.html] 819 bytes {bundle} [built]
[./app/app.component.tns.ts] 3.2 KiB {bundle} [built]
[./app/app.module.tns.ts] 2.78 KiB {bundle} [built]
...
[./main.tns.ts] 1.99 KiB {bundle} [built]
    + 639 hidden modules

Webpack compilation complete.
Downloading https://services.gradle.org/distributions/gradle-5.4.1-bin.zip
..................................................
Unzipping /root/.gradle/wrapper/dists/gradle-5.4.1-bin/e75iq110yv9r9wt1a6619x2xm/gradle-5.4.1-bin.zip to /root/.gradle/wrapper/dists/gradle-5.4.1-bin/e75iq110yv9r9wt1a6619x2xm
Set executable permissions for: /root/.gradle/wrapper/dists/gradle-5.4.1-bin/e75iq110yv9r9wt1a6619x2xm/gradle-5.4.1/bin/gradle
Built aar for nativescript-plugin-firebase
Project successfully prepared (android)
Building project...
Gradle build...
Downloading https://services.gradle.org/distributions/gradle-5.4.1-all.zip
..................................................
Unzipping /root/.gradle/wrapper/dists/gradle-5.4.1-all/3221gyojl5jsh0helicew7rwx/gradle-5.4.1-all.zip to /root/.gradle/wrapper/dists/gradle-5.4.1-all/3221gyojl5jsh0helicew7rwx
Set executable permissions for: /root/.gradle/wrapper/dists/gradle-5.4.1-all/3221gyojl5jsh0helicew7rwx/gradle-5.4.1/bin/gradle
     + setting applicationId

FAILURE: Build failed with an exception.

* Where:
Script '/builds/project/frontend/node_modules/nativescript-plugin-firebase/platforms/android/include.gradle' line: 95

* What went wrong:
A problem occurred evaluating script.
> Plugin with id 'com.google.gms.google-services' not found.

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

* Get more help at https://help.gradle.org

BUILD FAILED in 37s
Command ./gradlew failed with exit code 1
ERROR: Job failed: exit code 1

Unfortunately I cannot provide my repo source code since this is for a school project and is closed source until I graduate; however I can provide any configurations needed. Like I said though, it builds just fine and runs fine on Windows, and MacOS too. This seems like a Linux/Docker problem. Thanks for any advice!

ngocnt1 commented 4 years ago

i got exactly the same issue, is there any update?

MitchTalmadge commented 4 years ago

Unfortunately not, it's still breaking for my team. No clue what is causing it.

ngocnt1 commented 4 years ago

do you try update the tns-android to 6.2.0 or 6.3.1?

jasonhis commented 4 years ago

278 This is old issue.

Remove node_modules and platform.

yarn install
tns build android
MitchTalmadge commented 4 years ago

I solved this by adding the following line to my configuration, after npm install and before tns install:

(cd node_modules/nativescript-plugin-firebase && npm run setup)

Basically you navigate into the nativescript-plugin-firebase directory created during npm install and then run the setup script manually.