来自插件导入的离子黑屏

Ionic blank screen from plugin import

我正在尝试使用 Ionic 和 BluetoothLE 插件构建 BLE 配置应用程序。但是,当我导入插件时,它给我一个空白屏幕。我已经更新到 ionic 5,一切都是最新的。我正在尝试通过 android studio 上的 usb 调试模式构建它。在我添加导入语句之前它工作正常。

我按照文档的方式导入它 import { BluetoothLE } from '@ionic-native/bluetooth-le/ngx';

插件安装正确,识别为要导入的东西。但出于某种原因,它只会使应用变砖。

这是包裹-lock.json:

"@ionic-native/bluetooth-le": {
      "version": "5.22.0",
      "resolved": "https://registry.npmjs.org/@ionic-native/bluetooth-le/-/bluetooth-le-5.22.0.tgz",
      "integrity": "sha512-evqUuWzhVZZO7znOQvShCYHP8HdElGwnxpWUCYhSGp0YsoacYJUIB7U4LN0Y7azTn3wgMRWT4m7M49Z42ErMXw==",
      "requires": {
        "@types/cordova": "^0.0.34"
      }

此外,这是插件 https://ionicframework.com/docs/native/bluetooth-le

运行 在带有 ionic serve 的浏览器上,我在控制台中收到此错误

  StaticInjectorError(Platform: core)[HomePage -> BluetoothLE]: 
    NullInjectorError: No provider for BluetoothLE!
NullInjectorError: StaticInjectorError(AppModule)[HomePage -> BluetoothLE]: 
  StaticInjectorError(Platform: core)[HomePage -> BluetoothLE]: 
    NullInjectorError: No provider for BluetoothLE!
    at NullInjector.get (core.js:855)
    at resolveToken (core.js:17514)
    at tryResolveToken (core.js:17440)
    at StaticInjector.get (core.js:17266)
    at resolveToken (core.js:17514)
    at tryResolveToken (core.js:17440)
    at StaticInjector.get (core.js:17266)
    at resolveNgModuleDep (core.js:30393)
    at NgModuleRef_.get (core.js:31578)
    at resolveNgModuleDep (core.js:30393)
    at resolvePromise (zone-evergreen.js:797)
    at resolvePromise (zone-evergreen.js:754)
    at zone-evergreen.js:858
    at ZoneDelegate.invokeTask (zone-evergreen.js:391)
    at Object.onInvokeTask (core.js:39680)
    at ZoneDelegate.invokeTask (zone-evergreen.js:390)
    at Zone.runTask (zone-evergreen.js:168)
    at drainMicroTaskQueue (zone-evergreen.js:559)```

在我能找到的任何地方都没有记录。也许那是因为我是 Ionic 的新手,这是常识(我觉得软件中的任何类似的东西都不应被视为常识)但是当使用插件时,您需要将插件导入 app.module.ts 和像这样在提供者下添加它:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { BluetoothLE } from '@ionic-native/bluetooth-le/ngx';

import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
  providers: [
    StatusBar,
    SplashScreen,
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
    BluetoothLE
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}