Cannot find name 'ClassName'

I have to use certain plugins in my Ionic 3 Application but it gives Cannot find name error. I imported

import { AndroidPermissions } from '@ionic-native/android-permissions';

and on on declaring in constructor (public androidPermissions: AndroidPermissions) , it gives an error ([ts] Cannot find name 'AndroidPermissions'.) .

On declaring the same plugin in app.module.ts and declaring in Provider, it gave the error

Type 'AndroidPermissionsOriginal' is not assignable to type 'Provider'.
Type 'AndroidPermissionsOriginal' is missing the following properties from type 'FactoryProvider': provide, useFactory [2322]

After reading forums, I imported the plugin with ngx.

import { AndroidPermissions } from '@ionic-native/android-permissions/ngx'

Error got resolved, but on invoking it throws the error

Uncaught (in promise): TypeError: Object(...) is not a function
TypeError: Object(...) is not a function
    at AndroidPermissions.requestPermissions (
    at t.invoke (
    at Object.onInvoke (
    at t.invoke (
    at (
    at t.invokeTask (
    at Object.onInvokeTask (
    at t.invokeTask (

Similar error happened when using Network plugin and SMS plugin.

Then I upgraded to Ionic 4 and now the versions i have all frameworks are Ionic CLI 4.9.0, Angular CLI: 7.2.3, Node: 8.11.1, Angular: 7.2.2, typescript 3.1.6 and cordova 8.1.2.

1 Like