Closed DiappyMed closed 3 years ago
@DiappyMed thanks for using the plugin which version of the plugin are you using ? which framework Ionic/Angular, Ionic/React, Ionic/Vue ? Did you look at the applications starter?
@DiappyMed Show me the package.json file
Thank you for your quick reply. We are using Ionic/Angular. }, "private": true, "dependencies": { "@angular/common": "~10.0.0", "@angular/core": "~10.0.0", "@angular/forms": "~10.0.0", "@angular/platform-browser": "~10.0.0", "@angular/platform-browser-dynamic": "~10.0.0", "@angular/router": "~10.0.0", "@capacitor/core": "2.4.5", "@ionic-native/core": "^5.0.0", "@ionic-native/splash-screen": "^5.0.0", "@ionic-native/status-bar": "^5.0.0", "@ionic/angular": "^5.0.0", "rxjs": "~6.5.5", "tslib": "^2.0.0", "zone.js": "~0.10.3" }, "devDependencies": { "@angular-devkit/build-angular": "~0.1000.0", "@angular/cli": "~10.0.5", "@angular/compiler": "~10.0.0", "@angular/compiler-cli": "~10.0.0", "@angular/language-service": "~10.0.0", "@capacitor/cli": "2.4.5", "@ionic/angular-toolkit": "^2.3.0", "@types/jasmine": "~3.5.0", "@types/jasminewd2": "~2.0.3", "@types/node": "^12.11.1", "codelyzer": "^6.0.0", "jasmine-core": "~3.5.0", "jasmine-spec-reporter": "~5.0.0", "karma": "~5.0.0", "karma-chrome-launcher": "~3.1.0", "karma-coverage-istanbul-reporter": "~3.0.2", "karma-jasmine": "~3.3.0", "karma-jasmine-html-reporter": "^1.5.0", "protractor": "~7.0.0", "ts-node": "~8.3.0", "tslint": "~6.1.0", "typescript": "~3.9.5" }, "description": "An Ionic project" }
@DiappyMed You have to follow the instructions from the readme file. first install
npm i --save @capacitor/core@2.4.6
npm i --save @capacitor/android@2.4.6 // if you test on Android
npm i --save @capacitor/ios@2.4.6 // if you test on iOS
npm i --save-dev @capacitor/cli@2.4.6
when this is done install the plugin
npm i --save @capacitor-community/sqlite@latest
and then
npm run build
npx cap add android // if you test on Android
npx cap add ios // if you test on iOS
npx cap sync
npm run build
npx cap copy
npx cap open android // if you test on Android
npx cap open ios // if you test on iOS
On Android, register the plugin in your main activity:
import com.getcapacitor.community.database.sqlite.CapacitorSQLite;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializes the Bridge
this.init(
savedInstanceState,
new ArrayList<Class<? extends Plugin>>() {
{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(CapacitorSQLite.class);
}
}
);
}
}
Now it should work
Hello Jean Pierre, Thanks a lot, i upgraded my Capacitor/Core to 2.4.7 and it is working fine.
I am facing another difficulty when using osDatabase or isDBExists. I did run the code on android studio emulator or my real divice, but i always get this returned result, even when i do copy the database first:
"{"result":false,"message":"Not implemented on Web Platform"}"
how i did use it: CapacitorSQLite.isDatabase({database:databaseName}).then( (databaseExists) => { console.log("**++++++++++++++++++++", JSON.stringify(databaseExists)); if(databaseExists.result) { ...
Any advice on that please? When we use copyfromasset(), does it override the existing database?
Thank a lot again,
@DiappyMed i told you above register the plugin in your MainActivity.java file
import com.getcapacitor.community.database.sqlite.CapacitorSQLite;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializes the Bridge
this.init(
savedInstanceState,
new ArrayList<Class<? extends Plugin>>() {
{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(CapacitorSQLite.class);
}
}
);
}
}
i think you should look at the documentation and at the different app starter before starting to use it
@DiappyMed Did you solve your issue ? If no answer from you in the two coming days, I will close the issue.
Hello Jean Pierre, Thanks a lotfor your help, and thanks again for capacitor SQLite. Regards,
Hello,
When i tried to build the project using Capacitor-sqlite, i had the following error:
ERROR in ./node_modules/@capacitor-community/sqlite/dist/esm/index.js 2:24-38 “export ‘registerPlugin’ was not found in ‘@capacitor/core’
Do you have any idea how i can resolve it?
Thanks a lot in advance,