Skip to content
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

日历崩溃:KotlinNullPointerException #97

Open
victorfan336 opened this issue Dec 19, 2024 · 2 comments
Open

日历崩溃:KotlinNullPointerException #97

victorfan336 opened this issue Dec 19, 2024 · 2 comments

Comments

@victorfan336
Copy link

复现步骤:从其他页面切换到日历页后就崩溃了,偶先,容易在第一次安装使用的时候出现,后面极难出现。
android 系统: android 14
android 机型: 红米K60,其他设备如华为也都出现过。
CPU架构:arm64-v8a

崩溃日志:

com.necer.calendar.NViewPager$a$a.run(Unknown Source:191)
2
android.os.Handler.handleCallback(Handler.java:958)
3
android.os.Handler.dispatchMessage(Handler.java:99)
4
android.os.Looper.loopOnce(Looper.java:205)
5
android.os.Looper.loop(Looper.java:294)
6
android.app.ActivityThread.main(ActivityThread.java:8376)
7
java.lang.reflect.Method.invoke(Native Method)
8
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:640)
9
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:982)

@yannecer 麻烦看看,谢谢

@victorfan336
Copy link
Author

victorfan336 commented Dec 19, 2024

我已经没有混淆日历代码了。加了:
-keep class com.necer.** {*;}

结果还是崩溃:
前后台状态: 前台

设备机型: 23013RK75C

系统版本: Android 14,level 34

ROM: XiaoMi/MIUI

CPU架构: arm64-v8a

com.necer.calendar.NViewPager$1$onPageSelected$1.run(Unknown Source:215) 2 android.os.Handler.handleCallback(Handler.java:958) 3 android.os.Handler.dispatchMessage(Handler.java:99) 4 android.os.Looper.loopOnce(Looper.java:224) 5 android.os.Looper.loop(Looper.java:318) 6 android.app.ActivityThread.main(ActivityThread.java:8777) 7 java.lang.reflect.Method.invoke(Native Method) 8 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:561) 9 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)

操作步骤是调用切换日期,调用: calendar.jumpDate()的时候崩溃的

@victorfan336
Copy link
Author

victorfan336 commented Dec 19, 2024

我终于复现了:
崩溃日志:

kotlin.KotlinNullPointerException
at com.necer.calendar.NViewPager$1$onPageSelected$1.run(NViewPager.kt:79)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:224)
at android.os.Looper.loop(Looper.java:318)

源码位置:
com.necer.calendar.NViewPager
`
init {
addOnPageChangeListener(object : SimpleOnPageChangeListener() {
override fun onPageSelected(position: Int) {
super.onPageSelected(position)
post {
//算出相差几页
var localDate = if (calendarState == CalendarState.WEEK) {
} else {
// 这里崩溃了 !!!!
val intervalMonths = NDateUtil.getIntervalMonths(fulcrumDate, currentViewInitDate!!)
}
}

  }

}
`

不知道是fulcrumDate = null 还是 currentViewInitDate = null 了,最好是别用 ”!!“,否则会有意想不到的惊喜。

我用的是最新版:"6.0.0"

麻烦修复一下,谢谢

@victorfan336 victorfan336 changed the title 日历崩溃 日历崩溃:KotlinNullPointerException Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant