0

I have a android app that I'm building in android 2.1. But the time has come to switch to a bigger build. What is the best way to support 2 or more android build versions. I had some suggestions like:

  1. Using git branches for the 2 builds
  2. Making the native, first 2.1 app a library project and creating two separate project that will use the library's common classes but rewrite all of the controllers
  3. Use the library project, two separate project for the different build and whan I have to use a class from the specific build I will have to call something like this from the library project:

    Class<ExpandableListAdapter> adapterClass = Config.getHotelDistrictAdapterClass();
            hotelAdapter = adapterClass.getConstructor(String.class).newInstance(HotelDistrictListActivity.this,
    

    0, hotelList.size(), hotelList, cretedFromAssets);

    where the Config class will counsult a config file that is contained in the build versions and contains the class name for the specific build.

    So the scenario will go somothin like this: the lib project will call on the Config class then the config class will call on a config file in the current build(4.2 or 2.1), the config file will return the class name and the Config class will return the class to the lib Project and the Lib Project will instanciate the class with the code :

    hotelAdapter = adapterClass.getConstructor(String.class).newInstance(HotelDistrictListActivity.this, 0, hotelList.size(), hotelList,cretedFromAssets);

Please suggest what is the better or best way to maintain two separate builds for two android versions, or suggest the way that you use to maintain two ore more android builds. Thanks

user1796624
  • 3,665
  • 7
  • 38
  • 65

2 Answers2

1

You should have a look at AndroidManifest.xml minSDKVersion and targetSDKVersion fields. They allow you to support a range of android versions in the same app.

Android Min SDK Version vs. Target SDK Version

Community
  • 1
  • 1
Snicolas
  • 37,840
  • 15
  • 114
  • 173
  • Thanks for your quick reply, I think I understand the concept of min sdk and target sdk. But do you suggest to use just one project and build it with different targetsdk's? If so there is still the question of how to support and manage different classes, components, xml's and different solutions of the same problem for bought 2.1 and 4.x – user1796624 Nov 18 '12 at 10:50
0

You can Easily set your MinSDKVersion to 8 or 7 for and set your Building Target to 16 or 17 this can be done from your Manifest.xml file

Mahdi Giveie
  • 630
  • 1
  • 8
  • 25
  • But do I use just one project or two projects, and what happens if I want the design to be different in 2.1 and in 4.0? For example I want to start to use the action bar in 4.x. How do I maintain the code that i different for the two builds? – user1796624 Nov 18 '12 at 10:53
  • you can use Build.VERSION.SDK_INT , and use a if conditinon to decide what to do if the android id 4 or 2.1 – Mahdi Giveie Nov 19 '12 at 03:16