App crash due to ClassCastException: android.support.v4.view.ViewPager cannot be cast to android.support.v4.view.ViewPager
<pre><code>`import android.support.v4.view.ViewPager; 
 public class Home extends Activity {
 private ViewPager mainViewPager;
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.home); 
        mainViewPager = (ViewPager) findViewById(R.id.home_vp_pager); //the log will redirect me from DDMS to this line.
} 
}
`
</code></pre>

<p>My application experience a crash while updating my app through OTA. This is my error log</p>

<blockquote>
  <p>Caused by: java.lang.ClassCastException: android.support.v4.view.ViewPager cannot be cast to android.support.v4.view.ViewPager<br>
  12-26 16:47:43.067: E/AndroidRuntime(3821):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2572)
  12-26 16:47:43.067: E/AndroidRuntime(3821):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
  12-26 16:47:43.067: E/AndroidRuntime(3821):     at android.app.ActivityThread.-wrap11(ActivityThread.java)
  12-26 16:47:43.067: E/AndroidRuntime(3821):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
  12-26 16:47:43.067: E/AndroidRuntime(3821):     at android.os.Handler.dispatchMessage(Handler.java:111)
  12-26 16:47:43.067: E/AndroidRuntime(3821):     at android.os.Looper.loop(Looper.java:207)
  12-26 16:47:43.067: E/AndroidRuntime(3821):     at android.app.ActivityThread.main(ActivityThread.java:5728)
  12-26 16:47:43.067: E/AndroidRuntime(3821):     at java.lang.reflect.Method.invoke(Native Method)
  12-26 16:47:43.067: E/AndroidRuntime(3821):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
  12-26 16:47:43.067: E/AndroidRuntime(3821):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
  12-26 16:47:43.067: E/AndroidRuntime(3821): Caused by: java.lang.ClassCastException: android.support.v4.view.ViewPager cannot be cast to android.support.v4.view.ViewPager
  12-26 16:47:43.067: E/AndroidRuntime(3821):     at com.android.home.Home.onCreate(Home.java:445)
  12-26 16:47:43.067: E/AndroidRuntime(3821):     at android.app.Activity.performCreate(Activity.java:6309)
  12-26 16:47:43.067: E/AndroidRuntime(3821):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
  12-26 16:47:43.067: E/AndroidRuntime(3821):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
  12-26 16:47:43.067: E/AndroidRuntime(3821):     ... 9 more</p>
</blockquote>

<p>I am using the </p>

<p><em>android-support-v4.jar</em></p>

<p>Even my app shows this error repeatedly </p>

<p>NEW UPDATE : </p>

<p>I am using the </p>

<pre><code>'compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultconfig{
 ......
 minSdkVersion 19
    targetSdkVersion 21
 ....
 }
 .................
  dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')

    implementation 'com.android.support:support-v4:27.1.1'
   }'
</code></pre>