User1291
User1291

Reputation: 8181

Cannot resolve ``?attr/actionBarSize``

example layout:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    >
    <include layout="@layout/toolbar"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="?attr/actionBarSize"
        android:padding="@dimen/spacing_xlarge"
        >

    </LinearLayout>

</FrameLayout>

With the gradle build files below, Android Studio (3.1.3) marks the ?attr/actionBarSize red, claiming it

cannot resolve symbol ?attr/actionBarSize

Invalidating the caches and restarting android studio has no effect,

neither has adding

implementation "com.android.support:support-v4:$support_version"

to the module gradle build file.

How do I get android studio to recognise the setting?

I could add the android: namespace to it, as suggested by

Cannot resolve symbol '?attr/actionBarSize' after updating Android Studio from 2.3 to 3.0 for buildToolsVersion '26.0.2'

but the way I understand it, that would look up a different property.

build.gradle(Project)

buildscript {
    ext.kotlin_version = '1.2.50'
    ext.anko_version = '0.10.5'
    ext.support_version = '27.1.1'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle (Module)

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId "foo.bar.App"
        minSdkVersion 19
        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:$support_version"
    implementation "com.android.support:recyclerview-v7:$support_version"
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "org.jetbrains.anko:anko-common:$anko_version"
    implementation "org.jetbrains.anko:anko-sqlite:$anko_version"

    implementation "com.google.code.gson:gson:2.8.1"
    implementation "com.squareup.picasso:picasso:2.5.2"
}

Upvotes: 1

Views: 2294

Answers (2)

Lam Nguyen
Lam Nguyen

Reputation: 585

change to

?android:attr/actionBarSize

or

implementation 'androidx.legacy:legacy-support-v4:1.0.0'

Upvotes: 1

Pratik Mhatre
Pratik Mhatre

Reputation: 779

try ?android:attr/actionBarSize

Upvotes: 4

Related Questions