webentwicklung-frage-antwort-db.com.de

Laufzeitfehler Das Modul "ionisch-native" IONIC 2 kann nicht gefunden werden

Ich habe versucht, Werbebanner für die neuen ionic 2-Apps hinzuzufügen, es wird jedoch ein Fehler angezeigt. Ich mache es wie hier gezeigt Tutorial . aber wenn ich es vom Browser aus mit ionic serve -l -c ausführen lasse, zeigt es Runtime Error Cannot find module "ionic-native" Fehler wie unten beschrieben.

 enter image description here

hier ist mein app.component.ts datei code

import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { Geolocation } from '@ionic-native/geolocation';
import { AdMob } from 'ionic-native';


import { HomePage } from '../pages/home/home';
import { DetailsPage } from '../pages/details/details';
import { SettingModalPage } from '..Pages/setting-modal/setting-
modal';


@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = HomePage;

constructor(platform: Platform, statusBar: StatusBar, splashScreen: 
SplashScreen) {
platform.ready().then(() => {
  // Okay, so the platform is ready and our plugins are available.
  // Here you can do any higher level native things you might need.
  statusBar.styleDefault();
  splashScreen.hide();

  let options = {
    adId: 'ca-app-pub-5732334124058455/7973166445',
    adSize: 'SMART_BANNER',
    isTesting: false
  };

  AdMob.createBanner(options).then(() => {
    AdMob.showBanner(8);
  });

 });
}
}

in meiner package.json-Datei,

 "dependencies": {
"@angular/common": "2.4.8",
"@angular/compiler": "2.4.8",
"@angular/compiler-cli": "2.4.8",
"@angular/core": "2.4.8",
"@angular/forms": "2.4.8",
"@angular/http": "2.4.8",
"@angular/platform-browser": "2.4.8",
"@angular/platform-browser-dynamic": "2.4.8",
"@angular/platform-server": "2.4.8",
"@ionic-native/admob": "^3.4.4",
"@ionic-native/core": "^3.1.0",
"@ionic-native/geolocation": "^3.4.4",
"@ionic-native/launch-navigator": "^3.4.4",
"@ionic-native/splash-screen": "3.1.0",
"@ionic-native/status-bar": "3.1.0",
"@ionic/storage": "2.0.0",
"font-awesome": "^4.7.0",
"ionic-angular": "2.3.0",
"ionic2-rating": "^1.2.0",
"ionicons": "3.0.0",
"rxjs": "5.0.1",
"sw-toolbox": "3.4.0",
"zone.js": "0.7.2"
  },
  "devDependencies": {
"@ionic/app-scripts": "1.1.4",
"TypeScript": "2.0.9"
  },
  "cordovaPlugins": [
"cordova-plugin-whitelist",
"cordova-plugin-console",
"cordova-plugin-statusbar",
"cordova-plugin-device",
"cordova-plugin-splashscreen",
"ionic-plugin-keyboard"
],
4
alka vaghela

Überprüfen Sie hier .

import { AdMob } from 'ionic-native';

war in ionic-native 2.x.

Tun:

ionic plugin add cordova-plugin-admobpro --save
npm install --save @ionic-native/admob

Und:

import { AdMob, AdMobOptions, AdSize, AdExtras} from '@ionic-native/admob';//import

constructor(platform: Platform, statusBar: StatusBar, splashScreen: 
SplashScreen,admob:Admob)//inject in constructor.

   //and use
   let options:AdMobOptions={
    adId: 'ca-app-pub-5732334124058455/7973166445',
    adSize: 'SMART_BANNER',
    isTesting: false
   }
   this.admob.createBanner(options).then(()=>{
       this.admob.showBanner(8)
   })
7
Suraj Rao

Das Paket ionic-native existiert nicht mehr. Die Module sind jetzt in einem eigenen Paket, daher müssen Sie Folgendes ändern:

import { AdMob } from 'ionic-native';

von

import { AdMob } from '@ionic-native/admob';