3

I'm new to android development.

I'm studying with outdated books, so I'm really confused about new methods.

I'm going to make a simple and light app which can be run even on old devices.

So when I created a new android project, I set "Minimum Required SDK" to API 8, "Target SDK" to API 22 and "Compile With" to API 22.

Does this setting mean the app can work on the devices of API 8, even though I use the methods of API 22?

I'm asking this question due to deprecated methods.

I completed almost a half of my app developing using deprecated ones.

Can I just replace them all with new ones?

Or do I have to prepare multiple codes using different methods to support different platform versions?

(deprecated methods for older versions, and new ones for newer versions?)

4 Answers 4

3

Does this setting mean the app can work on the devices of API 8, even though I use the methods of API 22?

Yes. min sdk version is used to restrict the devices running OS with API level < minsdk from using app. Your app won't be shown in the play store for those devices.

I'm asking this question due to deprecated methods.

I haven't faced any issues till now due to depreciated methods. However, I would suggest to use min sdk version as 14 as Google has introduced many UI tweaks and enhancements. If you do some market research, using minsdk version = 14 would cover around 85% android market.

Can I just replace them all with new ones?

Yes, you can.

Or do I have to prepare multiple codes using different methods to support different platform versions? (deprecated methods for older versions, and new ones for newer versions?)

You can do it also. Older versions do not have support have fragments. Fragments improve user experience drastically for tablets. Similarly, material design for Lollypop devices is awesome. Thee are few examples where you can opt for API level specific implementation. However, it is better to switch for api level >= 14

1
  • 1
    Hmm,.. I replaced one with a newer method, and an error mark appeared saying "Call requires API level 21 (current min is 14)". So I added the old line again with an if condition statement but still.. I don't have an old device now, so I'm not sure if this should be okay. May I ignore the error message?
    – Jenix
    Commented Jul 10, 2015 at 9:15
2

To clear up your confusion:

Minimum Required SDK

The minimum version of Android you're going to support. To target the largest market share, I recommend API level 14 or above.

  • Generally, the lower the number, the more Android devices you're targeting.

Target SDK

Basically, all this is saying is what SDK have you tested your app with. If that's KitKat then you can write in the number 19 which is the API number of KitKat, for example. You can find a list of API numbers here. As you test your app with higher and higher versions of Android, you can increase that number.

  • Setting the Target SDK to be a higher number will mean that you target a lot more devices.

Compile With

Specifies what API number of Android you want to compile your app with.

  • By default this is the latest version of Android available in the SDK Manager. Should be set high to improve user experience.

Deprecated Methods

As to your question about deprecated methods: You can continue using them. They are deprecated in favour of a newer alternative that may or may not be better in terms of functionality.

1
  • Wow, I didn't know that such a few people were using devices lower than 4.x.. Thanks
    – Jenix
    Commented Jul 10, 2015 at 9:38
1

Deprecated methods will still work, the deprecated keyword just tells you that there is a newer preferred way to do it. Android is really good at backward compatibility so something compiled for API level 8 should mostly work on newer devices to.

0
1

You're going to have to use multiple code branching on version. You can check your system version at runtime like this:

private void setUpActionBar() {
    // Make sure we're running on Honeycomb or higher to use ActionBar APIs
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
}

API 8 is really old. Have a look at the version pie chart

You can find more information about this on the Android developers website

1
  • You posted the same link haha. Thanks!
    – Jenix
    Commented Jul 10, 2015 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.