No resource identifier found for attribute 'showAsAction' in package 'android'

前端 未结 7 1925
花落未央
花落未央 2021-02-13 19:30

as the title suggest, I\'m getting that error in at least 3 of the XML layout files, however, I dont see the attritube \"showsAsAction\" in any of those XML files, did I miss so

7条回答
  •  忘掉有多难
    2021-02-13 19:53

    I had this problem when I forgot to add appcompat-v7:+ to my project dependencies. You can do it like this in build.gradle:

    dependencies {
      compile 'com.android.support:appcompat-v7:+'
    }
    

    And this is because I had the following in my menu.xml:

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

    and

    app:showAsAction="never"
    

    When I removed the xmlns:app namespace and just used android:showAsAction="never", I didn't need the appcompat-v7 library anymore.

提交回复
热议问题