Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window.sqlitePlugin.echoTest is not a function, db.executeSql is not a function #784

Closed
GuilhermeLessa opened this issue May 4, 2018 · 9 comments

Comments

@GuilhermeLessa
Copy link

The functions return as undeclared. db.executeSql, batch, echoTest, all...
I'm having the same problem with the plugin nolanlawson/cordova-plugin-sqlite-2

  1. OpenDataBase is ok! Or not? (see console.log image)
  2. I need to include a sqlLitePlugin.js tag script in the index? Or just have the plugin installed via npm?

CONSOLE LOG IMAGE:
https://ibb.co/bKsYKS

db = window.sqlitePlugin.openDatabase({
name: 'tiCorporativoMobile.db',
version: '1.0',
location: 'default'
});
console.log(db);

window.sqlitePlugin.echoTest(function() {
console.log('ECHO test OK');
});

db.executeSql('DELETE FROM configuracoes', [], function(rs) {

}, function(error) { //+ error.message

});

help-me please!

@GuilhermeLessa
Copy link
Author

GuilhermeLessa commented May 4, 2018

I need to create file tiCorporativoMobile.db into root project?

@GuilhermeLessa
Copy link
Author

GuilhermeLessa commented May 4, 2018

MY CONFIG XML

<?xml version='1.0' encoding='utf-8'?> <widget id="com.example.helloworld" version="1.0.0" xmlns="http://www.w3.org/ns/widgets"> <name>TI Corporativo (dev)</name> <description /> <author /> <content src="index.html" /> <access origin="*" /> <allow-navigation href="*" /> <allow-intent href="itms:*" /> <allow-intent href="itms-apps:*" /> <preference name="DisallowOverscroll" value="true" /> <preference name="Orientation" value="default" /> <preference name="loglevel" value="DEBUG" /> <preference name="AndroidLaunchMode" value="singleTop" /> <preference name="ErrorUrl" value="" /> <preference name="Fullscreen" value="false" /> <preference name="KeepRunning" value="true" /> <preference name="SplashScreen" value="screen" /> <preference name="SplashScreenDelay" value="1000" /> <preference name="AllowInlineMediaPlayback" value="false" /> <preference name="AutoHideSplashScreen" value="true" /> <preference name="BackupWebStorage" value="cloud" /> <preference name="EnableViewportScale" value="false" /> <preference name="FadeSplashScreen" value="true" /> <preference name="FadeSplashScreenDuration" value="250" /> <preference name="KeyboardDisplayRequiresUserAction" value="true" /> <preference name="MediaPlaybackRequiresUserAction" value="false" /> <preference name="ShowSplashScreenSpinner" value="false" /> <preference name="SuppressesIncrementalRendering" value="false" /> <preference name="TopActivityIndicator" value="gray" /> <preference name="GapBetweenPages" value="0" /> <preference name="PageLength" value="0" /> <preference name="PaginationBreakingMode" value="page" /> <preference name="PaginationMode" value="unpaginated" /> <preference name="UIWebViewDecelerationSpeed" value="normal" /> <preference name="monaca:AndroidIsPackageNameSeparate" value="false" /> <preference name="ios-XCBuildConfiguration-TARGETED_DEVICE_FAMILY" value="1,2" /> <feature name="LocalStorage"> <param name="ios-package" value="CDVLocalStorage" /> </feature> <platform name="ios"> <icon height="57" src="/res/ios/icon/icon.png" width="57" /> <icon height="114" src="/res/ios/icon/icon@2x.png" width="114" /> <icon height="72" src="/res/ios/icon/icon-72.png" width="72" /> <icon height="144" src="/res/ios/icon/icon-72@2x.png" width="144" /> <icon height="60" src="/res/ios/icon/icon-60.png" width="60" /> <icon height="120" src="/res/ios/icon/icon-60@2x.png" width="120" /> <icon height="180" src="/res/ios/icon/icon-60@3x.png" width="180" /> <icon height="76" src="/res/ios/icon/icon-76.png" width="76" /> <icon height="152" src="/res/ios/icon/icon-76@2x.png" width="152" /> <icon height="40" src="/res/ios/icon/icon-40.png" width="40" /> <icon height="80" src="/res/ios/icon/icon-40@2x.png" width="80" /> <icon height="50" src="/res/ios/icon/icon-50.png" width="50" /> <icon height="100" src="/res/ios/icon/icon-50@2x.png" width="100" /> <icon height="29" src="/res/ios/icon/icon-small.png" width="29" /> <icon height="58" src="/res/ios/icon/icon-small@2x.png" width="58" /> <icon height="87" src="/res/ios/icon/icon-small@3x.png" width="87" /> <icon height="167" src="/res/ios/icon/icon-83.5@2x~ipad.png" width="167" /> <icon height="1024" src="/res/ios/icon/icon-1024.png" width="1024" /> <splash height="480" src="/res/ios/screen/Default~iphone.png" width="320" /> <splash height="960" src="/res/ios/screen/Default@2x~iphone.png" width="640" /> <splash height="1136" src="/res/ios/screen/Default-568h@2x~iphone.png" width="640" /> <splash height="1334" src="/res/ios/screen/Default-667h.png" width="750" /> <splash height="2208" src="/res/ios/screen/Default-736h.png" width="1242" /> <splash height="1242" src="/res/ios/screen/Default-Landscape-736h.png" width="2208" /> <splash height="1024" src="/res/ios/screen/Default-Portrait~ipad.png" width="768" /> <splash height="768" src="/res/ios/screen/Default-Landscape~ipad.png" width="1024" /> <splash height="2048" src="/res/ios/screen/Default-Portrait@2x~ipad.png" width="1536" /> <splash height="1536" src="/res/ios/screen/Default-Landscape@2x~ipad.png" width="2048" /> <config-file parent="CFBundleLocalizations" platform="ios" target="*-Info.plist"> <array> <string>en</string> </array> </config-file> </platform> <platform name="android"> <icon density="ldpi" src="/res/android/icon/ldpi.png" /> <icon density="mdpi" src="/res/android/icon/mdpi.png" /> <icon density="hdpi" src="/res/android/icon/hdpi.png" /> <icon density="xhdpi" src="/res/android/icon/xhdpi.png" /> <icon density="xxhdpi" src="/res/android/icon/xxhdpi.png" /> <icon density="xxxhdpi" src="/res/android/icon/xxxhdpi.png" /> <splash density="port-ldpi" src="/res/android/screen/splash-port-ldpi.9.png" /> <splash density="port-mdpi" src="/res/android/screen/splash-port-mdpi.9.png" /> <splash density="port-hdpi" src="/res/android/screen/splash-port-hdpi.9.png" /> <splash density="port-xhdpi" src="/res/android/screen/splash-port-xhdpi.9.png" /> <splash density="port-xxhdpi" src="/res/android/screen/splash-port-xxhdpi.9.png" /> <splash density="port-xxxhdpi" src="/res/android/screen/splash-port-xxxhdpi.9.png" /> </platform> <platform name="windows"> <icon src="/res/winrt/icon/package_logo_winrt.png" target="StoreLogo" /> <icon src="/res/winrt/icon/app_logo_winrt.png" target="Square150x150Logo" /> <icon src="/res/winrt/icon/app_small_logo_winrt.png" target="Square30x30Logo" /> <icon src="/res/winrt/icon/app_tile_wide_logo_winrt.png" target="Wide315x150Logo" /> <splash height="300" src="/res/winrt/screen/app_splash_screen_winrt.png" width="620" /> </platform> <platform name="chrome"> <icon height="128" src="/platforms/chrome/icon.png" width="128" /> </platform> <plugin name="cordova-sqlite-storage" spec="^2.3.1" /> <plugin name="cordova-plugin-sqlite-2" spec="^1.0.4" /> <engine name="browser" spec="^5.0.3" /> <engine name="android" spec="^7.0.0" /> </widget>

