mol
mol

Reputation: 2677

Cannot resolve method setExpandedTitleGravity(int)

I want to use setExpandedTitleGravity() method from CollapsingToolbarLayout. I just migrated from eclipse to android studio. In eclipse it worked fine, but in android studio compiler gives me the error cannot resolve method setExpandedTitleGravity(int).

Apparentely I'm using another version of the design library now, but it seems like it is the last one. My gradle dependance is: compile 'com.android.support:design:22.2.0'. Anyone knows why it happens?

Complete build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0 rc3"

    defaultConfig {
        applicationId "com.example.myapp"
        minSdkVersion 15
        targetSdkVersion 22
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:design:22.2.0'
}

Upvotes: 0

Views: 333

Answers (2)

IntelliJ Amiya
IntelliJ Amiya

Reputation: 75788

cannot resolve method setExpandedTitleGravity(int)

Your build.gradle should be for buildToolsVersion "23.0.0 rc3"

 dependencies {
    compile 'com.android.support:design:23.0.1'
              }

Note : For your information buildToolsVersion "23.0.0 rc3" (Version rc3) is not stable .Probably Beta Version (Avoid Beta-Canary Version for perfect Result ) . It will be better way if you use stable version like buildToolsVersion "23.0.0" or its upper version .

Upvotes: 1

Mattia Maestrini
Mattia Maestrini

Reputation: 32790

You receive cannot resolve method setExpandedTitleGravity(int) because setExpandedTitleGravity (int gravity) is added in Design Support Library v23.0.0

You need to update your build.gradle:

dependencies {
    compile 'com.android.support:design:23.0.1'
}

To use support libraries v23 you also need to change compileSdkVersion to 23

Upvotes: 1

Related Questions