attribute insetForeground has already be defined

2019-03-23 10:19发布

after updating to the new

com.android.support:design:22.2.0

I got this error:

"attribute insetForeground has already be defined"

keep in mind that i'm using @romannurik ScrimInsetsFrameLayout.java

4条回答
Rolldiameter
2楼-- · 2019-03-23 10:41

You have this class ScrimInsetsFrameLayout.java in your files whereas Google already put this in the Google Android Support Design Library. Replace the ScrimInsetsFrameLayout into android.support.design.widget.NavigationView

查看更多
放荡不羁爱自由
3楼-- · 2019-03-23 10:45

just change

insetForeground attribute

in your attrs.xml to a different name

查看更多
再贱就再见
4楼-- · 2019-03-23 10:51

Or else you can rename insetForeground in your values/attr.xml to insetForeground2 or something

查看更多
Animai°情兽
5楼-- · 2019-03-23 10:58

To elaborate on Omar's answer,

The Android design support library introduced NavigationDrawer that is used together with DrawerLayout to provide means of implementing navigation etc. See here:

Android Design Support Library

The NavigationDrawer extends ScrimInsetsFrameLayout which was brought into the library.

The error in the question occurs because the insetForeground attribute was defined twice. Once is the context of the library and once when a copy of ScrimInsetsFrameLayout was brought into the project.

Options:

  1. Rename the property defined in the project (as suggested by Omar) while continuing using the local copy of ScrimInsetsFrameLayout.
  2. Remove the local copy of ScrimInsetsFrameLayout and use the one in the library instead.
  3. Remove the local copy of ScrimInsetsFrameLayout and use NavigationDrawer instead.
查看更多
登录 后发表回答