I am facing a strange problem here. My ionic 7 app using capacitor is not running even in real device.
All my plugin seem not working, i tried removing all plugin and install them again, removing the android platform and adding it again, and still not working.
I am always getting “Native: tried calling NativeStorage.getItem, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator”
the problem is that i am running the app in a real android device connected via usb cable.
This is a simple app with only three plugins, NativeStorage, SQLlite and SQLLite porter, so to reproduce the error, you can create a simple ionic projet with a simple call to the nativeStorage remove method like this:
import { Component } from '@angular/core';
import { Platform, ToastController, NavController } from '@ionic/angular';
import { DbService } from './services/db.service';
import { Router } from '@angular/router';
import { SQLitePorter } from '@awesome-cordova-plugins/sqlite-porter/ngx';
import { HttpClient } from '@angular/common/http';
import { SQLite, SQLiteObject } from '@awesome-cordova-plugins/sqlite/ngx';
import {TranslateDirective} from '@ngx-translate/core';
import { Globalization } from '@awesome-cordova-plugins/globalization/ngx';
import {TranslateService} from '@ngx-translate/core';
import { NativeStorage } from '@awesome-cordova-plugins/native-storage/ngx';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.scss'],
})
export class AppComponent {
public selectedIndex = 0;
public appPages = [
{
title: 'SETTINGS',
url: '/settings',
icon: 'settings'
},
{
title: 'ABOUT',
url: '/about',
icon: 'briefcase'
},
];
constructor(
public db: DbService,
public platform: Platform,
public globalization: Globalization,
public router: Router,
public sqlPorter: SQLitePorter,
public httpClient: HttpClient,
public nativeStorage: NativeStorage,
) {
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.
this.nativeStorage.remove('myUser');
}
}
Here is my ionic info command output
Ionic:
Ionic CLI : 7.1.1 (C:\Users\HP\AppData\Roaming\npm\node_modules\@ionic\cli)
Ionic Framework : @ionic/angular 7.0.14
@angular-devkit/build-angular : 16.1.0
@angular-devkit/schematics : 16.1.0
@angular/cli : 16.1.0
@ionic/angular-toolkit : 9.0.0
Capacitor:
Capacitor CLI : 5.0.5
@capacitor/android : 5.0.5
@capacitor/core : 5.0.5
@capacitor/ios : not installed
Utility:
cordova-res : not installed globally
native-run : 1.7.2
System:
NodeJS : v18.16.0 (C:\nodejs\node.exe)
npm : 9.6.2
OS : Windows 10
Any help will be appreciate
I created more than 5 new fresh simple projets to start from scratch, and still facing the same problem.
If anybody already faced the same problem, i will appreciate a helpful hand