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 01:38

Nothing helped, but changing:

?attr/actionBarSize to ?android:attr/actionBarSize did the job.

That's actually a bug in few versions. Even if you won't fix it, Android will automatically fix it at runtime.

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

Try to add this in your build.gradle(app) dependencies:

resolutionStrategy {
    force libraries.support.appCompat
    force libraries.support.design
    force 'com.android.support:support-utils:26.0.1'
    force 'com.android.support:support-compat:26.0.1'
}
查看更多
乱世女痞
4楼-- · 2019-03-08 01:39

this work:

delete all file in $HOME/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar

查看更多
迷人小祖宗
5楼-- · 2019-03-08 01:44

Changed all Support Library versions to the newest 27.1.1 and the error was gone.

查看更多
ら.Afraid
6楼-- · 2019-03-08 01:45

Good day, I know this is a bit late.

but I have encountered this one too, when I updated to Android Studio 3.0

what i did is I changed

compile 'com.android.support:support-v4:26.1.0'

to

implementation 'com.android.support:support-v4:26.1.0'

Hope it can help somebody.

查看更多
干净又极端
7楼-- · 2019-03-08 01:46

Your buildToolsVersion version differs from version in dependencies (e.g. buildToolsVersion is 27.0.0 but implementation 'com.android.support:support-v4:27.0.1'). Make them the same.

查看更多
登录 后发表回答