Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8084927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:56:37+00:00 2026-06-05T17:56:37+00:00

My app need to target API level 7 and above, however I’d like to

  • 0

My app need to target API level 7 and above, however I’d like to selectively use functionality from newer releases when it becomes available. For instance, I might have code like this:

if (Build.VERSION.SDK_INT >= 8) {
    base64String = android.util.Base64.encodeToString(bytes, android.util.Base64.DEFAULT);
} else {
    base64String = MyCustomBase64.encodeBytes(bytes);
}

However, when I configure the project in eclipse to target “Android 2.1” (API 7) the class android.util.Base64 isn’t found since it only exists for API 8 and above. Eclipse then designates that line as a compile error (red “x”) since the class isn’t on the build path.

My question: what is the “proper” way to handle this sort of development (supporting features that don’t actually exist in one’s target environment) when doing Android development using Eclipse?

I can always change the target in Eclipse to 2.2 (API 8), but that’s not ideal either. It creates the situation where I might unknowingly use a feature that only exists in 8+ and not be notified of that fact by Eclipse.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:56:38+00:00Added an answer on June 5, 2026 at 5:56 pm

    You have answered your own question.

    I can always change the target in Eclipse to 2.2 (API 8)

    That is how it is done. You can still set the minSDK/targetSDK in your manifest to 7. AFAIK you’ll just have to use the if statements like you’ve shown around any code that is from a higher API level.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my app need to show user scrollable menu bar under tab bar like fox
I've downloaded the iOS CloudApp API files from the CloudApp website. I would like
I have an iOS app which I need to upload the binary of. From
I need to prevent users from starting my Java application (WebStart Swing app) multiple
I am developing a C app using Code::Blocks, and need to target multiple platforms
For my GAE app I need to do some natural language processing to extract
In my app I need to draw a widget contents onto Bitmap. The code(pseudo)
My android app project need to add a new function of saving the click
Android Calendar App I need to be able to implement a view similar to
In my iPhone app I need to round an integer to the nearest multiple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.