Tablayout with viewpager and FragmentPagerAdapter crashes on vertical scroll after build tools and sdk update

110 views Asked by At

I have a legacy application which had following build configurations

targetSdkVersion 23 compileSdkVersion 23 buildToolsVersion 23.0.2 SupportLibVersion 23.4.0 gradle 2.2.0

and I updated them to

gradle version 3.1.4 targetSdkVersion 27 compileSdkVersion 27 buildToolsVersion 27.0.3 SupportLibVersion 27.1.1 Constrain layout 1.0.2

Now when I run the app in emulator or mobile, the app which has home screen as Tablayout viewpager with a number of fragments loading as a list in each page (FragmentPagerAdapter) crashes when I vertically scroll any of the tab items.The actual error I am getting after this upgrade is "No view found for ID of .. fragment". I didn't make any code changes at all, only updated configurations.

I tried to debug this but it seems to be a support library issue. I have verified that I am using same support library version for all different dependencies like appcompat, design, recyclerview, annotation etc. Please suggest a solution.

Note: I tried to downgrade the support library versions and debug, if I change to 23.4.0 the crash doesn't happen, from 25.2.0 onwards it crashes.

 Activity state:
  09-23 14:14:30.214 11596-11596/com.*** E/AndroidRuntime: 
  FATAL EXCEPTION: main
  Process: com.****, PID: 11596
  java.lang.IllegalArgumentException: No view found for id 0x7 (unknown) for fragment ****Fragment{a92e376 #2 id=0x7}
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1293)
    at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
    at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:757)
    at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2355)
    at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2146)
    at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2098)
    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2008)
    at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:710)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
0

There are 0 answers