Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type HTTPOriginal is not assignable to type Provider, ionic error after plugin installation

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:

Code

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.

like image 493
Blast06 Avatar asked Jan 26 '19 02:01

Blast06


2 Answers

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+

like image 103
Maheswaran Ravisankar Avatar answered Nov 03 '22 10:11

Maheswaran Ravisankar


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/[email protected] to @ionic-native/[email protected]

like image 1
deepak ranjan Avatar answered Nov 03 '22 12:11

deepak ranjan