Georgi Koemdzhiev
Georgi Koemdzhiev

Reputation: 11931

getAdapterPosition() is not found as a method

I recently uprated to Android Studio 2.3 and not the getAdapterPosition (RecyclerView) cannot be found. I saw on the web that the reason for that is the support library version. But I am not sure how to solve it still. My support:appcompat-v7:25.2.0' version is the latest possible (e.g. above 21). I don't understand why the method is not found. Any advice, please?

compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/wekaSTRIPPED.jar')
compile('com.mikepenz:materialdrawer:5.8.1@aar') { // Material Drawer
    transitive = true
}
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'com.google.dagger:dagger:2.9'
compile 'com.github.wendykierp:JTransforms:3.1'
compile 'com.afollestad.material-dialogs:commons:0.9.3.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.github.paolorotolo:appintro:4.1.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.borax12.materialdaterangepicker:library:1.9'
compile 'com.evernote:android-job:1.1.7' // Scheduling library
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
annotationProcessor 'com.google.dagger:dagger-compiler:2.9'

Upvotes: 1

Views: 4288

Answers (4)

Mushahid Khatri
Mushahid Khatri

Reputation: 728

Can you please check you are using this method in ViewHolder Class?

getAdapterPostion() is the method of RecyclerView.ViewHolder.

You need to make sure you are using this method inside the class extending RecyclerView.ViewHolder

Upvotes: 8

squalle0nhart
squalle0nhart

Reputation: 351

compile 'com.android.support:recyclerview-v7:25.2.0' 

may be missing that line ???

Upvotes: 2

MarcGV
MarcGV

Reputation: 1262

Probably you have to use buildToolsVersion 25.2.0 too, and in my case the gradle showed me and error:

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.2.0, 25.0.0. Examples include com.android.support:animated-vector-drawable:25.2.0 and com.android.support:customtabs:25.0.0

To solve this I have had to add this line compile 'com.android.support:customtabs:25.2.0' forcing to use this version for customtabs.

Before:

//    android support
    compile 'com.android.support:recyclerview-v7:25.2.0'
    compile 'com.android.support:cardview-v7:25.2.0'
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support:design:25.2.0'

After:

//    android support
    compile 'com.android.support:recyclerview-v7:25.2.0'
    compile 'com.android.support:customtabs:25.2.0'
    compile 'com.android.support:cardview-v7:25.2.0'
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support:design:25.2.0'

If you have an error like this, I recommend you to add the library that shows the error with the version you want.

Upvotes: 1

Sandeep Kharat
Sandeep Kharat

Reputation: 570

Please add this dependency: compile 'com.android.support:recyclerview-v7:23.3.0'

Upvotes: 1

Related Questions