Error when intergrate nativescript-plugin-firebase to vue-cli-template

plugins
firebase

#1

I have successfully created, built & ran a new app with the vue-cli-template. Now I want to install the plugin nativescript-plugin-firebase. I have followed these steps from both documents:

  1. npm install nativescript-plugin-firebase
  2. npm run clean
  3. Add google-services.json to app/App_Resources/Android/google-services.json
  4. Copy firebase.nativescript.json to the template folder.
  5. import (not require) the plugin before Vue.start runs (in main.js ), and run firebase.init() afterwards
  6. npm run build:android

And this is where the error happens. Note that before intergrating the plugin, the project was working just fine. This is the terminal output:

Terminal
C:\SOURCE\Officer\Officer>npm run build:android

> officer@1.0.0 build:android C:\SOURCE\Officer\Officer
> npm run build -- --env.android


> officer@1.0.0 build C:\SOURCE\Officer\Officer
> webpack --env.tnsAction build "--env.android"

info: Copying NativeScript plugins to template dependencies...
info: Preparing NativeScript application from template...
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN officer@ No repository field.

info: Bundling application for android...
Executing post-build scripts
info: Building NativeScript application...
Copying template files...
Installing tns-android
+ tns-android@4.1.3
added 1 package and audited 87 packages in 2.315s
found 0 vulnerabilities

Project successfully created.
Executing before-prepare hook from C:\SOURCE\Officer\Officer\dist\hooks\before-prepare\nativescript-plugin-firebase.js
Preparing project...
Successfully prepared plugin nativescript-plugin-firebase for android.
Successfully prepared plugin nativescript-theme-core for android.
Successfully prepared plugin nativescript-vue for android.
Successfully prepared plugin tns-core-modules for android.
Successfully prepared plugin tns-core-modules-widgets for android.
Project successfully prepared (android)
Executing after-prepare hook from C:\SOURCE\Officer\Officer\dist\hooks\after-prepare\firebase-build-gradle.js
Configure firebase
Executing after-prepare hook from C:\SOURCE\Officer\Officer\dist\hooks\after-prepare\firebase-copy-google-services.js
Copy C:\SOURCE\Officer\Officer\dist\app\App_Resources\Android\google-services.json to C:\SOURCE\Officer\Officer\dist\platforms\android\app\google-services.json.
Executing after-prepare hook from C:\SOURCE\Officer\Officer\dist\hooks\after-prepare\nativescript-plugin-firebase.js
Building project...
Gradle build...
         + setting applicationId
         + applying user-defined configuration from C:\SOURCE\Officer\Officer\dist\app\App_Resources\Android\app.gradle
         Applying settings from C:\SOURCE\Officer\Officer\dist\app\App_Resources\Android\settings.json
         + adding nativescript runtime package dependency: nativescript-optimized-with-inspector
         + adding aar plugin dependency: C:\SOURCE\Officer\Officer\dist\node_modules\nativescript-plugin-firebase\platforms\android\firebase-release.aar
         + adding aar plugin dependency: C:\SOURCE\Officer\Officer\dist\node_modules\tns-core-modules-widgets\platforms\android\widgets-release.aar
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
# tns build android

==========

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Usage   β”‚ Synopsis
                                                             β”‚
β”‚ General β”‚ $ tns build android [--compileSdk <API Level>] [--key-store-path <File Path> --key-store-password <Password> --key-store-alias <Name> --key-store-alias-password <Password>] [--release] [--static-bindings] [--copy-to <File Path>] [--bundle [<value>] [--env.*]] β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Builds the project for Android and produces an APK that you can manually deploy on device or in the native emulator.

### Options

    * --compileSdk - Sets the Android SDK that will be used to build the project.
    * --clean - If set, forces rebuilding the native application.
    * --release - If set, produces a release build. Otherwise, produces a debug build. When set, you must also specify the --key-store-* options.
    * --key-store-path - Specifies the file path to the keystore file (P12) which you want to use to code sign your APK. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.
    * --key-store-password - Provides the password for the keystore file specified with --key-store-path. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.
    * --key-store-alias - Provides the alias for the keystore file specified with --key-store-path. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.
    * --key-store-alias-password - Provides the password for the alias specified with --key-store-alias-password. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.
    * --copy-to - Specifies the file path where the built .apk will be copied. If it points to a non-existent directory, it will be created. If the specified value is directory, the original file name will be used.
    * --bundle - Specifies that a bundler (e.g. webpack) should be used if one is present. If no value is passed will default to webpack.
    * --env.* - Specifies additional flags that the bundler may process. May be passed multiple times. For example: --env.uglify --env.snapshot.

