0

I'm trying to implement swiping on a group of fragment in my app and am basically trying to follow the code on Android's http://developer.android.com/reference/android/support/v13/app/FragmentPagerAdapter.html page.

However, I'm getting the following error:

02-14 19:16:34.138: I/LoginFragment(10309): setting shared preferences...
02-14 19:16:34.197: I/art(10309): Rejecting re-init on previously-failed class java.lang.Class<com.grooble.moeigo.ProfileActivity$AppSectionsPagerAdapter>
02-14 19:16:34.197: I/art(10309): Rejecting re-init on previously-failed class java.lang.Class<com.grooble.moeigo.ProfileActivity$AppSectionsPagerAdapter>
02-14 19:16:34.198: I/art(10309): Rejecting re-init on previously-failed class java.lang.Class<com.grooble.moeigo.ProfileActivity$AppSectionsPagerAdapter>
02-14 19:16:34.233: I/art(10309): Rejecting re-init on previously-failed class java.lang.Class<com.grooble.moeigo.ProfileActivity$AppSectionsPagerAdapter>
02-14 19:16:34.235: D/AndroidRuntime(10309): Shutting down VM
02-14 19:16:34.239: E/AndroidRuntime(10309): FATAL EXCEPTION: main
02-14 19:16:34.239: E/AndroidRuntime(10309): Process: com.grooble.moeigo, PID: 10309
02-14 19:16:34.239: E/AndroidRuntime(10309): java.lang.NoClassDefFoundError: com.grooble.moeigo.ProfileActivity$AppSectionsPagerAdapter
02-14 19:16:34.239: E/AndroidRuntime(10309):    at com.grooble.moeigo.ProfileActivity.onCreate(ProfileActivity.java:53)
02-14 19:16:34.239: E/AndroidRuntime(10309):    at android.app.Activity.performCreate(Activity.java:5933)
02-14 19:16:34.239: E/AndroidRuntime(10309):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
02-14 19:16:34.239: E/AndroidRuntime(10309):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
02-14 19:16:34.239: E/AndroidRuntime(10309):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
02-14 19:16:34.239: E/AndroidRuntime(10309):    at android.app.ActivityThread.access$800(ActivityThread.java:144)
02-14 19:16:34.239: E/AndroidRuntime(10309):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
02-14 19:16:34.239: E/AndroidRuntime(10309):    at android.os.Handler.dispatchMessage(Handler.java:102)
02-14 19:16:34.239: E/AndroidRuntime(10309):    at android.os.Looper.loop(Looper.java:135)
02-14 19:16:34.239: E/AndroidRuntime(10309):    at android.app.ActivityThread.main(ActivityThread.java:5221)
02-14 19:16:34.239: E/AndroidRuntime(10309):    at java.lang.reflect.Method.invoke(Native Method)
02-14 19:16:34.239: E/AndroidRuntime(10309):    at java.lang.reflect.Method.invoke(Method.java:372)
02-14 19:16:34.239: E/AndroidRuntime(10309):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
02-14 19:16:34.239: E/AndroidRuntime(10309):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

I have the class defined:

public class ProfileActivity extends Activity implements ActionBar.TabListener {

    AppSectionsPagerAdapter appSectionsAdapter;

    ViewPager viewPager;

    // other private variables

    @Override
    protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
        setContentView(R.layout.profile_activity);

    public static class AppSectionsPagerAdapter extends FragmentPagerAdapter {

        public AppSectionsPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int i) {
            switch (i) {
                case 0:
                    return new FriendsFragment();

                default:
                    return new UserFragment();
            }
        }

        @Override
        public int getCount() {
            return 2;
        }

    }

but I suspect the problem may be something to do with mixing up the native and support libraries(?) Here are the relevant imports:

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.support.v13.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

Is it ok to mix up native, v4 and v13 like this? Any suggestions welcome.

@No Name: I believe I have. Here's a screenshot of the build path:

build path

This is the profile_activity.xml that contains the ViewPager:

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

</android.support.v4.view.ViewPager>

and I also put in a bit more of the ProfileActivity code that might be relevant.

grooble
  • 617
  • 1
  • 8
  • 27

0 Answers0