Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the ViewPager giving errors in Android Studio Design mode?

I'm using Android Studio 0.8.6 (beta). I'm trying to create a fragment using the "android.support.v4.view.ViewPager"

I get the following error when I'm in the design view of the fragment layout:

Rendering Problems 

The following classes could not be instantiated:
- android.support.v4.view.ViewPager (Open Class, Show Exception)

 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE  

Exception Details java.lang.ClassNotFoundException: android.support.v4.view.ViewConfigurationCompatFroyo   
at com.intellij.util.lang.UrlClassLoader.findClass(UrlClassLoader.java:148)   
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)   
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)   
at android.support.v4.view.ViewConfigurationCompat$FroyoViewConfigurationVersionImpl.getScaledPagingTouchSlop(ViewConfigurationCompat.java:49)   
at android.support.v4.view.ViewConfigurationCompat.getScaledPagingTouchSlop(ViewConfigurationCompat.java:73)   
at android.support.v4.view.ViewPager.initViewPager(ViewPager.java:367)   
at android.support.v4.view.ViewPager.<init>(ViewPager.java:355)   
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)   
at android.view.LayoutInflater.inflate(LayoutInflater.java:478)   
at android.view.LayoutInflater.inflate(LayoutInflater.java:381)

I'm pretty new the Android thing and Android Studio. I've been googling and have not found a solution that makes sense to me. How do I correct this?

Thanks, JohnB

like image 226
JohnB Avatar asked Oct 20 '14 03:10

JohnB


1 Answers

::> Xaver

After several hours of combing through Google, I was able to find the following which helped solve my issue:

Android: class not found exception: android.support.v4.app.FragmentPager

By adding the missing support library through File->Project Structure, the errors went away.

I CAN in fact view the preview without errors/exceptions.

JB

like image 131
JohnB Avatar answered Nov 15 '22 09:11

JohnB