문제

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

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top