New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.err: TypeError: Cannot read property 'getInstance' of undefined #829

Closed
ngoahamos opened this Issue Aug 1, 2018 · 9 comments

Comments

Projects
None yet
3 participants
@ngoahamos
Copy link

ngoahamos commented Aug 1, 2018

Hello Guys,
i'm getting the following error in Android. I don't know what am doing wrong. Any help will be much appreciated.
Thanks.

JS: Angular is running in the development mode. Call enableProdMode() to enable the production mode. System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.amole.notify/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: System.err: Calling js method onCreate failed System.err: TypeError: Cannot read property 'getInstance' of undefined System.err: File: "file:///data/data/com.amole.notify/files/app/tns_modules/nativescript-plugin-firebase/firebase.js, line: 286, column: 69 System.err: StackTrace: System.err: Frame: function:'runInit', file:'file:///data/data/com.amole.notify/files/app/tns_modules/nativescript-plugin-firebase/firebase.js', line: 286, column: 70 System.err: Frame: function:'Observable.notify', file:'file:///data/data/com.amole.notify/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 110, column: 23 System.err: Frame: function:'notifyLaunch', file:'file:///data/data/com.amole.notify/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 870, column: 17 System.err: Frame: function:'ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/com.amole.notify/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 803, column: 28 System.err: Frame: function:'ActivityCallbacksImplementation.onCreate', file:'file:///data/data/com.amole.notify/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 677, column: 14 System.err: Frame: function:'NativeScriptActivity.onCreate', file:'file:///data/data/com.amole.notify/files/app/tns_modules/tns-core-modules/ui/frame/activity.js', line: 20, column: 25

package.json
"nativescript": { "id": "com.amole.notify", "tns-android": { "version": "4.1.3" } }, "scripts": { "lint": "tslint \"app/**/*.ts\"" }, "dependencies": { "@angular/animations": "~6.0.6", "@angular/common": "~6.0.6", "@angular/compiler": "~6.0.6", "@angular/core": "~6.0.6", "@angular/forms": "~6.0.6", "@angular/http": "~6.0.6", "@angular/platform-browser": "~6.0.6", "@angular/platform-browser-dynamic": "~6.0.6", "@angular/router": "~6.0.6", "nativescript-angular": "~6.0.6", "nativescript-plugin-firebase": "^6.4.1", "nativescript-theme-core": "~1.0.4", "nativescript-ui-sidedrawer": "~4.1.0", "reflect-metadata": "~0.1.10", "rxjs": "~6.1.0", "tns-core-modules": "4.1.1", "zone.js": "~0.8.18" },

app.gradle
`android {
defaultConfig {
generatedDensities = []
applicationId = "com.amole.notify"
multiDexEnabled true
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
dexOptions {
javaMaxHeapSize "4g"
}

project.ext {
googlePlayServicesVersion = "11.8.0"
}
}`

`buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath 'com.google.gms:google-services:3.1.0'
}

}

allprojects {
repositories {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}`

main.ts | i also moved it to app.component.ts still had the same error.
`import { platformNativeScriptDynamic } from "nativescript-angular/platform";

import { AppModule } from "./app.module";
import * as Firebase from 'nativescript-plugin-firebase';

Firebase.init({})
.then((instance) => {
console.log('firebase.init done');
}, (error) => {
console.log(firebase.init error: ${error});

});
platformNativeScriptDynamic().bootstrapModule(AppModule);`

@EddyVerbruggen

This comment has been minimized.

Copy link
Owner

EddyVerbruggen commented Aug 1, 2018

Can you try removing the platforms/android folder and run again?

@ngoahamos

This comment has been minimized.

Copy link
Author

ngoahamos commented Aug 1, 2018

Hello @EddyVerbruggen thanks for your prompt response. Still getting the same error after doing the above.

@ngoahamos

This comment has been minimized.

Copy link
Author

ngoahamos commented Aug 1, 2018

created firebase.nativescript.json file first before installing the plugin and now it's working.

@ngoahamos ngoahamos closed this Aug 1, 2018

@VeeK727

This comment has been minimized.

Copy link

VeeK727 commented Aug 2, 2018

Hey @ngoahamos, I'm facing the same issue. Can you tell me where did you put this file and what did you put in it?

@EddyVerbruggen

This comment has been minimized.

Copy link
Owner

EddyVerbruggen commented Aug 2, 2018

You should not have to create that file manually.. when installing the plugin you should be prompted with a few questions which should create that file for you (so next ‘npm i’ you won’t be prompted again).

@VeeK727

This comment has been minimized.

Copy link

VeeK727 commented Aug 2, 2018

Hi Eddy, I used the Sidekick to install the plugin and it didn't prompt me for anything and the file was not created.

@ngoahamos

This comment has been minimized.

Copy link
Author

ngoahamos commented Aug 2, 2018

@EddyVerbruggen didn't get the prompt, so i thought everything was taken care of, then i started getting errors.
@VeeK727 in the root folder. in the same folder your package.json is.
Modify it to suit your need.

{ "using_ios": true,
  "using_android": true,
  "realtimedb": false,
  "firestore": true,
  "remote_config": false,
  "messaging": true,
  "crash_reporting": false,
  "crashlytics": true,
  "storage": false,
  "facebook_auth": false,
  "google_auth": false,
  "admob": false,
  "invites": false,
  "ml_kit": false,
  "ml_kit_text_recognition": false,
  "ml_kit_barcode_scanning": false,
  "ml_kit_face_detection": false,
  "ml_kit_image_labeling": false,
  "ml_kit_custom_model": false
}
@EddyVerbruggen

This comment has been minimized.

Copy link
Owner

EddyVerbruggen commented Aug 2, 2018

Ah, sidekick, makes sense. Would it help if I add a note about this in the readme, or would nobody read that anyway? 🤭

@ngoahamos

This comment has been minimized.

Copy link
Author

ngoahamos commented Aug 2, 2018

It will be very helpful if you add a note about it in the readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment