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

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

嗨,我创建示例项目,但崩溃。

我运行带有kitkat的设备,但我的应用崩溃了,只显示了以下消息:
异常错误为什么?我使用android studio lastversione

我的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'
}

我的测试 Activity 是从Android Studio创建的空白 Activity

我的测试 Activity
<?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'

}

最佳答案

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

将构建工具版本更改为:

buildToolsVersion '22.0.1'

关于android - 使用一次<android.support.design.widget时我的应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33112259/

相关文章:

iOS崩溃报告 "unexpected start state"异常?

android - 当用户登录凭据存储在浏览器中时,Android 上的 Twitter OAuth 回调出现问题

java - Android 模拟器中从右到左的字符反转

android - 有没有办法在 android studio 中找到所有的 Log.d() 行

Android Studio 使用更多内存,因为我一直在使用它

java - 不幸的是,Myapp在输入登录详细信息后已停止

ios - 我不理解 Swift 中的 nil

android - react native 回调

Android:接近警报和电池消耗

android - 同一个 Flutter 应用中的多个 Kotlin 运行时