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


如果ActivityMain类正在扩展FragmentActivity ,则将定义getSupportFragmentManager() 。


According to docs, FragmentPagerAdapter is also present in support lib v4 (see docs). So if this is the only reason you use v13 - you can easily get rid of it.

链接地址: http://www.djcxy.com/p/19008.html

上一篇: push()相反;

下一篇: 我如何在同一个项目中使用android支持库v4和v13?