-
Notifications
You must be signed in to change notification settings - Fork 133
Description
The application crashes with a kotlin.UninitializedPropertyAccessException during CarPlay connection. The carContext property is being accessed before it's initialized.
To Reproduce
- Launch the application
- Wait for CarPlay connection
- Application crashes when connection is established
Expected Behavior
When CarPlay connection is established, the application should start properly and display the CarPlay interface.
CarPlay Information:
- Device: iPhone Simulator
- OS Version: iOS 17
- RNCarPlay Version: 2.4.1-beta.0
- Android Auto Information:
- Device: Android Emulator
- Android Version: Android 14
- RNCarPlay Version: 2.4.1-beta.0
Additional Context
The error occurs because the carContext property in CarPlayModule.kt is defined as lateinit. When the property is accessed before initialization, Kotlin throws an UninitializedPropertyAccessException.
Error message:
2025-06-14 03:09:51.441 7860-7860 AndroidRuntime com.bigarajapp E FATAL EXCEPTION: main
Process: com.bigarajapp, PID: 7860
kotlin.UninitializedPropertyAccessException: lateinit property carContext has not been initialized
at org.birkir.carplay.CarPlayModule.createScreen(CarPlayModule.kt:276)
at org.birkir.carplay.CarPlayModule.createTemplate$lambda$0(CarPlayModule.kt:109)
at org.birkir.carplay.CarPlayModule.$r8$lambda$9sex2LVUDdPHzECudMLMkKLR6Ow(Unknown Source:0)
at org.birkir.carplay.CarPlayModule$$ExternalSyntheticLambda5.run(D8$$SyntheticClass:0)
at android.os.Handler.handleCallback(Handler.java:995)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loopOnce(Looper.java:248)
at android.os.Looper.loop(Looper.java:338)
at android.app.ActivityThread.main(ActivityThread.java:9067)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932)
Relevant code sections:
CarPlayModule.kt - carContext definition and usage
CarPlaySession.kt - CarPlay connection management
index.js - CarPlay template creation and connection management
This issue appears to be related to the initialization order of the CarPlay connection and the management of the carContext property. Specifically, the timing of when setCarContext is called and the usage of carContext without null checks are causing the problem.