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'
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.
Update all your library versions to 26.1.0
(to the most recent version) and also add:
compile 'com.android.support:support-v4:26.1.0'
if you are using Android Studio 3.0.0 and above then use
implementation 'com.android.support:support-v4:26.1.0'
Sync your project and the error will automatically resolve because ?attr/actionBarSize
is part of v4
library.
In the project directory hierarchy switch "Android" to "Project". Then delete a folder ".idea/libraries", only "libraries". Select an option from the menu "File -> Invalidate Caches / Restart... -> Invalidate and Restart".
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.
This is what I did to fix exactly the same problem. 1. Go to SDK manager. 2. Check Android API 27 and Android 8.0 (Oreo) 3. Click "Apply" to download and install those SDKs 4. In build.gradle, change the 'buildToolsVersion "26.0.1"' to 'buildToolsVersion "26.0.2"' and do a gradle sync.
Hope this can help fix your issue.
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.
my problem solved by changing compileSdkVersion
and targetSdkVersion
from 26
to the last version 27
, also u need to upgrade ur dependencies
to 27
.
android {
compileSdkVersion 27
defaultConfig {
applicationId "com......"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
}
hope this solve ur problem too :)
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'
}
This worked.
I have updated the compile and support lib versions from 26.x.x to 27.x.x.
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.
this work:
delete all file in $HOME/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar
Changed all Support Library versions to the newest 27.1.1
and the error was gone.
please replace android support libraries.
from
27.1.1
to
28.0.0-alpha3
and replace 27 to 28 for following cases:
compileSdkVersion 28
buildToolsVersion "28.0.0"
targetSdkVersion 28
this will fix the issue.
来源:https://stackoverflow.com/questions/47026492/cannot-resolve-symbol-attr-actionbarsize-after-updating-android-studio-from-2