使用时我的应用程序崩溃一次<android.support.design.widget

时间:2015-10-13 20:43:22

标签: android android-studio crash android-widget android-support-design

=“”

我创建示例项目但崩溃。

< / p>

我使用kitkat运行设备,但我的应用程序崩溃并只显示消息 异常错误为什么?我使用android studio lastversione

my build.grade 添加支持22和appcompat

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "com.android.xxx"
        minSdkVersion 19
        targetSdkVersion 19
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}


dependencies {
    //compile 'com.android.support:appcompat-v7:22.0.0'
    //compile 'com.github.shell-software:fab:1.0.5'
    compile 'com.android.support:support-v4:+'
    compile 'com.android.support:appcompat-v7:22.0.0'

    compile 'com.android.support:cardview-v7:22.0.0'
    compile 'com.android.support:recyclerview-v7:22.0.0'

    compile 'com.android.support:design:22.2.0'

    compile 'com.google.code.gson:gson:2.3'
}

我的测试活动是从android studio

创建的空白活动

我的测试活动

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="com.android.xxx.TestActivity">

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_drawer"
        android:layout_gravity="bottom|end" />

</RelativeLayout>

更新

我找到了最佳配置

这在设备和模拟器上编译并运行,我的布局

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:orientation="vertical"
        >
        <include
            android:id="@+id/toolbar"
            layout="@layout/tool_bar"
        />
        <FrameLayout
            android:id="@+id/frame"
            android:layout_width="match_parent"
            android:layout_height="401dp">

        </FrameLayout>

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_delete_black"
            android:layout_gravity="start|left" />



    </LinearLayout>



    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_gravity="start"
        app:headerLayout="@layout/header"
        app:menu="@menu/drawer"
        />
</android.support.v4.widget.DrawerLayout>

我的剧本

apply plugin: 'com.android.application'

android {
//    compileSdkVersion 22
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.android4dev.navigationview"
        minSdkVersion 19
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
//    compile 'com.android.support:appcompat-v7:22.2.0'
//    compile 'com.android.support:design:22.2.0'
    compile 'de.hdodenhof:circleimageview:1.3.0'

    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:cardview-v7:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'

}

3 个答案:

答案 0 :(得分:0)

您的构建工具和sdk版本不匹配。

将构建工具版本更改为:

buildToolsVersion '22.0.1'

答案 1 :(得分:0)

您的构建工具和库版本似乎很旧。当前版本为23.0.1 转到您的sdk管理和更新构建工具和支持库。

更新工具后,请更改Gradle文件以使用23.0.1的最新构建工具和支持库:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.android.xxx"
        minSdkVersion 19
        targetSdkVersion 23
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}


dependencies {
    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.android.support:appcompat-v7:23.0.1'

    compile 'com.android.support:cardview-v7:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'

    compile 'com.android.support:design:23.0.1'

    compile 'com.google.code.gson:gson:2.3'
}

答案 2 :(得分:0)

@Sharj

使用ouput进行构建

D:\Users\robi\StudioProjects\QuandoArrivo\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.0.1\res\values-v23\values-v23.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
Error:Execution failed for task ':app:processDebugResources'.