Cordova-sqlite-storage: -[__NSDictionaryM length]: unrecognized selector

Created on 23 Apr 2015  路  5Comments  路  Source: storesafe/cordova-sqlite-storage

I recently updated to 10.10.3 and xcode 6.3.1 and I can't use this plugin anymore. The app freezes after ~0.5s and disabling the plugin seems to solve the issue. I don't know ObjectiveC but I'll be happy to help you solve this problem.

Here is the stack trace I got from ionic run:

(lldb) 2015-04-23 16:01:08.824 tqf[189:5076] Initializing SQLitePlugin
2015-04-23 16:01:08.825 tqf[189:5076] Detected docs path: /var/mobile/Containers/Data/Application/78C2AD10-F65D-4DDB-8A03-7CCD4D0D93ED/Documents
2015-04-23 16:01:08.826 tqf[18(lldb) 9:5076] Detected Library path: /var/mobile/Containers/Data/Application/78C2AD10-F65D-4DDB-8A03-7CCD4D0D93ED/Library
(lldb) 2015-04-23 16:01:08.829 tqf[189:5076] no cloud sync at path: /var/mobile/Containers/Data/Application/78C2AD10-F65D-4DDB-8A03-7CCD4D0D93ED/Library/LocalDatabase
(lldb) 2015-04-23 16:01:08.831 tqf[189:5076] -[__NSDictionaryM length]: unrecognized selector sent to instance 0x15e8c490
2015-04-23 16:01:08.832 tqf[189:5076] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSD(lldb) ictionaryM length]: unrecognized selector sent to instance 0x15e8c490'
*** First throw call stack:
(0x2bb22137 0x39bb2c77 0x2bb275fd 0x2bb254d9 0x2ba549d8 0x2c7ad79b 0xa2127 0xa22ad 0x1336ab 0x132f9f 0x2c855125 0x2bae815f 0x2bae7ce1 0x2bae5f4b 0x2ba319a1(lldb)  0x2ba317b3 0x3320a1a9 0x2f1bc695 0x2a513 0x3a15aaaf)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) Process 189 stopped
* thread #1: tid = 0x13d4, 0x3a220df0 libsystem_kernel.dylib`__pthread_kill + 8, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x3a220df0 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
->  0x3a220df0 <+8>:  blo    0x3a220e08                ; <+32>
    0x3a220df4 <+12>: ldr    r12, [pc, #0x4]           ; <+24>
    0x3a220df8 <+16>: ldr    r12, [pc, r12]
    0x3a220dfc <+20>: b      0x3a220e04                ; <+28>
(lldb) ^C
bug-general question doc-general

Most helpful comment

That solved the issue, thanks a lot! I was using ngCordova the wrong way.

$cordovaSQLite.openDB({ name: SQL_DB_NAME + '.db' }); // NOPE
$cordovaSQLite.openDB(SQL_DB_NAME + '.db') // YUP

All 5 comments

Looks like the same cause as was reported in litehelpers/Cordova-sqlcipher-adapter#5.

The example in the document at http://ngcordova.com/docs/plugins/sqlite/ tells you pass an object in the first argument, but looking in the code at https://github.com/driftyco/ng-cordova/blob/master/src/plugins/sqlite.js it really expects a string with the name of your database file.

I was able to reproduce your error with the following code in my sample app:

    var a1 = { name: 'aaa', location: 1};
    window.sqlitePlugin.openDatabase({name: a1}, function(db) { alert('ok')}, function(err) {alert('error')});

Please double-check your code and try it again.

I will add a check that the database name must be a string.

That solved the issue, thanks a lot! I was using ngCordova the wrong way.

$cordovaSQLite.openDB({ name: SQL_DB_NAME + '.db' }); // NOPE
$cordovaSQLite.openDB(SQL_DB_NAME + '.db') // YUP

FYI I just updated the Javascript to make sure the database name is given as a string, and throw an exception if not. Will add a test when I get a chance.

Thank prevostc you solution worked

FYI I just updated the Javascript to make sure the database name is given as a string, and throw an exception if not. Will add a test when I get a chance.

Test is now added, closing.

Was this page helpful?
0 / 5 - 0 ratings