I've got a project written for API 11 and up, no I need it available for 2.3.3 OS devices either, so need to use Support Library. What is the easiest way to go with it? I know some methods have different names for Fragments
, for instance. Can it be possible to use "Find and Replace All"?

- 59,186
- 91
- 226
- 333
-
Why not possible, is that menu item disabled? – Alexander Kulyakhtin Jul 10 '12 at 19:53
-
I mean, is that menu item (Find and Replace All) disabled so you can not use it anymore? – Alexander Kulyakhtin Jul 10 '12 at 19:55
2 Answers
For the most part, yes it will be possible. You'll also have to change less than you think, for example the Fragment
class is fine.
You will have to change getFragmentManager
to getSupportFragmentManager
, as well as changing your base Activity
to a FragmentActivity
. Those are the most common two off the top of my head.
The easiest way is to change the target to 2.2, add the support-package as a library, and see what breaks and then fix it-- and once you have a replacement fix you can use find and replace all to fix all instances of the issue.

- 6,263
- 2
- 24
- 34
-
-
yeah, that wasn't back-ported. Check this out: http://stackoverflow.com/questions/5501431/was-preferencefragment-intentionally-excluded-from-the-compatibility-package – edthethird Jul 10 '12 at 19:58
-
You don't need to change the project build to debug your app... this is what `Android lint` is for... – Alex Lockwood Jul 10 '12 at 20:00
-
edited, thank you-- as I mentioned those class changes are off the top of my head, the OP will have to do some investigation himself – edthethird Jul 10 '12 at 20:05
Can it be possible to use "Find and Replace All"?
As far as I'm concerned, it's never a good idea to do a simple "Find and Replace All"... it's far too easy to make a mistake.
What is the easiest way to make the transition?
The change is very simple and should not require you to change your build target at all (assuming you are targeting Android 1.6 or above, of course). The key changes you must make are:
For each
Activity
that makes use of the support libraries, have it extendFragmentActivity
instead.In each
FragmentActivity
, replace all calls togetLoaderManager()
withgetSupportLoaderManager()
.In each
FragmentActivity
, replace all calls togetFragmentManager()
togetSupportFragmentManager()
.Replace all relevant
android.*
imports with their correspondingsupport.v4.*
import statements.

- 83,063
- 39
- 206
- 250