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 8029553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:28:15+00:00 2026-06-05T00:28:15+00:00

Problem: I’m writing an Android app, and one of its features requires Open Accessory

  • 0

Problem: I’m writing an Android app, and one of its features requires Open Accessory compatibility, which is only available in 3.1 and up (as well as a backport for certain versions of 2.3.4). The packages I need (android.hardware.usb or android.future.usb) are completely absent from earlier API levels, but I need the app to run on at least Android 2.2. Right now, it won’t even install (I get “INSTALL_FAILED_MISSING_SHARED_LIBRARY” in Eclipse).

I’ve done some research and come up with the following potential solutions, but I need help choosing which one is the “best” (easiest to implement, cleanest, easiest to maintain, most logical…) or if there’s another solution I’ve overlooked.


Solution #1: Create two branches of the project: one supporting accessories, and one for older phones.

Pro: Keeps things clean, and I could just designate one project as the phones-only one, and the other as tablets-only.

Con: Requires that I set up a Library project or work up some kind of custom build script so I don’t have to duplicate all of my code across two projects.


Solution #2: Use reflection to manually load the necessary classes at runtime, and throw an exception if the class does not exist.

Pro: I can maintain backwards compatibility without having to make multiple projects.

Con: It seems a little messy/hacky


So in a nutshell… how can I use a package that only exists in API level 12 and up, but still have the app run on earlier versions?

Any advice would be greatly appreciated. Thanks!

  • 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-05T00:28:16+00:00Added an answer on June 5, 2026 at 12:28 am

    I ended up going with the Library Project solution. A vast majority of the application code was in the Library project, but everything related to Open Accessory was moved to its own project. It actually ended up being pretty easy to maintain since so much code was shared. No complicated build scripts required!

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

Sidebar

Related Questions

Problem is like this: I have two winapi application's. There is only one way
(Problem solved now, see answers below) Hello, in my app I am trying to
Problem Description: We have a service which has applications for main mobile OS’s. We
Problem One: </a> 19-10-2011, 04:49 PM </td> <td class=thread How to fetch the DATE
Problem background: I have a Qt/QML Symbian application targeting Qt 4.7.4, that requires a
Problem: If I pull my app's toolbar off of the window frame and float
Problem description I have 6 databases from 6 different machines, and having one cloud
Problem Statement : Execute Various Command randomly by matching its percentage. like execute CommandA
Problem with writing an if-else statement for a sports website. The key is to
Problem I have a protobuf message definition with a MessageType field, which is an

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.