Error inflating class Android support design

前端 未结 5 1844
囚心锁ツ
囚心锁ツ 2021-02-19 08:03

What I am trying to do is use the new android support design library mentioned here: http://android-developers.blogspot.com/2015/05/android-design-support-library.html.

相关标签:
5条回答
  • 2021-02-19 08:43

    This error can be caused due to reasons as mentioned below.

    1. This problem will likely occur when the version of your appcompat library and design support library doesn't match.

    Example of matching condition

      compile 'com.android.support:appcompat-v7:24.2.0' // appcompat library
    
      compile 'com.android.support:design:24.2.0' //design support library
    
    1. Your theme file in styles should not have

      <item name="colorPrimary">#4A0958</item>
      <item name="colorPrimaryDark">#4A0958</item>
      

      It should look somewhat like this.

      <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
      
       <item name="colorPrimary">#4A0958</item>
       <item name="colorPrimaryDark">#4A0958</item>
       <item name="colorAccent">#4A0958</item>
      
      </style>
      
    0 讨论(0)
  • 2021-02-19 08:48

    I had the same issue. I resolved it build cleaning and rebuilding the project. When I ran it again, it had no such exceptions thrown.

    0 讨论(0)
  • 2021-02-19 08:51

    If you are using any of the Design Library components, you should ensure your activity extends AppCompatActivity and uses an appropriate Theme.AppCompat theme. Note that the FloatingActionButton relies on the colorAccent set on your theme - ensure your theme has that defined.

    0 讨论(0)
  • 2021-02-19 08:52

    If everything else doesn't work, Upgrade the version of the dependency and version. In your build.gradle file:

    compileSdkVersion 24
    
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.android.support:recyclerview-v7:24.2.0'
    compile 'com.android.support:cardview-v7:24.2.0'
    
    0 讨论(0)
  • 2021-02-19 08:52

    I had the same error. After more Search i have got solution. Just Change build.gradle (Module: app)

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 24 // previous 23
    
        buildToolsVersion "24.0.2"
    
        defaultConfig {
            applicationId "com.ventrux.thevideoapp"
            minSdkVersion 15
            targetSdkVersion 24  // previous 23
            versionCode 1
            versionName "1.0"
            multiDexEnabled true
    
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
        compile 'com.android.support:appcompat-v7:24.2.1'       // previous 23.2.1
        compile 'com.android.support:design:24.2.1'          // previous 23.2.1
    
        compile files('libs/YouTubeAndroidPlayerApi.jar')
    }
    

    Xml for FloatingActionButton

      <android.support.design.widget.FloatingActionButton
                android:id="@+id/fab"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|end"
                android:src="@drawable/plus_iconaddvideo"
                android:layout_marginRight="30dp"
                android:layout_marginBottom="30dp"
                android:layout_alignParentBottom="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"
                android:layout_marginEnd="30dp"
                />
    
    0 讨论(0)
提交回复
热议问题