### Attributes

<API Level> is a valid Android API level. For example: 22, 23.

error: uncaughtException: Command failed: node launch.js build android
 date=Wed Aug 08 2018 10:39:38 GMT+0700 (Indochina Time), pid=14620, uid=null, gid=null, cwd=C:\SOURCE\Officer\Officer, execPath=C:\Program Files\nodejs\node.exe, version=v10.5.0, argv=[C:\Program Files\nodejs\node.exe, C:\SOURCE\Officer\Officer\node_modules\webpack\bin\webpack.js, --env.tnsAction, build, --env.android], rss=90030080, heapTotal=69623808, heapUsed=58364640, external=81091, loadavg=[0, 0, 0], uptime=430403, trace=[column=12, file=child_process.js, function=ChildProcess.exithandler, line=291, method=exithandler, native=false, column=13, file=events.js, function=ChildProcess.emit, line=182, method=emit, native=false, column=16, file=internal/child_process.js, function=maybeClose, line=961, method=null, native=false, column=5, file=internal/child_process.js, function=Process.ChildProcess._handle.onexit, line=248, method=onexit, native=false], stack=[Error: Command failed: node launch.js build android, ,     at ChildProcess.exithandler (child_process.js:291:12),     at ChildProcess.emit (events.js:182:13),     at maybeClose (internal/child_process.js:961:16),     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)]
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! officer@1.0.0 build: `webpack --env.tnsAction build "--env.android"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the officer@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\nvtung\AppData\Roaming\npm-cache\_logs\2018-08-08T03_39_39_016Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! officer@1.0.0 build:android: `npm run build -- --env.android`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the officer@1.0.0 build:android script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\nvtung\AppData\Roaming\npm-cache\_logs\2018-08-08T03_39_39_052Z-debug.log

And these are logs:

2018-08-08T03_39_39_016Z-debug.log
0 info it worked if it ends with ok

1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',

1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',

1 verbose cli 'run',

1 verbose cli 'build',

1 verbose cli '--',

1 verbose cli '--env.android' ]

2 info using npm@6.1.0

3 info using node@v10.5.0

4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]

5 info lifecycle officer@1.0.0~prebuild: officer@1.0.0

6 info lifecycle officer@1.0.0~build: officer@1.0.0

7 verbose lifecycle officer@1.0.0~build: unsafe-perm in lifecycle true

8 verbose lifecycle officer@1.0.0~build: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\SOURCE\Officer\Officer\node_modules\.bin;C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\SOURCE\Officer\Officer\node_modules\.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Microsoft MPI\Bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\nodejs\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\Java\jdk1.8.0_172\bin;C:\Android\android-sdk\tools;C:\Android\android-sdk\platform-tools;;C:\Program Files\Microsoft VS Code\bin;C:\Users\nvtung\AppData\Local\Microsoft\WindowsApps;C:\Users\nvtung\AppData\Roaming\npm;C:\Program Files\kdiff3;C:\Program Files\Microsoft VS Code\bin;C:\Users\nvtung\AppData\Local\GitHubDesktop\bin;C:\Users\nvtung\AppData\Local\Programs\Fiddler

9 verbose lifecycle officer@1.0.0~build: CWD: C:\SOURCE\Officer\Officer

10 silly lifecycle officer@1.0.0~build: Args: [ '/d /s /c', 'webpack --env.tnsAction build "--env.android"' ]

11 silly lifecycle officer@1.0.0~build: Returned: code: 1 signal: null

12 info lifecycle officer@1.0.0~build: Failed to exec build script

13 verbose stack Error: officer@1.0.0 build: `webpack --env.tnsAction build "--env.android"`

13 verbose stack Exit status 1

13 verbose stack at EventEmitter.&lt;anonymous&gt; (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:304:16)

13 verbose stack at EventEmitter.emit (events.js:182:13)

13 verbose stack at ChildProcess.&lt;anonymous&gt; (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)

13 verbose stack at ChildProcess.emit (events.js:182:13)

13 verbose stack at maybeClose (internal/child_process.js:961:16)

13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)

14 verbose pkgid officer@1.0.0

15 verbose cwd C:\SOURCE\Officer\Officer

16 verbose Windows_NT 10.0.17134

17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build" "--" "--env.android"

18 verbose node v10.5.0

19 verbose npm v6.1.0

20 error code ELIFECYCLE

21 error errno 1

22 error officer@1.0.0 build: `webpack --env.tnsAction build "--env.android"`

22 error Exit status 1

23 error Failed at the officer@1.0.0 build script.

23 error This is probably not a problem with npm. There is likely additional logging output above.

24 verbose exit [ 1, true ]
2018-08-08T03_39_39_052Z-debug.log
0 info it worked if it ends with ok

1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',

1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',

1 verbose cli 'run',

1 verbose cli 'build:android' ]

2 info using npm@6.1.0

3 info using node@v10.5.0

4 verbose run-script [ 'prebuild:android', 'build:android', 'postbuild:android' ]

5 info lifecycle officer@1.0.0~prebuild:android: officer@1.0.0

6 info lifecycle officer@1.0.0~build:android: officer@1.0.0

7 verbose lifecycle officer@1.0.0~build:android: unsafe-perm in lifecycle true

8 verbose lifecycle officer@1.0.0~build:android: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\SOURCE\Officer\Officer\node_modules\.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Microsoft MPI\Bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\nodejs\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\Java\jdk1.8.0_172\bin;C:\Android\android-sdk\tools;C:\Android\android-sdk\platform-tools;;C:\Program Files\Microsoft VS Code\bin;C:\Users\nvtung\AppData\Local\Microsoft\WindowsApps;C:\Users\nvtung\AppData\Roaming\npm;C:\Program Files\kdiff3;C:\Program Files\Microsoft VS Code\bin;C:\Users\nvtung\AppData\Local\GitHubDesktop\bin;C:\Users\nvtung\AppData\Local\Programs\Fiddler

9 verbose lifecycle officer@1.0.0~build:android: CWD: C:\SOURCE\Officer\Officer

10 silly lifecycle officer@1.0.0~build:android: Args: [ '/d /s /c', 'npm run build -- --env.android' ]

11 silly lifecycle officer@1.0.0~build:android: Returned: code: 1 signal: null

12 info lifecycle officer@1.0.0~build:android: Failed to exec build:android script

13 verbose stack Error: officer@1.0.0 build:android: `npm run build -- --env.android`

13 verbose stack Exit status 1

13 verbose stack at EventEmitter.&lt;anonymous&gt; (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:304:16)

13 verbose stack at EventEmitter.emit (events.js:182:13)

13 verbose stack at ChildProcess.&lt;anonymous&gt; (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)

13 verbose stack at ChildProcess.emit (events.js:182:13)

13 verbose stack at maybeClose (internal/child_process.js:961:16)

13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)

14 verbose pkgid officer@1.0.0

15 verbose cwd C:\SOURCE\Officer\Officer

16 verbose Windows_NT 10.0.17134

17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build:android"

18 verbose node v10.5.0

19 verbose npm v6.1.0

20 error code ELIFECYCLE

21 error errno 1

22 error officer@1.0.0 build:android: `npm run build -- --env.android`

22 error Exit status 1

23 error Failed at the officer@1.0.0 build:android script.

23 error This is probably not a problem with npm. There is likely additional logging output above.

24 verbose exit [ 1, true ]

Additional info:

Project structure

tns doctor
C:\SOURCE\Officer\Officer>tns doctor
√ Getting environment information

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.
√ Getting NativeScript components versions information...
β€Ό Update available for component nativescript. Your current version is 4.1.2 and the latest available version is 4.2.0.
android list target
C:\SOURCE\Officer\Officer>android list target
**************************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools\bin\sdkmanager.bat
and tools\bin\avdmanager.bat
**************************************************************************

Invoking "C:\Android\android-sdk\tools\bin\avdmanager" list target

Available Android targets:==============] 100% Fetch remote repository...
----------
id: 1 or "android-25"
     Name: Android API 25
     Type: Platform
     API level: 25
     Revision: 3

So any help is appreciated.


#2

Hai,
If you choose to save your config during the installation, the supported options may be saved in the firebase.nativescript.json at the root of your app. This is to ensure your app may roundtrip source control and installation on CI won’t prompt for user input during installation.

You can reconfigure the plugin by going to the node_modules/nativescript-plugin-firebase and running npm run config .

You can also change the configuration by deleting the firebase.nativescript.json and reinstalling the plugin.
This may this help you.

Regards,
Riya.
(Oracle developer)


#3

Did you try installing API Level 26?
New apps / updates must use API level 26 or later.