Comments (16)
I think the crash is pretty clear. In fact it is crystal clear. MMKV is NOT initiated correctly.
What is your problem?
from mmkv.
Cheers ! Sorry that I forgot to mention that I have initialize the mmkv by calling this function.
from mmkv.
I'm not sure that if you could open the screenshot or not. So I upload it again and with the paste of the snippet
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.main.bounds);
window?.backgroundColor = UIColor.white;
MMKV.initialize();
from mmkv.
I'm not buying it. Please provide the full logs of mmkv, starting from App launch.
from mmkv.
You should make MMKV.initialize() the first line of your didFinishLaunch, not the third line.
from mmkv.
Cheers !
Here's the full logs.
*** Assertion failure in +[MMKV mmkvWithID:cryptKey:rootPath:mode:expectedCapacity:], libMMKV.mm:215
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'MMKV not initialized properly, must call +initializeMMKV: in main thread before calling any other MMKV methods'
*** First throw call stack:
(
0 CoreFoundation 0x00000001804ae138 __exceptionPreprocess + 172
1 libobjc.A.dylib 0x0000000180087db4 objc_exception_throw + 56
2 Foundation 0x0000000180d2dfd8 _userInfoForFileAndLine + 0
3 MMKV 0x0000000105f11888 +[MMKV mmkvWithID:cryptKey:rootPath:mode:expectedCapacity:] + 156
4 MMKV 0x0000000105f117e0 +[MMKV mmkvWithID:cryptKey:rootPath:mode:] + 88
5 MMKV 0x0000000105f113e8 +[MMKV mmkvWithID:mode:] + 160
6 moment 0x0000000104f5041c $sSo4MMKVC6mmapID4modeABSgSS_So8MMKVModeVtcfCTO + 64
7 moment 0x0000000104f501a4 $s6moment13OperationViewC09configSubC0yyF + 728
8 moment 0x0000000104f2ed68 $s6moment8BaseViewC5frameACSo6CGRectV_tcfc + 320
9 moment 0x0000000104f2ede8 $s6moment8BaseViewC5frameACSo6CGRectV_tcfcTo + 56
10 moment 0x0000000104f50920 $s6moment13OperationViewC5frameACSo6CGRectV_tcfc + 272
11 moment 0x0000000104f50984 $s6moment13OperationViewC5frameACSo6CGRectV_tcfcTo + 56
12 moment 0x0000000104f497a4 $s6moment13OperationViewC5frameACSo6CGRectV_tcfC + 96
13 moment 0x0000000104f4959c $s6moment9GroupCellC5style15reuseIdentifierACSo011UITableViewC5StyleV_SSSgtcfc + 3152
14 moment 0x0000000104f49850 $s6moment9GroupCellC5style15reuseIdentifierACSo011UITableViewC5StyleV_SSSgtcfcTo + 160
15 moment 0x0000000104f4c5a8 $s6moment8TextCellC5style15reuseIdentifierACSo011UITableViewC5StyleV_SSSgtcfc + 228
16 moment 0x0000000104f4c688 $s6moment8TextCellC5style15reuseIdentifierACSo011UITableViewC5StyleV_SSSgtcfcTo + 160
17 UIKitCore 0x0000000185603c04 -[UITableView _dequeueReusableViewOfType:withIdentifier:] + 416
18 UIKitCore 0x0000000185603e44 -[UITableView dequeueReusableCellWithIdentifier:] + 152
19 UIKitCore 0x0000000185604034 -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:] + 216
20 UIKitCore 0x0000000185603f38 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 68
21 moment 0x0000000104f2d644 $s6moment16MomentControllerC9tableView_12cellForRowAtSo07UITableE4CellCSo0jE0C_10Foundation9IndexPathVtF + 612
22 moment 0x0000000104f2d7dc $s6moment16MomentControllerC9tableView_12cellForRowAtSo07UITableE4CellCSo0jE0C_10Foundation9IndexPathVtFTo + 136
23 UIKitCore 0x0000000185618c8c -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 1376
24 UIKitCore 0x00000001855eba54 -[UITableView _updateVisibleCellsForRanges:createIfNecessary:] + 560
25 UIKitCore 0x00000001855ec06c -[UITableView _updateVisibleCellsNow:] + 1112
26 UIKitCore 0x0000000185606168 -[UITableView layoutSubviews] + 144
27 UIKitCore 0x000000018590a128 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1492
28 QuartzCore 0x000000018a1ae654 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 440
29 QuartzCore 0x000000018a1b940c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 124
30 QuartzCore 0x000000018a0f2d30 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 460
31 QuartzCore 0x000000018a122aa8 _ZN2CA11Transaction6commitEv + 652
32 UIKitCore 0x0000000185400570 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 32
33 CoreFoundation 0x000000018040ec50 CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 20
34 CoreFoundation 0x000000018040e398 __CFRunLoopDoBlocks + 352
35 CoreFoundation 0x0000000180408c3c __CFRunLoopRun + 788
36 CoreFoundation 0x0000000180408514 CFRunLoopRunSpecific + 572
37 GraphicsServices 0x000000018ef06ae4 GSEventRunModal + 160
38 UIKitCore 0x00000001853e8040 -[UIApplication _run] + 868
39 UIKitCore 0x00000001853ebcc8 UIApplicationMain + 124
40 moment 0x0000000104f4671c main + 64
41 dyld 0x000000010515d544 start_sim + 20
42 ??? 0x00000001052020e0 0x0 + 4380958944
43 ??? 0x3401800000000000 0x0 + 3747417102437318656
)
libc++abi: terminating due to uncaught exception of type NSException
Now I have changed the position of the MMKV.initialize(). The issue remains the same.
from mmkv.
No, that is the crash stack. I'm taking about logs from console.
from mmkv.
To be clear, add a line of log before you call MMKV.initialize(). And if there's no log, then mmkv is not initiated.
from mmkv.
And if that's the case, move it to your main() function or create a constructor function for your AppDelegate.
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
init() {
MMKV.initialize()
super.init()
}
……
}
from mmkv.
I have added the lines at the beginning of the code.
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
override init(){
print(Thread.current)
MMKV.initialize()
super.init()
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.main.bounds);
window?.backgroundColor = UIColor.white;
Here is my backtrace
- thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x0000000105ec49ec libsystem_kernel.dylib__pthread_kill + 8 frame #1: 0x0000000104e6f1d0 libsystem_pthread.dylib
pthread_kill + 256
frame #2: 0x00000001801655c0 libsystem_c.dylibabort + 104 frame #3: 0x00000001802a7798 libc++abi.dylib
abort_message + 128
frame #4: 0x0000000180298eec libc++abi.dylibdemangling_terminate_handler() + 300 frame #5: 0x0000000180063498 libobjc.A.dylib
_objc_terminate() + 124
frame #6: 0x00000001802a6c70 libc++abi.dylibstd::__terminate(void (*)()) + 12 frame #7: 0x00000001802a9acc libc++abi.dylib
__cxa_rethrow + 144
frame #8: 0x0000000180087f48 libobjc.A.dylibobjc_exception_rethrow + 40 frame #9: 0x00000001804085c4 CoreFoundation
CFRunLoopRunSpecific + 748
frame #10: 0x000000018ef06ae4 GraphicsServicesGSEventRunModal + 160 frame #11: 0x00000001853e8040 UIKitCore
-[UIApplication _run] + 868
frame #12: 0x00000001853ebcc8 UIKitCore`UIApplicationMain + 124
Also, I have upgraded the UIKit to the latest version. This issue is still unfixed.
from mmkv.
What are the logs from the console?
Is it so hard to understand?
from mmkv.
You know what, I'm tired of repeating to ask the same question. Why don't you upload a reproducible demo?
from mmkv.
Sorry for causing you any trouble. I'm still learning as a beginner. Here is the repository of the project:https://github.com/EchoHayate/Moment
from mmkv.
The problem is that you have called the wrong initialize method.
// MMKV.initialize();
MMKV.initialize(rootDir: nil);
Change it as the code above and you should have no problem.
The initialize()
method is inherited from NSObject and is useless. I should make it hidden later.
from mmkv.
Cheers! I think I couldn't find the log from console even though I tried many times across the Internet. Could you please tell me how to do it? Many Thanks!
from mmkv.
https://stackoverflow.com/questions/483493/how-to-show-the-logged-messages-window-in-xcode
from mmkv.
Related Issues (20)
- crashed in Harmony Next Emulator API 11 x86_64 HOT 15
- minsdk 23 bump HOT 5
- The MMKV for HarmonyOS NEXT version lacks the interface for parsing the float type. HOT 17
- POSIX平台构建demo程序时报错 HOT 3
- MMKV for HarmonyOS NEXT 是否可以提供自定义对象的存取接口? HOT 4
- 多进程模式使用问题 HOT 1
- 在 HarmonyOS NEXT API 11 上初始化,发生崩溃,版本 : @tencent/mmkv":"1.3.5" HOT 1
- Fail to find any mmkv plugin dependencies HOT 3
- MMKV failed to build on iOS v1.3.5 HOT 4
- 一直有错误信息打印 HOT 1
- Query related to encryption key size increase HOT 1
- ohos中json字符串末尾分号丢失 HOT 5
- 鸿蒙 ide版本 Build Version: 5.0.3.100 api12 初始化的时候必现sysFreeze HOT 4
- MMKV crash (report from bugly) HOT 1
- Importing ArkTS files to JS and TS files is not allowed. <ArkTSCheck> HOT 4
- 鸿蒙导入MMKV初始化崩溃 HOT 3
- 鸿蒙版本存入字符串和取出字符串不匹配 HOT 1
- MMKV for HarmonyOS NEXT 在ts文件中无法使用 HOT 7
- 【建议】建议MMKV的python端打包发布 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mmkv.