NoSuchMethodError: no virtual removeOnPageChangeListener method

I use ongakuer / CircleIndicator to add viewpager indicators. I used a sample code because it changed a little code from customViewpager.addOnPageChangeListener to customViewpager.setOnPageChangeListener because it showed a compilation error. After that there was no compilation error.

When I run the action, I immediately get the following error:

 java.lang.NoSuchMethodError: No virtual method removeOnPageChangeListener(Landroid/support/v4/view/ViewPager$OnPageChangeListener;)V in class Landroid/support/v4/view/ViewPager; or its super classes (declaration of 'android.support.v4.view.ViewPager' appears in /data/app/com.app.app-2/base.apk) at me.relex.circleindicator.CircleIndicator.setViewPager(CircleIndicator.java:127) at com.app.app.ViewpagerActivity.onCreate(ViewpagerActivity.java:24) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
+8
android
source share
3 answers

Faced a similar problem with RecyclerView.Adapter -

 java.lang.NoSuchMethodError: No virtual method setAdapterCount ... 

Refusing caching and then restarting Android Studio resolved the error in my case. You can find caching invalidations in IntelliJ (based on Android Studio software) at this link .

+5
source share

I had the same problem and in my case the solution was as follows:

Decision:

  • Go to the SDK Manager .
  • Go to the SDK Tools tab.
  • Make sure you have installed the latest version of Android Support Library, rev 22 .
  • Now try to run the application again.

Explanation:

  • removeOnPageChangeListener was added only in editor 22 of the v4 support library.
  • For some reason, Android Studio will not tell you that you do not have the full version downloaded and installed.
+2
source share

I had this error when I used the version of support-v4 library that was not compatible with my other support libraries:

 compile ('com.android.support:support-v4:22.1.1') { // Force stable version of support-v4 force = true } 

Unfortunately, the only solution I found was to remove the support-v4 library from my build in general.

-one
source share

All Articles