Error in referencing Android Design package

Source: Internet
Author: User

Error in referencing Android Design package

When using Android Studio for development, when encountering obsolete and unrecommended methods and classes, I want to do something to remove the above line. Then, I was troubled by a problem that was not a problem for a long time.

Previously, when we created a fixed Tabs, this function was similar,

ActionBar. Tab is used, but ActionBar deprecated is used. So what is a new solution? TabLayout + ViewPager can implement the above functions

Error: android. view. InflateException: Binary XML file line #8: Error inflating class android. support. design

First, I made it clear that my sdk has been upgraded to version 21 or later. The support Library is also up-to-date.

Add dependency in Android studio

Build. gradle (Module. app)

 

dependencies {    compile fileTree(dir: 'libs', include: ['*.jar'])    compile 'com.android.support:appcompat-v7:22.2.0'    compile 'com.android.support:support-v4:22.2.0'    compile 'com.android.support:design:22.2.0'}
The content of activity_main.xml is as follows:

 

 

         
 

Error message:

 

 

Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class android.support.design.widget.TabLayout        at android.view.LayoutInflater.createView(LayoutInflater.java:633)        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)        at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)        at android.view.LayoutInflater.inflate(LayoutInflater.java:504)        at android.view.LayoutInflater.inflate(LayoutInflater.java:414)        at android.view.LayoutInflater.inflate(LayoutInflater.java:365)        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)        at android.app.Activity.setContentView(Activity.java:2144)        at com.example.hp.myapplication.MainActivity.onCreate(MainActivity.java:15)        at android.app.Activity.performCreate(Activity.java:5933)
The error shown above is that an Inflate error occurs in row 8th of the xml file, which causes the error in line 15 of MainActivity. java:

 

setContentView(R.layout.activity_main);
Error.

 

Solution:

In styles. xml of res/values, you need to modify the attribute value of parent. You cannot use custom attributes.

Two styles. xml must be modified.

For more information, see:

 

 
      
  
  
 
Modify the property value in the parent.
 
  
 

The result is successfully resolved.

 

Reference for similar issues: http://stackoverflow.com/questions/30547323/error-when-using-any-android-design-support-library-elements/30557995#30557995

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.