Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

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

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

Comments

@ngoahamos
Copy link

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
Copy link
Owner

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

@ngoahamos
Copy link
Author

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

@ngoahamos
Copy link
Author

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

@Whip
Copy link

Whip 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
Copy link
Owner

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).

@Whip
Copy link

Whip 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
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
Copy link
Owner

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

@ngoahamos
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants