我的应用程序已关闭(崩溃)并在Android监视器上显示错误: activities.MainActivity.onCreate(MainActivity.java:77) 我该怎么办?!
这是我的logcat:
03-14 10:21:04.255 5003-5003/com.panaceasoft.citiesdirectorySHZ E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.panaceasoft.citiesdirectorySHZ, PID: 5003
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.panaceasoft.citiesdirectorySHZ/com.panaceasoft.citiesdirectorySHZ.activities.MainActivity}: android.view.InflateException: Binary XML file line #12: Binary XML file line #12: Error inflating class android.support.design.widget.NavigationView
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: android.view.InflateException: Binary XML file line #12: Binary XML file line #12: Error inflating class android.support.design.widget.NavigationView
Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class android.support.design.widget.NavigationView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.panaceasoft.citiesdirectorySHZ.activities.MainActivity.onCreate(MainActivity.java:77)
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)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/internal/view/menu/MenuBuilder;
at android.support.design.widget.NavigationView.<init>(NavigationView.java:95)
at android.support.design.widget.NavigationView.<init>(NavigationView.java:88)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.panaceasoft.citiesdirectorySHZ.activities.MainActivity.onCreate(MainActivity.java:77)
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)
03-14 10:21:04.255 5003-5003/com.panaceasoft.citiesdirectorySHZ E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.internal.view.menu.MenuBuilder" on path: DexPathList[[zip file "/data/app/com.panaceasoft.citiesdirectorySHZ-1/base.apk", zip file "/data/app/com.panaceasoft.citiesdirectorySHZ-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.panaceasoft.citiesdirectorySHZ-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.panaceasoft.citiesdirectorySHZ-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.panaceasoft.citiesdirectorySHZ-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.panaceasoft.citiesdirectorySHZ-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.panaceasoft.citiesdirectorySHZ-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.panaceasoft.citiesdirectorySHZ-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.panaceasoft.citiesdirectorySHZ-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.panaceasoft.citiesdirectorySHZ-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.panaceasoft.citiesdirectorySHZ-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.panaceasoft.citiesdirectorySHZ-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.panaceasoft.citiesdirectorySHZ-1/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 27 more
这是我的MainActivity java代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initUtils();
initUI();
initData();
bindData();
}
这是我的build.gradle:
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.panaceasoft.citiesdirectorySHZ"
minSdkVersion 10
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/android-async-http-1.4.4.jar')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:palette-v7:22.2.1'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.pnikosis:materialish-progress:1.5'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.afollestad.material-dialogs:core:0.9.0.1'
compile 'com.github.rey5137:material:1.1.1'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}