brodycj / cordova-sqlite-legacy

Legacy version of Cordova/PhoneGap plugin to open and use sqlite databases on Windows 8.1/Windows Phone 8.1 in addition to Android/iOS/macOS/Windows 10 with HTML5/Web SQL API
Other
6 stars 11 forks source link

Does not work on Windows Phone 8.1 #9

Closed cenob8 closed 7 years ago

cenob8 commented 7 years ago

Using the test bootstrap project on https://github.com/brodybits/Cordova-sqlite-bootstrap-test

Can be reproduced with the following steps :

cordova plugin add https://github.com/litehelpers/Cordova-sqlite-legacy-build-support --save 
cordova platform add windows

Then in Visual Studio 2015 I open the solution and run the project on my Nokia Lumia phone (WP 8.1)

The first error I encounter is :

Could not copy the file "Y:\projects\cordova-sqlite\platforms\windows\Debug\SQLite3.WindowsPhone\SQLite3.winmd" because it was not found.

Indeed that file isn't there, neither does that folder exist.

Solution : manually build the SQLite3 solution in :

Y:\projects\cordova-sqlite\plugins\cordova-sqlite-legacy-build-support\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.WindowsPhone

Switch to the Windows Phone 8.1 solution and change the target to 'ARM', then build.

This results in several output files (amongst others the above mentioned SQLite3.winmd) that end up in:

Y:\projects\cordova-sqlite\plugins\cordova-sqlite-legacy-build-support\src\windows\SQLite3-Win-RT\SQLite3\ARM\Debug\SQLite3.WindowsPhone

I then manually copy these files into the following directory :

Y:\projects\cordova-sqlite\platforms\windows\Debug\SQLite3.WindowsPhone

And update the reference in the project to point to the SQLite3.winmd in the directory above. The bootstrap test project now builds without errors.

But as soon as the window.sqlitePlugin.openDatabase({name: 'sample.db', location: 'default'}); line is called this returns an error :

OPEN database: sample.db
open db name: sample.db at full path: C:\Data\Users\DefApps\APPDATA\Local\Packages\com.test.TestApp_bzbj8h50hftv4\LocalState\sample.db
new transaction is waiting for open operation
OPEN database: sample.db failed, aborting any pending transactions
Could not open database

The debug output in VS also shows the following errors :

Exception was thrown at line 119, column 7 in ms-appx://com.test.testapp/www/plugins/cordova-sqlite-legacy-build-support/src/windows/SQLite3-Win-RT/SQLite3JS/js/SQLite3.js
0x8007007e - JavaScript runtime error: The specified module could not be found.
Exception was thrown at line 19, column 5 in ms-appx://com.test.testapp/www/plugins/cordova-sqlite-legacy-build-support/src/windows/SQLite3-Win-RT/SQLite3JS/js/SQLite3.js
0x800a139e - JavaScript runtime error: Error creating an SQLite database connection.

Any help would be appreciated.

cenob8 commented 7 years ago

Also tested on the wp8 cordova platform and there it works perfectly without the need of any workarounds. So the problem is only in the windows cordova platform.

brodycj commented 7 years ago

The first error I encounter is :

Could not copy the file "Y:\projects\cordova-sqlite\platforms\windows\Debug\SQLite3.WindowsPhone\SQLite3.winmd" because it was not found.

Please look at the build output tab very carefully. Something went wrong with the build at that stage.

I then manually copy these files into the following directory :

Y:\projects\cordova-sqlite\platforms\windows\Debug\SQLite3.WindowsPhone

I don't expect it to work if you manually copy those files.

If you need further help please provide the build output that you get before you encounter the "first error".