错误是:
07/18 11:08:26:启动应用程序$ adb install-multiple -r -t E:\ Nav_drawer \ app \ build \ intermediates \ split-apk \ debug \ slices \ slice_2.apk E:\ Nav_drawer \ app \ build \ intermediates \ instant-run-apk \ debug \ app-debug.apk E:\ Nav_drawer \ app \ build \ intermediates \ split-apk \ debug \ slices \ slice_1.apk E:\ Nav_drawer \ app \ build \ intermediates \ split-apk \ debug \ slices \ slice_8.apk E:\ Nav_drawer \ app \ build \ intermediates \ split-apk \ debug \ slices \ slice_5.apk E:\ Nav_drawer \ app \ build \ intermediates \ split-apk \ debug \ slices \ slice_6.apk E:\ Nav_drawer \ app \ build \ intermediates \ split-apk \ debug \ slices \ slice_7.apk E:\ Nav_drawer \ app \ build \ intermediates \ split-apk \ debug \ slices \ slice_4.apk E:\ Nav_drawer \ app \ build \ intermediates \ split-apk \ debug \ slices \ slice_9.apk E:\ Nav_drawer \ app \ build \ intermediates \ split-apk \ debug \ slices \ slice_3.apk E:\ Nav_drawer \ app \ build \ intermediates \ split-apk \ debug \ dep \ dependencies.apk E:\ Nav_drawer \ app \ build \ intermediates \ split-apk \ debug \ slices \ slice_0.apk 安装已拆分的APK $ $ adb shell am start -n “ com.example.nidhi.nav_drawer / com.example.nidhi.nav_drawer.MainActivity” -a android.intent.action.MAIN -c android.intent.category.LAUNCHER客户端尚未准备好..等待进程上线等待 进程上线已连接到设备上的进程3012 emulator-5554从以下位置捕获并显示logcat消息 应用。可以在“ Logcat输出”中禁用此行为 “调试器”设置页面中的部分。 D / AndroidRuntime:关闭 虚拟机
--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.nidhi.nav_drawer, PID: 3012
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nidhi.nav_drawer/com.example.nidhi.nav_drawer.MainActivity}: java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to android.support.v7.widget.Toolbar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to android.support.v7.widget.Toolbar
at com.example.nidhi.nav_drawer.MainActivity.onCreate(MainActivity.java:32)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Application terminated.
答案 0 :(得分:0)
您的代码说FramLayout无法转换为工具栏
所以这意味着您需要像这样将Framelayout投射到工具栏
Login
尝试这样更改
frame = (Toolbar) findViewById(R.id.Frameloayout);
答案 1 :(得分:0)
为什么要尝试将FrameLayout投射到工具栏上? FrameLayout永远不会投射到工具栏,请进行更改。