java.lang.RuntimeException: Unable to start activity ComponentInfo{www.xl06.xyz/www.xl06.xyz.ui.MainActivity}: kotlin.TypeCastException: null cannot be cast to non-null type android.support.v7.widget.Toolbar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2419)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2479)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5420)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: kotlin.TypeCastException: null cannot be cast to non-null type android.support.v7.widget.Toolbar
at www.xl06.xyz.ui.MainActivity$toolbar$2.invoke(MainActivity.kt:27)
at www.xl06.xyz.ui.MainActivity$toolbar$2.invoke(MainActivity.kt:12)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at www.xl06.xyz.ui.MainActivity.getToolbar(MainActivity.kt)
at www.xl06.xyz.utils.ToolBarManger$DefaultImpls.MianToolBAr(ToolBarManger.kt:12)
at www.xl06.xyz.ui.MainActivity.MianToolBAr(MainActivity.kt:12)
at www.xl06.xyz.ui.MainActivity.initData(MainActivity.kt:21)
at www.xl06.xyz.base.BasesActivity.onCreate(BasesActivity.kt:19)
at android.app.Activity.performCreate(Activity.java:6267)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2372)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2479)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5420)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
我的是类型找错
override val toolbar by lazy { find<Toolbar>(R.layout.toolbar) } //错误代码
override val toolbar by lazy { find<Toolbar>(R.id.toolbar) }//正确代码