Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use android support libraries v4 and v13 in the same project?

I'm trying to use both v4 and v13 support libraries and the ADT is giving me the error:

Found both android-support-v4 and android-support-v13 in the dependency list.
Because v13 includes v4, using only v13.

I need to use both because I have to use:

import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;

import android.support.v13.app.FragmentPagerAdapter;

I've tried to add the libraries as an external jar but then I'm getting NoClassDefFoundError

Can I use both libraries or can I replace some of those imports?

Thanks in advance

EDIT:

Hello, thanks for the fast answers

I've tried before to use the android.support.v4.app.FragmentPagerAdapter but then I got another problem.

I have a main activity which implements a Navigation Drawer and uses a FrameLayout to load the Fragments. This activity has a method that displays the fragments. The method has the next code:

if (fragment != null) {
    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit();

If I use android.support.v4.app.FragmentPagerAdapter I need to use also

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;

And I got the next error when using getFragmentManager();

Type mismatch: cannot convert from android.app.FragmentManager to  android.support.v4.app.FragmentManager

I've read I can use getSupportFragmentManager() but I get another error:

The method getSupportFragmentManager() is undefined for the type ActivityMain

That's the reason I want to use both, v4 and v13 libraries

SOLVED:

The solution was make ActivityMain extends from FragmentActivity and use only v4 support library

like image 422
CarlosA Avatar asked Feb 08 '14 16:02

CarlosA


1 Answers

If ActivityMain class is extending FragmentActivity, then getSupportFragmentManager() will be defined.

like image 188
VJ Vélan Solutions Avatar answered Sep 28 '22 05:09

VJ Vélan Solutions