-
Notifications
You must be signed in to change notification settings - Fork 19
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
App getting crash #4
Comments
Are you using |
@developernotes
|
Hi @theBlbDan, A couple of questions regarding your application configuration:
We had a long thread in the |
I saw issue 587 last night and read through it as well as this one. I do use App Bundles and no on abiFilters. My minSDK is 24, so ReLinker won't be of any use. I don't believe that SplitInstallHelper is of any use when using App Bundles. Of the 400+ crash reports I've received on this new build, it's only affecting three devices and is definitely on first installs. I'm only at 25% roll-out, so that is helping to keep it reduced. Possibly related? Native library failed to load |
I'm seeing this intermittently as well in our release builds (proguarded). Our debug builds don't seem to suffer from this problem. |
Hi @theBlbDan, I'm sorry for the delay in response, I didn't receive a notification to your latest reply. This may be a stretch, but I did find this reference on StackOverflow 1 which could be related to your specific release packaging. Would you mind taking a look and let us know if this change impacts the behavior you are seeing? Thanks! Footnotes |
@developernotes - FWIW, I'm dealing with straight APKs, no app bundles. I'm seeing this in my minified release builds (with proguard rules added ala #18 , but my debug builds work fine. Stack trace is a little bit different since we're using Room (and 4.5.5, so line numbers are a little bit different), but fails at the same nativeOpen call.
We had to rollback to the 4.5.4 legacy library due to this issue. |
@mandrachek out of curiosity, do you have something like this within your ProGuard file:
If not, would you add it and let us know if the behavior is different with a release build? |
Yes, that's already in our proguard-rules.pro |
@mandrachek if you disable ProGuard, but perform a release build does it still crash? |
@developernotes - checking... yes, even with minification disabled, the release build crashes. The only differences in configuration for us are pretty standard stuff - signing configurations, a couple manifest placeholders (release builds have canProfile set to true, debug builds have useCleartextTraffic set to true), and debug builds have isDebuggable set to true, and release builds (normally) have isMinifyEnabled (and proguard files set up) |
@developernotes - I noticed that in the merged manifest, According to the tooltip, if extractNativeLibs is false, the libraries have to be stored and page-aligned. Is it possible the libsqlcipher.so in the aar is not page-aligned? |
Well... I spoke too soon turns out that didn't solve the problem. It appeared to delay it. I was able to launch our app, login, download data, put it in a sqlcipher db, and then at some point, down the road, while using the app, blammo:
|
@developernotes no luck. |
Still haven't been able to figure this out. :( |
download that app from playstore , slideloads app gets this crashs only |
@goldfish07 are you using ProGuard? |
@developernotes I am currently chasing a |
@theBlbDan #15 I migrated to sqlcipher recently and started seeing these crashes. I never had them when using plain slit |
yes |
Hi @zkrige, We recently merged in a pull request for ProGuard support within the library. Can you compare your configuration to this? |
thanks @developernotes - I dont think #15 is related to proguard as its not complaining about classes not found - its complaining about connection being closed when it shouldn't be. I was just letting @theBlbDan know that I had the same crash |
@mandrachek can you try out the new ProGuard configuration that was merged into master here. Additionally, if you're not already using |
@developernotes -Sorry, but that doesn't help. I'm doing
If you recall, I also get the crash on my release builds even with R8/Proguard disabled (
I'm doing: override fun onCreate() {
super<Application>.onCreate()
System.loadLibrary("sqlcipher");
...
} It's like some of the room/coroutine threads can't see the loaded library. |
So, I think I've got a fix! Loading the native library in We have a number of database modules that look something like this: @Module
@InstallIn(SingletonComponent::class)
object MyDatabaseModule {
@Singleton
@Provides
fun provideMyDatabase(
@ApplicationContext context: Context,
...
): MyDatabase = Room.databaseBuilder(
context,
MyDatabase::class.java,
MY_DATABASE
)
.setJournalMode(RoomDatabase.JournalMode.WRITE_AHEAD_LOGGING)
.fallbackToDestructiveMigration()
.apply {
openHelperFactory(SupportOpenHelperFactory(password.toByteArray()))
}.build() It looks like adding |
@developernotes ^^ - this was indeed the fix for me. |
Hello @mandrachek, Thank you for your follow-up, we're happy to hear you were able to resolve the issue. Loading the native library into the running process is required before initializing any SQLCipher Java component (i.e., |
@developernotes - the odd thing is that it's called in my application.onCreate() - I must have one being injected by dagger/hilt before the onCreate() call. |
@mandrachek's solution also worked for me, thanks! Here's what seems to be working (as said earlier @mandrachek ): @Singleton
@Provides
fun provideAppDatabase(@ApplicationContext context: Context): DB =
Room.databaseBuilder(
context.applicationContext,
DB::class.java,
Constants.DB_NAME
)
.apply {
// 1. Load library here.
System.loadLibrary("sqlcipher")
// 2. Enable WAL journal mode to improve performance as per official doc.
openHelperFactory(SupportOpenHelperFactory(Keys.secretKeyForEncryption().toByteArray(),null,true))
}
.fallbackToDestructiveMigration()
.build() Do enable WAL journal mode to improve performance as per the official doc. |
We are running into a similar issue and based on what I can see calling Is there a a threading components as in on whatever thread isn't being called? Basing this on #4 (comment) where it's mentioned that it seems like the coroutines aren't aware of the library being loaded? Any other potential reasons that I could look into. I tried the proguard but with or without it (in debug builds) I'm seeing this issue. |
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbOutputFile, "password", null, null, null);
implementation 'net.zetetic:sqlcipher-android:4.5.2'
implementation 'androidx.sqlite:sqlite:2.1.0'
Here are the logs I am getting,
java.lang.UnsatisfiedLinkError: No implementation found for long net.zetetic.database.sqlcipher.SQLiteConnection.nativeOpen(java.lang.String, int, java.lang.String, boolean, boolean) (tried Java_net_zetetic_database_sqlcipher_SQLiteConnection_nativeOpen and Java_net_zetetic_database_sqlcipher_SQLiteConnection_nativeOpen__Ljava_lang_String_2ILjava_lang_String_2ZZ)
at net.zetetic.database.sqlcipher.SQLiteConnection.nativeOpen(Native Method)
at net.zetetic.database.sqlcipher.SQLiteConnection.open(SQLiteConnection.java:222)
at net.zetetic.database.sqlcipher.SQLiteConnection.open(SQLiteConnection.java:198)
at net.zetetic.database.sqlcipher.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:474)
at net.zetetic.database.sqlcipher.SQLiteConnectionPool.open(SQLiteConnectionPool.java:189)
at net.zetetic.database.sqlcipher.SQLiteConnectionPool.open(SQLiteConnectionPool.java:181)
at net.zetetic.database.sqlcipher.SQLiteDatabase.openInner(SQLiteDatabase.java:1029)
at net.zetetic.database.sqlcipher.SQLiteDatabase.open(SQLiteDatabase.java:1014)
at net.zetetic.database.sqlcipher.SQLiteDatabase.openDatabase(SQLiteDatabase.java:841)
at net.zetetic.database.sqlcipher.SQLiteDatabase.openDatabase(SQLiteDatabase.java:813)
at net.zetetic.database.sqlcipher.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:910)
The text was updated successfully, but these errors were encountered: