Creating a Toast throws an error


#1

Hello,

I am new with Ionic and Angular.
I want to test the Toast Plugin.

First I added it to my project:

cordova plugin add cordova-plugin-x-toast

my page1.ts looks like this:

import { Component } from '@angular/core';

import { NavController } from 'ionic-angular';

import { Toast } from 'ionic-native';

@Component({
  selector: 'page-page1',
  templateUrl: 'page1.html'
})
export class Page1 {

  constructor(public navCtrl: NavController) {
    Toast.show("I'm a toast", '5000', 'center').subscribe(
      toast => {
        console.log(toast);
      });
  }
}

When I run the app on my Android Device, I get this error:

11-30 04:31:15.341: I/chromium(31584): [INFO:CONSOLE(1)] “Native: tried calling t.show, but the t plugin is not installed.”, source: file:///android_asset/www/build/main.js (1)
11-30 04:31:15.341: I/chromium(31584): [INFO:CONSOLE(1)] “Install the t plugin: ‘ionic plugin add cordova-plugin-x-toast’”, source: file:///android_asset/www/build/main.js (1)
11-30 04:31:15.341: I/chromium(31584): [INFO:CONSOLE(1)] “Unable to clear the previous observable watch for”, source: file:///android_asset/www/build/main.js (1)
11-30 04:31:15.341: I/chromium(31584): [INFO:CONSOLE(1)] “TypeError: Cannot read property ‘hide’ of null”, source: file:///android_asset/www/build/main.js (1)
11-30 04:31:15.341: I/chromium(31584): [INFO:CONSOLE(11)] “EXCEPTION: plugin_not_installed”, source: file:///android_asset/www/build/main.js (11)
11-30 04:31:15.381: I/chromium(31584): [INFO:CONSOLE(1)] “Native: tried calling t.show, but the t plugin is not installed.”, source: file:///android_asset/www/build/main.js (1)
11-30 04:31:15.381: I/chromium(31584): [INFO:CONSOLE(1)] “Install the t plugin: ‘ionic plugin add cordova-plugin-x-toast’”, source: file:///android_asset/www/build/main.js (1)
11-30 04:31:15.381: I/chromium(31584): [INFO:CONSOLE(1)] “Unable to clear the previous observable watch for”, source: file:///android_asset/www/build/main.js (1)
11-30 04:31:15.381: I/chromium(31584): [INFO:CONSOLE(1)] “TypeError: Cannot read property ‘hide’ of null”, source: file:///android_asset/www/build/main.js (1)
11-30 04:31:15.381: I/chromium(31584): [INFO:CONSOLE(11)] “EXCEPTION: plugin_not_installed”, source: file:///android_asset/www/build/main.js (11)
11-30 04:31:15.381: I/chromium(31584): [INFO:CONSOLE(11)] “EXCEPTION: Uncaught (in promise): plugin_not_installed”, source: file:///android_asset/www/build/main.js (11)
11-30 04:31:15.381: I/chromium(31584): [INFO:CONSOLE(11)] “ORIGINAL STACKTRACE:”, source: file:///android_asset/www/build/main.js (11)
11-30 04:31:15.391: I/chromium(31584): [INFO:CONSOLE(11)] “Error: Uncaught (in promise): plugin_not_installed
11-30 04:31:15.391: I/chromium(31584): at s (file:///android_asset/www/build/polyfills.js:3:8568)
11-30 04:31:15.391: I/chromium(31584): at file:///android_asset/www/build/polyfills.js:3:8940
11-30 04:31:15.391: I/chromium(31584): at t.invokeTask (file:///android_asset/www/build/polyfills.js:3:14051)
11-30 04:31:15.391: I/chromium(31584): at Object.onInvokeTask (file:///android_asset/www/build/main.js:3:19691)
11-30 04:31:15.391: I/chromium(31584): at t.invokeTask (file:///android_asset/www/build/polyfills.js:3:13987)
11-30 04:31:15.391: I/chromium(31584): at e.runTask (file:///android_asset/www/build/polyfills.js:3:11411)
11-30 04:31:15.391: I/chromium(31584): at i (file:///android_asset/www/build/polyfills.js:3:8028)”, source: file:///android_asset/www/build/main.js (11)
11-30 04:31:15.391: E/chromium(31584): [ERROR:interface_registry.cc(99)] Failed to locate a binder for interface: autofill::mojom::AutofillDriver
11-30 04:31:15.441: I/chromium(31584): [INFO:CONSOLE(19)] “DEVICE READY FIRED AFTER”, source: file:///android_asset/www/build/main.js (19)

When i try to install the plugin again I get:

Plugin “cordova-plugin-x-toast” already installed on android.


#2

Hi this can help you http://ionicframework.com/docs/v2/components/#toast