@brodycj
Copy link
Contributor

brodycj commented May 4, 2018

Your config.xml indicates that you have both cordova-sqlite-storage and cordova-plugin-sqlite-2 installed, which may lead to undefined results such as build errors and data loss issues discussed in #626, #719, and #776. Please completely remove each sqlite plugin, double-check, and install the one desired.

The other possible issue is that you must wait for the deviceready event before using this or any other Cordova plugin.

@GuilhermeLessa
Copy link
Author

GuilhermeLessa commented May 4, 2018

I'm using "document.addEventListener('deviceready', function() {" to wait device.

  1. I need to create file tiCorporativoMobile.db into root project?
  2. OpenDataBase is ok! Or not? (see console.log image)
  3. I need to include a sqlLitePlugin.js tag script in the index? Or just have the plugin installed via npm?

@brodycj
Copy link
Contributor

brodycj commented May 4, 2018

I need to create file tiCorporativoMobile.db into root project?

You should not need to do anything like that. This plugin will create the database if it does not already exist. If you want pre-populated database then please use cordova-sqlite-ext plugin version.

OpenDataBase is ok! Or not? (see console.log image)

Image indicates to me that you are using Web SQL database.

I need to include a sqlLitePlugin.js tag script in the index?

no

Or just have the plugin installed via npm?

yes

@GuilhermeLessa
Copy link
Author

GuilhermeLessa commented May 4, 2018

I'm removing sqlite-2 with "cordova plugin rm --save", and also removed from config.xml and plugins / fetch.json. Even so when "run" it reinstalls the plugin. Can you help me?

NPM: https://ibb.co/eredm7

What is the problem with GIT?

@brodycj
Copy link
Contributor

brodycj commented May 4, 2018

I forgot to mention that you should also completely remove all versions of sqlite plugin from package.json as well as config.xml. Also this plugin does NOT support browser platform.

Here is what I would recommend:

  • completely remove plugins and platforms directories
  • remove every form of sqlite plugin and any other unwanted plugins from config.xml and package.json (I forgot to mention package.json before)
  • then use cordova plugin add to add the desired sqlite plugin
  • do cordova platform add to add the desired platform
  • do cordova plugin ls and check the results

It is also possible to use the browser platform for testing if you use my sql-promise-helper project as described in brodycj/sql-promise-helper#4.

@GuilhermeLessa
Copy link
Author

I rebuild the project, being careful with all the items spoken here. Worked well!

@brodycj
Copy link
Contributor

brodycj commented May 4, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants