Crash when creating database on Android 4
- Android version: 4.2.2
- Phone model: Huawei Ascend Y330
Stacktrace:
2022-04-27 12:54:22.506 3426-3618/org.briarproject.mailbox E/AndroidRuntime: FATAL EXCEPTION: Thread-370
org.briarproject.mailbox.core.db.DbException: org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets" [50000-200]
at org.briarproject.mailbox.core.db.JdbcDatabase.startTransaction(JdbcDatabase.kt:261)
at org.briarproject.mailbox.core.db.JdbcDatabase.startTransaction(JdbcDatabase.kt:235)
at org.briarproject.mailbox.core.db.JdbcDatabase.transaction(JdbcDatabase.kt:669)
at org.briarproject.mailbox.core.db.JdbcDatabase.read(JdbcDatabase.kt:657)
at org.briarproject.mailbox.core.db.H2Database.databaseHasSettingsTable(H2Database.kt:71)
at org.briarproject.mailbox.core.db.JdbcDatabase.open$mailbox_core(JdbcDatabase.kt:120)
at org.briarproject.mailbox.core.db.H2Database.open(H2Database.kt:64)
at org.briarproject.mailbox.core.lifecycle.LifecycleManagerImpl.startServices(LifecycleManagerImpl.kt:115)
at org.briarproject.mailbox.android.MailboxService$onCreate$1.invoke(MailboxService.kt:103)
at org.briarproject.mailbox.android.MailboxService$onCreate$1.invoke(MailboxService.kt:102)
at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets" [50000-200]
at org.h2.engine.Database.openDatabase(Database.java:333)
at org.h2.engine.Database.<init>(Database.java:301)
at org.h2.engine.Engine.openSession(Engine.java:74)
at org.h2.engine.Engine.openSession(Engine.java:192)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:171)
at org.h2.engine.Engine.createSession(Engine.java:166)
at org.h2.engine.Engine.createSession(Engine.java:29)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:340)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:173)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:152)
at org.h2.Driver.connect(Driver.java:69)
at java.sql.DriverManager.getConnection(DriverManager.java:175)
at org.briarproject.mailbox.core.db.H2Database.createConnection(H2Database.kt:115)
at org.briarproject.mailbox.core.db.JdbcDatabase.startTransaction(JdbcDatabase.kt:254)
at org.briarproject.mailbox.core.db.JdbcDatabase.startTransaction(JdbcDatabase.kt:235)
at org.briarproject.mailbox.core.db.JdbcDatabase.transaction(JdbcDatabase.kt:669)
at org.briarproject.mailbox.core.db.JdbcDatabase.read(JdbcDatabase.kt:657)
at org.briarproject.mailbox.core.db.H2Database.databaseHasSettingsTable(H2Database.kt:71)
at org.briarproject.mailbox.core.db.JdbcDatabase.open$mailbox_core(JdbcDatabase.kt:120)
at org.briarproject.mailbox.core.db.H2Database.open(H2Database.kt:64)
at org.briarproject.mailbox.core.lifecycle.LifecycleManagerImpl.startServices(LifecycleManagerImpl.kt:115)
at org.briarproject.mailbox.android.MailboxService$onCreate$1.invoke(MailboxService.kt:103)
at org.briarproject.mailbox.android.MailboxService$onCreate$1.invoke(MailboxService.kt:102)
at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
Caused by: java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets
at org.h2.mvstore.MVStore.writeStoreHeader(MVStore.java:1096)
at org.h2.mvstore.MVStore.<init>(MVStore.java:390)
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:3579)
at org.h2.mvstore.db.MVTableEngine$Store.open(MVTableEngine.java:170)
at org.h2.mvstore.db.MVTableEngine.init(MVTableEngine.java:103)
at org.h2.engine.Database.getPageStore(Database.java:2659)
at org.h2.engine.Database.open(Database.java:675)
at org.h2.engine.Database.openDatabase(Database.java:307)
at org.h2.engine.Database.<init>(Database.java:301)
at org.h2.engine.Engine.openSession(Engine.java:74)
at org.h2.engine.Engine.openSession(Engine.java:192)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:171)
at org.h2.engine.Engine.createSession(Engine.java:166)
at org.h2.engine.Engine.createSession(Engine.java:29)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:340)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:173)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:152)
at org.h2.Driver.connect(Driver.java:69)
at java.sql.DriverManager.getConnection(DriverManager.java:175)
at org.briarproject.mailbox.core.db.H2Database.createConnection(H2Database.kt:115)
at org.briarproject.mailbox.core.db.JdbcDatabase.startTransaction(JdbcDatabase.kt:254)
at org.briarproject.mailbox.core.db.JdbcDatabase.startTransaction(JdbcDatabase.kt:235)
at org.briarproject.mailbox.core.db.JdbcDatabase.transaction(JdbcDatabase.kt:669)
at org.briarproject.mailbox.core.db.JdbcDatabase.read(JdbcDatabase.kt:657)
at org.briarproject.mailbox.core.db.H2Database.databaseHasSettingsTable(H2Database.kt:71)
at org.briarproject.mailbox.core.db.JdbcDatabase.open$mailbox_core(JdbcDatabase.kt:120)
at org.briarproject.mailbox.core.db.H2Database.open(H2Database.kt:64)
at org.briarproject.mailbox.core.lifecycle.LifecycleManagerImpl.startServices(LifecycleManagerImpl.kt:115)
at org.briarproject.mailbox.android.MailboxService$onCreate$1.invoke(MailboxService.kt:103)
at org.briarproject.mailbox.android.MailboxService$onCreate$1.invoke(MailboxService.kt:102)
at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
Looks like the crash ultimately comes from H2's MVStore#writeStoreHeader():
byte[] bytes = buff.toString().getBytes(StandardCharsets.ISO_8859_1);
StandardCharsets was added in Java 7, so it won't be available on Android < 7. Looks like we might need to downgrade H2 to the same version we're using for Briar.
Incidentally there's a Soup Nazi reference in the StandardCharsets source. :-)