Ahmad Hassan
05/31/2023, 4:55 PMactual fun Scope.createDriver(): SqlDriver {
val databaseName = "test.db"
val fileManager = NSFileManager.defaultManager
val documentsDirectory = fileManager.URLsForDirectory(NSDocumentDirectory, inDomains = NSUserDomainMask).first() as NSURL
val destinationURL = documentsDirectory.URLByAppendingPathComponent(databaseName)
val bundlePath = MR.assets.balagh_ul_quran.url
if (!fileManager.fileExistsAtPath(destinationURL?.path.toString())) {
val response = try {
if (destinationURL != null) {
fileManager.copyItemAtURL(bundlePath, toURL = destinationURL, error = null)
} else {
}
} catch (e: Exception) {
showLog("catch:${e.message}")
}
println("myLog: $response")
}
return NativeSqliteDriver(NoteDatabase.Schema, destinationURL?.path.toString())
}
But the app is crashing.
Logs are inside the thread:Ahmad Hassan
05/31/2023, 4:55 PMUncaught Kotlin exception: org.koin.core.error.InstanceCreationException: Could not create instance for '[Singleton:'app.cash.sqldelight.db.SqlDriver']'
at 0 iOSApp 0x10401cc95 kfun:kotlin.Exception#<init>(kotlin.String?;kotlin.Throwable?){} + 133
at 1 iOSApp 0x104982af5 kfun:org.koin.core.error.InstanceCreationException#<init>(kotlin.String;kotlin.Exception){} + 133
at 2 iOSApp 0x10498472b kfun:org.koin.core.instance.InstanceFactory#create(org.koin.core.instance.InstanceContext){}1:0 + 2715
at 3 iOSApp 0x104986f52 kfun:org.koin.core.instance.SingleInstanceFactory#create(org.koin.core.instance.InstanceContext){}1:0 + 226
at 4 iOSApp 0x1049872a8 kfun:org.koin.core.instance.SingleInstanceFactory.get$lambda$0#internal + 232
at 5 iOSApp 0x104987334 kfun:org.koin.core.instance.SingleInstanceFactory.$get$lambda$0$FUNCTION_REFERENCE$0.invoke#internal + 84
at 6 iOSApp 0x10498742d kfun:org.koin.core.instance.SingleInstanceFactory.$get$lambda$0$FUNCTION_REFERENCE$0.$<bridge-UNN>invoke(){}#internal + 77
at 7 iOSApp 0x1049a470f kfun:org.koin.mp.KoinPlatformTools#synchronized(org.koin.mp.Lockable;kotlin.Function0<0:0>){0§<kotlin.Any?>}0:0 + 703
at 8 iOSApp 0x10498714a kfun:org.koin.core.instance.SingleInstanceFactory#get(org.koin.core.instance.InstanceContext){}1:0 + 362
at 9 iOSApp 0x104990b81 kfun:org.koin.core.registry.InstanceRegistry#resolveInstance(org.koin.core.qualifier.Qualifier?;kotlin.reflect.KClass<*>;org.koin.core.qualifier.Qualifier;org.koin.core.instance.InstanceContext){0§<kotlin.Any?>}0:0? + 529
at 10 iOSApp 0x10499a18c kfun:org.koin.core.scope.Scope.resolveValue#internal + 1612
at 11 iOSApp 0x10499996f kfun:org.koin.core.scope.Scope.resolveInstance#internal + 2255
at 12 iOSApp 0x104999037 kfun:org.koin.core.scope.Scope#get(kotlin.reflect.KClass<*>;org.koin.core.qualifier.Qualifier?;kotlin.Function0<org.koin.core.parameter.ParametersHolder>?){0§<kotlin.Any?>}0:0 + 2487
at 13 iOSApp 0x104a43f53 kfun:com.ahmadhassan.mynote.test.HomeVModel#<init>(){} + 995
at 14 iOSApp 0x104a40824 kfun:com.ahmadhassan.mynote.test#Home(androidx.compose.runtime.Composer?;kotlin.Int){} + 996
at 15 iOSApp 0x104a4fefc kfun:com.ahmadhassan.mynote.ComposableSingletons$Main_iosKt.<init>$lambda$0#internal + 684
at 16 iOSApp 0x104a50051 kfun:com.ahmadhassan.mynote.ComposableSingletons$Main_iosKt.$<init>$lambda$0$FUNCTION_REFERENCE$0.invoke#internal + 97
at 17 iOSApp 0x104a5010d kfun:com.ahmadhassan.mynote.ComposableSingletons$Main_iosKt.$<init>$lambda$0$FUNCTION_REFERENCE$0.$<bridge-UNNNB>invoke(androidx.compose.runtime.Composer;kotlin.Int){}#internal + 173
at 18 iOSApp 0x104357222 kfun:androidx.compose.runtime.internal.ComposableLambdaImpl#invoke(androidx.compose.runtime.Composer;kotlin.Int){}kotlin.Any? + 1106
at 19 iOSApp 0x10436d371 kfun:androidx.compose.runtime.internal.ComposableLambdaImpl#$<bridge-NNNNB>invoke(androidx.compose.runtime.Composer;kotlin.Int){}kotlin.Any?(androidx.compose.runtime.Composer;kotlin.Any?){}kotlin.Any? + 177
at 20 iOSApp 0x104978a07 kfun:moe.tlaster.precompose.PreComposeApplication$lambda$1$lambda$0#internal + 823
at 21 iOSApp 0x10497a757 kfun:moe.tlaster.precompose.$PreComposeApplication$lambda$1$lambda$0$FUNCTION_REFERENCE$9.invoke#internal + 119
at 22 iOSApp 0x10497a88d kfun:moe.tlaster.precompose.$PreComposeApplication$lambda$1$lambda$0$FUNCTION_REFERENCE$9.$<bridge-UNNNB>invoke(androidx.compose.runtime.Composer;kotlin.Int){}#internal + 173
at 23 iOSApp 0x104357222 kfun:androidx.compose.runtime.internal.ComposableLambdaImpl#invoke(androidx.compose.runtime.Composer;kotlin.Int){}kotlin.Any? + 1106
at 24 iOSApp 0x10436d371 kfun:androidx.compose.runtime.internal.ComposableLambdaImpl#$<bridge-NNNNB>invoke(androidx.compose.runtime.Composer;kotlin.Int){}kotlin.Any?(androidx.compose.runtime.Composer;kotlin.Any?){}kotlin.Any? + 177