2016-11-08 7 views
0

エラー膨らまクラスandroid.support.design.widget.FloatingActionButton - 私はこのエラーを得た私の活動を実行したいアンドロイド

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/white"> 

    <ListView 
     android:id="@+id/listview_diary" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:clipToPadding="false" 
     android:divider="@null" 
     android:dividerHeight="16dp" 
     android:fadingEdge="none" 
     android:fitsSystemWindows="true" 
     android:padding="12dp" 
     android:scrollbars="none" 
     android:background="@android:color/white"/> 

    <android.support.design.widget.FloatingActionButton 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/fab_add_diary" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:layout_margin="16dp" 
     android:clickable="true" 
     android:padding="8dp" 
     android:src="@mipmap/ic_add" 
     app:backgroundTint="@color/colorPrimary" 
     app:borderWidth="0dp"/> 

</RelativeLayout> 

私のクラスが拡張:私のXMLコードが

android.view.InflateException: Binary XML file line #21: Error inflating class android.support.design.widget.FloatingActionButton 
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2693) 
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758) 
                      at android.app.ActivityThread.access$900(ActivityThread.java:177) 
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448) 
                      at android.os.Handler.dispatchMessage(Handler.java:102) 
                      at android.os.Looper.loop(Looper.java:145) 
                      at android.app.ActivityThread.main(ActivityThread.java:5942) 
                      at java.lang.reflect.Method.invoke(Native Method) 
                      at java.lang.reflect.Method.invoke(Method.java:372) 
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1389) 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1184) 
                     Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class android.support.design.widget.FloatingActionButton 

AppCompatActivityクラス。

私のスタイル:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 

私のGradle:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 24 
    buildToolsVersion "25.0.0" 

    defaultConfig { 
     applicationId "***.***.***" 
     minSdkVersion 16 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 
     jackOptions { 
      enabled true 
     } 
     // Enabling multidex support. 
     multiDexEnabled true 
    } 
    buildTypes { 
     release { 
      debuggable false 
      minifyEnabled false 
      shrinkResources false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_8 
     targetCompatibility JavaVersion.VERSION_1_8 
    } 
    dexOptions { 
     javaMaxHeapSize "2g" 
     incremental true 
     preDexLibraries = false 
    } 
} 
repositories { 
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } 
    maven { url 'https://raw.github.com/felipecsl/m2repository/master' } 
    // maven { url "https://jitpack.io" } 
    mavenCentral() 

} 
dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile('com.github.florent37:materialviewpager:[email protected]') { 
     transitive = true 
    } 
    compile 'com.android.support:appcompat-v7:24.2.1' 
    compile 'com.android.support:recyclerview-v7:24.0.0' 
    compile 'com.android.support:design:24.0.0' 
    compile 'com.android.support:multidex:1.0.1' 
    compile 'com.android.support:cardview-v7:24.0.0' 
    compile 'com.android.support:support-v4:24.0.0' 
    ... 
+0

uが使用されている1つのアクティビティまたはAppCompatActivityこれを変更します? –

+0

"私のクラスは' AppCompatActivity'クラスを拡張しました。 " –

+0

'xmlns:app =" http://schemas.android.com/apk/res-auto "を' RelativeLayout'に移動させよう –

答えて

0

はRelativeLayout

1

にFloatingActionButtonから xmlns:app="http://schemas.android.com/apk/res-auto" を移動しようが、この
1試してみてください。最新のバージョンをインストールするsdk managerを使用して、デザインサポートライブラリとappCompatライブラリをアップデートします。
2. Appcompatテーマを使用します。
3.アクティビティの代わりにAppCompatActivityからアクティビティを拡張します。
4.これらすべてのクリーンプロジェクトと実行した後

compile 'com.android.support:appcompat-v7:24.2.0' 
compile 'com.android.support:design:24.2.0' 

5.同じ両方のライブラリのバージョンを維持しようとします。

0

フローティングボタンのXMLレイアウトから

xmlns:app="http://schemas.android.com/apk/res-auto" 

変更またはこのコードの下、必要な依存関係を追加し、それを再構築し、実行

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 24 
    buildToolsVersion "24.0.3" 
    defaultConfig { 
     applicationId "com.java.user.sample" 
     minSdkVersion 15 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled true 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

ファイルのGradleにコードを修正し、次の行を削除します プロジェクト

+0

これらの変更はなぜ機能しますか? – kilokahn

0

これは私のために最終的に働く。この中へ

compile 'com.android.support:appcompat-v7:23.4.0'  
compile 'com.android.support:design:23.0.0' 

compile 'com.android.support:appcompat-v7:25.0.0' 
compile 'com.android.support:design:25.0.0' 
0

が同じバージョンでAndroidアプリのcompatとAndroidスタジオ・デザインは私のための作品であることを確認してください。..

関連する問題