Reputation: 467
I am using ongakuer/CircleIndicator library to add viewpager indicators. I have used the sample code as it is except changing a small code from customViewpager.addOnPageChangeListener
to customViewpager.setOnPageChangeListener
because it was showing compile error. After that there was no compile error.
When I run the activity, I straightaway 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)
Upvotes: 16
Views: 28241
Reputation: 659
Faced a similar issue with RecyclerView.Adapter -
java.lang.NoSuchMethodError: No virtual method setAdapterCount ...
Invalidating caches and then restarting Android Studio resolved the error in my case. You can find directions to invalidate caches in IntelliJ (the software Android Studio is built upon) at this link.
Upvotes: 9
Reputation: 1954
I had the same issue and in my case the solution was as follows:
Upvotes: 4
Reputation: 26821
I had this error when I used a version of support-v4 library which wasn't 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 is by removing support-v4 library from my build altogether.
Upvotes: 0