无法实例化以下类: - android.support.design.widget.NavigationView

时间:2017-01-19 19:41:03

标签: android android-navigationview android-api-levels

我正在尝试在我的应用中使用此https://github.com/Siclo-Mobile/EZPhotoPicker

我的build.gradle(在“app”文件夹中)在实现之前看起来像这样(并且应用程序工作正常):

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
 
repositories {
    maven { url 'https://maven.fabric.io/public' }
}
 
android {
    signingConfigs {
        vitalRelease {
            keyAlias 'XXXX'
            keyPassword 'XXXXX'
            storeFile file('XXXXXXXXXXX')
            storePassword 'XXXXXXX'
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    defaultConfig {
        applicationId "com.enye.cme"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
}
 
buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }
 
    dependencies {
        // The Fabric Gradle plugin uses an open ended version to react
        // quickly to Android tooling updates
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
 
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'com.android.support:cardview-v7:23.0.1'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.github.bumptech.glide:glide:3.6.1'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.google.code.gson:gson:1.7.2'
    compile 'com.splitwise:tokenautocomplete:2.0.2@aar'
    compile 'com.github.citux:datetimepicker:0.2.0'
    compile 'com.prolificinteractive:material-calendarview:1.1.0'
    //compile 'com.nbsp:library:1.08'
    compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
    compile 'com.google.android.gms:play-services-ads:9.0.0'
    compile('com.crashlytics.sdk.android:answers:1.3.6@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
        transitive = true;
    }
    compile 'com.nononsenseapps:filepicker:2.5.2'
    compile 'com.google.firebase:firebase-core:9.0.0'
    compile 'com.google.firebase:firebase-messaging:9.0.0'
    compile 'com.google.android.gms:play-services-appindexing:9.0.0'
}
 
apply plugin: 'com.google.gms.google-services'

我按照GitHub中README.md中给出的说明,现在我的build.gradle看起来像这样:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url 'https://dl.bintray.com/siclo/SicloAndroidOSS' } //ADDED THIS LINE
}

android {
    signingConfigs {
        vitalRelease {
            keyAlias 'XXXXX'
            keyPassword 'XXXXXX'
            storeFile file('XXXXXXXXXXX')
            storePassword 'XXXXXX'
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    defaultConfig {
        applicationId "com.enye.cme"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.vitalRelease
        }
    }
    productFlavors {
        vital {
            applicationId "com.enye.mce"
            buildConfigField 'String', 'appId', '"MCE"';
        }

        cuidam {
            applicationId "com.enye.cuidam"
            buildConfigField 'String', 'appId', '"CUIDAM"';
        }
    }
}

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        // The Fabric Gradle plugin uses an open ended version to react
        // quickly to Android tooling updates
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'com.android.support:cardview-v7:23.0.1'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.github.bumptech.glide:glide:3.6.1'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.google.code.gson:gson:1.7.2'
    compile 'com.splitwise:tokenautocomplete:2.0.2@aar'
    compile 'com.github.citux:datetimepicker:0.2.0'
    compile 'com.prolificinteractive:material-calendarview:1.1.0'
    //compile 'com.nbsp:library:1.08'
    compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
    compile 'com.google.android.gms:play-services-ads:9.0.0'
    compile('com.crashlytics.sdk.android:answers:1.3.6@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
        transitive = true;
    }
    compile 'com.nononsenseapps:filepicker:2.5.2'
    compile 'com.google.firebase:firebase-core:9.0.0'
    compile 'com.google.firebase:firebase-messaging:9.0.0'
    compile 'com.google.android.gms:play-services-appindexing:9.0.0'
    compile 'com.siclo.ezphotopick:library:1.0.1' //ADDED THIS LINE
}

apply plugin: 'com.google.gms.google-services'

正如你所看到的,除了指令中给出的那两行之外,我没有改变任何东西。 现在,当我启动应用程序时,它会崩溃并抛出这个错误:

