Type HTTPOriginal is not assignable to type Provid

2020-02-12 06:28发布

问题:

After i install the cordova-plugin-advanced-http plugin, when i try to import it on providers in app.modules.ts, i get the following:

I have reinstalled, clean cache, and it keeps happening. Here's the app.module.ts code:

import { HTTP } from '@ionic-native/http';
import { GalleryPageModule } from './../pages/gallery/gallery.module';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';


//providers
import { ImagesProvider } from '../providers/images/images';

//plugins
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { File } from '@ionic-native/file';
import { FileTransfer } from "@ionic-native/file-transfer";
import { AndroidPermissions } from '@ionic-native/android-permissions';
import { SocialSharing } from '@ionic-native/social-sharing';


//firebase
import { firebase } from './../firebase';
import { AngularFireModule } from '@angular/fire';
import { AngularFireDatabaseModule, AngularFireDatabase } from '@angular/fire/database';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { AngularFirestoreModule, AngularFirestore } from '@angular/fire/firestore';
import { ImagenPageModule } from '../pages/imagen/imagen.module';

@NgModule({
  declarations: [
    MyApp,
    HomePage,

  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp),
    HttpClientModule,
    GalleryPageModule,
    AngularFireModule.initializeApp(firebase),
    AngularFireDatabaseModule,
    AngularFireAuthModule,
    AngularFirestoreModule.enablePersistence(),
    ImagenPageModule,
    GalleryPageModule


  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage,

  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    HttpClient,
    ImagesProvider,
    AngularFirestore,
    File,
    HTTP,
    FileTransfer,
    AndroidPermissions,
    SocialSharing,



  ]
})
export class AppModule {}

I have tried that in other projects i have, and it works, does not appear that HTTPOriginal suggestion.

回答1:

You installed the latest @ionic-native/http beta (v5+)

You have to import HTTP from /ngx

import { HTTP } from '@ionic-native/http/ngx';

Otherwise fallback to @ionic-native/http v4+



回答2:

This is because of Ionic Have updated all the Plugin so I suggest using the lower version of that plugin .! if your current version 4.5.0 or something then you have to downgrade it with 4.3.2 or something.



回答3:

I was also getting the same error in case of @ionic-native/android-permissions.
To fix this kind of issues just downgrade the version of plugin.

Example:
@ionic-native/android-permissions@.5.0.1 to @ionic-native/android-permissions@3.4.0