Cannot resolve symbol '?attr/actionBarSize'

2019-03-08 01:26发布

After updating Android Studio from 2.3 to 3.0 I changed buildToolsVersion from 26.0.0 to 26.0.2 and after then I am getting this error:

Cannot resolve symbol '?attr/actionBarSize

Xml code:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="@color/colorPrimary"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:titleTextColor="@android:color/white"/>

Dependencies:

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

14条回答
狗以群分
2楼-- · 2019-03-08 02:01

I tried all the answers here and so many others from lots of places but only the below techniques worked for me. The simple way is you just need to close the project then import the same project as a Gradle project Or you can go to Project structure -> project -> change Gradel plugin = 4.4 and Android plugin version = 3.1.4. Both of these above methods work.

Note: These versions(4.4, 3.1.4) are latest when I write this answer please use the latest version instead of these.

查看更多
Bombasti
3楼-- · 2019-03-08 02:01

Maybe you hava upgraded the version of gradle. when my gradle version is 4.4 and plugin version is 3.1.1.It is ok.

enter image description here

查看更多
登录 后发表回答