01-18 18:51:22.096 9036-9036/com.enye.cuidam E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.enye.cuidam, PID: 9036
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.enye.cuidam/com.enye.cme.activities.MainActivity}:  android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class android.support.design.widget.NavigationView
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5443)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class android.support.design.widget.NavigationView
   at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
   at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
   at com.enye.cme.activities.MainActivity.onCreate(MainActivity.java:117)
   at android.app.Activity.performCreate(Activity.java:6245)
   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490) 
   at android.app.ActivityThread.-wrap11(ActivityThread.java) 
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
   at android.os.Handler.dispatchMessage(Handler.java:102) 
   at android.os.Looper.loop(Looper.java:148) 
   at android.app.ActivityThread.main(ActivityThread.java:5443) 
   at java.lang.reflect.Method.invoke(Native Method) 
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class android.support.design.widget.NavigationView
   at android.view.LayoutInflater.createView(LayoutInflater.java:645)
   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
   at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
   at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
   at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
   at com.enye.cme.activities.MainActivity.onCreate(MainActivity.java:117) 
   at android.app.Activity.performCreate(Activity.java:6245) 
   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130) 
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) 
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490) 
   at android.app.ActivityThread.-wrap11(ActivityThread.java) 
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
   at android.os.Handler.dispatchMessage(Handler.java:102) 
   at android.os.Looper.loop(Looper.java:148) 
   at android.app.ActivityThread.main(ActivityThread.java:5443) 
   at java.lang.reflect.Method.invoke(Native Method) 
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
Caused by: java.lang.reflect.InvocationTargetException
   at java.lang.reflect.Constructor.newInstance(Native Method)
   at android.view.LayoutInflater.createView(LayoutInflater.java:619)
   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
   at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
   at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
   at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
   at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
   at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
   at com.enye.cme.activities.MainActivity.onCreate(MainActivity.java:117) 
   at android.app.Activity.performCreate(Activity.java:6245) 
   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130) 
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) 
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490) 
   at android.app.ActivityThread.-wrap11(ActivityThread.java) 
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
   at android.os.Handler.dispatchMessage(Handler.java:102) 
   at android.os.Looper.loop(Looper.java:148) 
   at android.app.ActivityThread.main(ActivityThread.java:5443) 
   at java.lang.reflect.Method.invoke(Native Method) 
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
Caused by: java.lang.NoClassDefFoundError: android.support.design.internal.NavigationMenuPresenter
   at android.support.design.widget.NavigationView.<init>(NavigationView.java:80)
   at android.support.design.widget.NavigationView.<init>(NavigationView.java:92)
   at java.lang.reflect.Constructor.newInstance(Native Method) 
   at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
   at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
   at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
   at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
   at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
   at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
   at com.enye.cme.activities.MainActivity.onCreate(MainActivity.java:117) 
   at android.app.Activity.performCreate(Activity.java:6245) 
   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130) 
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) 
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490) 
   at android.app.ActivityThread.-wrap11(ActivityThread.java) 
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
   at android.os.Handler.dispatchMessage(Handler.java:102) 
   at android.os.Looper.loop(Looper.java:148) 
   at android.app.ActivityThread.main(ActivityThread.java:5443) 
   at java.lang.reflect.Method.invoke(Native Method) 
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 

MainActivity的第117行是这一行:

setContentView(R.layout.activity_main);

这是布局activity_main:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout"
    android:layout_width="match_parent" android:layout_height="match_parent"
    android:fitsSystemWindows="true" tools:openDrawer="start">

    <include layout="@layout/app_bar_main" android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView android:id="@+id/nav_view"
        android:layout_width="wrap_content" android:layout_height="match_parent"
        android:layout_gravity="start" android:fitsSystemWindows="true"
        app:menu="@menu/activity_main_drawer" />

</android.support.v4.widget.DrawerLayout>

我做错了吗?它甚至没有膨胀活动,我想我搞砸了build.gradle。

提前感谢您的帮助!

0 个答案:

没有答案