Reputation: 117
im trying to create a ViewPager for my app. Im new to android developing so first im trying a sample to look how it works from this site. When i try to run it in the emulator it force closes. I dont know why i get the error, i checked the code lot of times and there is no difference.
So as the code is the same as in the link above i only provide the logcat.
01-30 04:07:40.059: E/AndroidRuntime(3013): FATAL EXCEPTION: main
01-30 04:07:40.059: E/AndroidRuntime(3013): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.testviewpager/com.testviewpager.TestViewPagerActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class com.viewpagerindicator.TitlePagePageIndicator
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.os.Handler.dispatchMessage(Handler.java:99)
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.os.Looper.loop(Looper.java:123)
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.app.ActivityThread.main(ActivityThread.java:3683)
01-30 04:07:40.059: E/AndroidRuntime(3013): at java.lang.reflect.Method.invokeNative(Native Method)
01-30 04:07:40.059: E/AndroidRuntime(3013): at java.lang.reflect.Method.invoke(Method.java:507)
01-30 04:07:40.059: E/AndroidRuntime(3013): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-30 04:07:40.059: E/AndroidRuntime(3013): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-30 04:07:40.059: E/AndroidRuntime(3013): at dalvik.system.NativeStart.main(Native Method)
01-30 04:07:40.059: E/AndroidRuntime(3013): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class com.viewpagerindicator.TitlePagePageIndicator
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-30 04:07:40.059: E/AndroidRuntime(3013): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.app.Activity.setContentView(Activity.java:1657)
01-30 04:07:40.059: E/AndroidRuntime(3013): at com.testviewpager.TestViewPagerActivity.onCreate(TestViewPagerActivity.java:14)
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-30 04:07:40.059: E/AndroidRuntime(3013): ... 11 more
01-30 04:07:40.059: E/AndroidRuntime(3013): Caused by: java.lang.ClassNotFoundException: com.viewpagerindicator.TitlePagePageIndicator in loader dalvik.system.PathClassLoader[/data/app/com.testviewpager-1.apk]
01-30 04:07:40.059: E/AndroidRuntime(3013): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
01-30 04:07:40.059: E/AndroidRuntime(3013): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
01-30 04:07:40.059: E/AndroidRuntime(3013): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.view.LayoutInflater.createView(LayoutInflater.java:471)
01-30 04:07:40.059: E/AndroidRuntime(3013): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
01-30 04:07:40.059: E/AndroidRuntime(3013): ... 20 more
The com.viewpagerindicator is a libary project (on the link its com.jakewharton.android.viewpagerindicator, i know that, i just changed it to the original), there i changed nothing, only imported from the authors site. So if anyone know what i did wrong please help. I can provide more information if this is not enough.
Upvotes: 1
Views: 3336
Reputation: 625
I have the same problem but i figured out that the solution very simple if you are following this link like me you have to delete this part [jakewharton.android] from your main layout refering to link main layout this what causing inflateException and make it just like what your viewPagerIndicator library package name
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
Upvotes: 2
Reputation: 8531
I don't believe that you are either importing or linking the library correctly.
Here is a post that shows an easy example of how to import a similar type lib and link it up.
using-the-johannilsson-android-actionbar-library
I have made a view pager myself, but did not end up using this library. Instead I used the android support package. It works much better for me because I do not have to import the entire package, I just have to link the lib.
Upvotes: 0