-
Notifications
You must be signed in to change notification settings - Fork 113
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
Error CapacitorSQLitePlugin :null only in production #494
Comments
@wimZ Not really an idea. May be you should try to invalidate the cache File->Invalidate Caches select all caches and invalidate and restart. and redo the full sequence npx cap sync
npm run build
npx cap copy
npx cap open android in Android Studio do
i never published an app to the play-store, i only develop capacitor plugins, so here i cannot help Hope this will help Which version of Android Studio ? |
@jepiqueau: The rebuild as described was not successful. Android Studio is 2023.1.1 ;) |
I had the same problem, but not in production but with the app-debug that generates the I have been able to analyze that this only happens on certain Android devices, specifically on my physical device that has Android 12, but on Android Studio emulated devices this problem does not occur (I tried APIs 30, 31 and 32). I've also noticed ambiguities depending on what OS I run my Ionic project on. Since it works perfectly on the physical device if I run it on Manjaro OS. Post data: This is the first time I speak in a discussion forum here on Git hub, if I have been impertinent in any community rule, I apologize to everyone. I have attached my |
I did the same process and I got the exact same thing. |
@wimZ @ileosebastian |
@rijeshpk thnks for this, |
@jepiqueau, BTW I use plain capacitor without framework In order to figure out where it starts to fail, I wanted to create a minimal app and rebuild from there while phased testing After initial setup as per: https://capacitorjs.com/docs/getting-started Then I get the following result my index.js (stripped out non-essentials) import {CapacitorSQLite,SQLiteConnection) from '@capacitor-community/sqlite' //1 //2 //3 //4 This result expected, since the table does not exist |
@wimZ can you share your minimal app |
How do I share?
Whole folder in zip?
----------------------------------------
18 dec 2023 17:46:10 QUEAU Jean Pierre ***@***.***>:
…
@wimZ[https://github.com/wimZ]
can you share your minimal app
—
Reply to this email directly, view it on
GitHub[#494 (comment)],
or
unsubscribe[https://github.com/notifications/unsubscribe-auth/AD2YDNPRRJQRJHA7SSLEOGTYKBXNBAVCNFSM6AAAAABAR6PYW6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRRGAZDCMRSG4].
You are receiving this because you were mentioned.
[Tracking
afbeelding][https://github.com/notifications/beacon/AD2YDNMG6DPYV4UMGVJ2DHDYKBXNBA5CNFSM6AAAAABAR6PYW6WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTO5TXCW.gif]
|
Any solution, it does not work for me at all |
In fact @jepiqueau, I can say that what @rijeshpk says works perfectly for my case. That is, I applied everything mentioned in android-quirks (I didn't do it before because I was testing it only in a web environment with SQL queries) and then reinstalled all the packages and added android back to the ionic project to see if it worked. It is indeed an error in the cache and/or permissions that the application has that is causing the CapacitorSQLitePlugin to not be instantiated. |
Following only the lines of code that execute the queries from the plugin (but uncommented), the 'test' table is never created in the first instance, so it is correct that the query cannot be made. |
Maybe you noticed the error on 3 the DROP TABLE.
I get the same error on each execute. create and drop
query seems to work, since it gives an expected 'no such table'
I removed the CREATE TABLE should have removed the Drop.
…----------------------------------------
19 dec 2023 01:45:13 Leo Intriago ***@***.***>:
import {CapacitorSQLite,SQLiteConnection) from
***@***.***/sqlite' const _db = CapacitorSQLite const
dbName='abc'
//1 await _db.createConnection({database: dbName,encrypted: false,mode:
'no-encryption',version: 1,})
//2 await _db.open({ database: dbName })
//3 await _db.execute({database: dbName, statements: [*DROP TABLE IF
NOT EXIST test*], values: [],}) Error: Execute: Attempt to invoke
virtual method 'java.lang.String
java.lang.String.replace(java.lang.CharSequence,
java.lang.CharSequence)' on a null object reference at returnResult
((index):917:32) at cap.fromNative ((index):899:17) at :1:18
//4 await _db.query({database: dbName, statement: 'Select * from test',
values: [], }) Error: Query: in selectSQL cursor no such table: test: ,
while compiling: Select * from test
This result expected, since the table does not exist
Following only the lines of code that execute the queries from the
plugin (but uncommented), the 'test' table is never created in the
first instance, so it is correct that the query cannot be made.
—
Reply to this email directly, view it on
GitHub[#494 (comment)],
or
unsubscribe[https://github.com/notifications/unsubscribe-auth/AD2YDNPHZ3RXWP3SYPOYBRDYKDPRPAVCNFSM6AAAAABAR6PYW6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRRHEZDCMBUG4].
You are receiving this because you were mentioned.
[Tracking
afbeelding][https://github.com/notifications/beacon/AD2YDNK24TXFIR3NRS62ESTYKDPRPA5CNFSM6AAAAABAR6PYW6WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTO7KURO.gif]
|
@wimZ can you share it on github so i can clone it and test it |
You should now have access Appreciate your support!!! |
@wimZ can you give me the link |
@wimZ i mean the link to your github repository where you have updated your app so i can clone it quickly |
my 1st time sharing. |
@wimZ i got it and i will have a look |
@wimZ Did the bug happens on Android as you do not implement the web part |
Yes its android where it fails My original app is only android. |
@wimZ modify your index.js file as below: /** @format */
import { SplashScreen } from '@capacitor/splash-screen'
import {
CapacitorSQLite,
SQLiteConnection,
} from '@capacitor-community/sqlite'
const _sqlite = CapacitorSQLite
const sqliteConnection = new SQLiteConnection(_sqlite);
let _db
let dbName = 'abcdefghijk',
result = false
const main = () => {
SplashScreen.hide()
document
.querySelector('#connect-db')
.addEventListener('click', async function (e) {
try {
console.log('creating connection')
_db = await sqliteConnection.createConnection(
dbName, false, 'no-encryption', 1, false)
console.log("$$$$ _db: ",_db)
} catch (e) {
console.info(e.message)
}
})
document
.querySelector('#open-db')
.addEventListener('click', async function (e) {
try {
console.info('opening db')
await _db.open()
} catch (e) {
console.info(e.message)
}
})
document
.querySelector('#drop-db')
.addEventListener('click', async function (e) {
try {
result = await _db.execute(`DROP TABLE IF EXISTS test;`)
console.log(result)
} catch (e) {
console.info(e.message)
console.log(e.stack)
}
})
document
.querySelector('#create-db')
.addEventListener('click', async function (e) {
try {
result = await _db.execute(
`CREATE TABLE IF NOT EXISTS test ('sleutel','naam')`)
console.log(result)
} catch (e) {
console.info(e.message)
}
})
document
.querySelector('#insert-db')
.addEventListener('click', async function (e) {
try {
result = await _db.execute(
`insert into test (sleutel, naam) VALUES (1, 'truus');`)
console.log(result)
} catch (e) {
console.info(e.message)
}
try {
result = await _db.execute('insert into test (sleutel, naam) VALUES (2, "kees");')
console.log(result)
} catch (e) {
console.info(e.message)
}
})
document
.querySelector('#query-db')
.addEventListener('click', async function (e) {
try {
result = await _db.query('Select * from test;',[])
console.log(JSON.stringify(result.values))
console.log(result)
} catch (e) {
console.info(e.message)
}
})
}
main() this will work |
Works! Thanks. The app was migrated from Cordova, and as far as I recall I never modified the way I instantiated sqlite db I'll check if problem in the app can be solved the same way. |
Tests so far show that my issue is resolved. Thanks for supporting this. |
Discussed in #493
Originally posted by wimZ December 11, 2023
My app used to run fine in producton.
After various modifications and plugin updates, it now runs fine in debug mode on a Samsung A53 5G (Android 13) but when I publish to play-store and install on the same device I get error : CapacitorSQLitePlugin :null
The error occurs on createConnection
Install from Playstore to an older device with Android 9 and it runs fine.
I have
rolled back recent updates
cleaned project
reinstalled SQLite including some previous versions
I would appreciate any suggestions how to proceed.
The text was updated successfully, but these errors were encountered: