Skip to content

Eclipse Troubleshooting

Ytai Ben-Tsvi edited this page Nov 28, 2012 · 8 revisions

Eclipse Troubleshooting Guide

Don't Panic!

The Android development environment is awesome! However, it may be a little daunting to set-up initially, especially if you have no prior experience with Android development or with the Eclipse IDE. Fear not the threatening red cross icons! Most problems are common and easy to work-around, and once you manage to build you project correctly once, the rest of the development is smooth (well, at least as far as the development tools are concerned, your bugs are still yours to find and fix...).

This page will list common problems, along with their solutions and their causes (which you don't have to read if you just want to fix the problem and move on with your life). If you encountered a problem not listed here, start a thread on the ioio-users mailing list and someone will probably be there to help you. One recommendation before we begin: unless you have a good understanding of Eclipse and the Android SDK, you probably want to start with the ADT Bundle. This is a package that contains Eclipse, Android SDK with the latest platform, ADT and a bunch of other stuff. In short, this will give you sort of a sterile, complete development environment to start with. Trying to install those things separately without really knowing what you're doing has a good chance of frustrating you.

This page is not intended to be a guide for setting up Eclipse or the Android SDK or for teaching you Android development or Java. There are plenty of resources for that on the Internet. Before even looking into IOIO, please make sure you are able to build, install and run a simple Android application. The Android "Building Your First App" guide is a good place to start.

General Diagnosis & Recovery Steps

  • First and most important: do not struggle with getting any other projects build correctly before you get IOIOLibAndroid building! All the other projects depend on IOIOLibAndroid, and will fail to build If their dependency doesn't build. If you see a red-cross icon next to the IOIOLibAndroid project, right click all the other projects (tip: you can select them all and then right-click once) and select "Close Project". Open the "Problems" view in Eclipse, through Window > Show View... > Problems. Then debug the IOIOLibAndroid build according to the suggestions below. Only once this is fixed, move on to IOIOLibBT and/or IOIOLibAccessory, if you are using them, and only then to your application project.
  • Sometimes Eclipse just gets into a weird transient state. Right click the project and click Refresh. Then go to Project > Clean... and select "Clean all projects". We're assuming here that you are using "Build Automatically", which can be set under the "Project" menu. In many cases, just cleaning and rebuilding makes some build problems go away. In particular, after trying each of the solutions proposed below, try a Clean-Build cycle.

Unable to resolve target 'android-3'

Symptoms

You are seeing an error message such as:

Unable to resolve target 'android-3'
Unable to resolve target 'android-7'
Unable to resolve target 'android-10'
Unable to resolve target 'Google Inc.:Google APIs:10'

INSERT PICTURE

Solution

Right-click project > Properties > Android tab: INSERT PICTURE Make sure a Project Build Target is selected.

  • For IOIOLibAndroid, it should be API 3 or greater.
  • For IOIOLibBT, it should be API 7 or greater.
  • For IOIOLibAccessory, it should be API 10 or greater with the Google APIs.
  • For application projects, it should be API 3 or greater.

If you want to add build targets, you need to install new SDKs from the Android SDK manager. Click this: **INSERT PICTURE (sdk manager) Then select the SDK to install: **INSERT PICTURE (google apis)

Explanation

Which Android target to build against is part of the project configuration. Each user might have a different set of actual SDKs installed. The projects are released with the minimum required target configured for them.

UsbManager cannot be resolved

Symptoms

You get any of the following errors on IOIOLibAccessory:

UsbManager cannot be resolved
UsbAccessory cannot be resolved to a type
The import com.android.future cannot be resolved
UsbManager cannot be resolved
UsbAccessory cannot be resolved to a type

Solution

RTFM. The previous issue told you to use a Google APIs target (API 10 or greater) on IOIOLibAccessory. INSERT PICTURE (select-google-apis)

Explanation

The USB Accessory libraries have been released as Google-proprietary add-ons for Android 2.3.4, and only on Android 3.0 and higher they became a standard part of the SDK. Unfortunately, the API is slightly different, so for backward compatibility with Android 2.3.4 we have to use the proprietary libraries.

Java Compiler Compliance Level

Symptoms

You are getting something like this for any of the projects:

Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead. Please use Android Tools > Fix Project Properties.
Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties.

INSERT PICTURE (java-17)

Solution

As the error suggests, right click the project > Android Tools > Fix Project Properties INSERT PICTURE (fix-properties) If that doesn't work, you can fix it manually by opening the project properties (right click project > Properties). Then configure the Java Compiler settings as in the following picture: INSERT PICTURE (java-settings)

Explanation

If that's what Android requires, who are we to argue?

Project Dependency Issues

Symptoms

One of the dependent projects (IOIOLibBT, IOIOLibAccessory or an application project) fail to build with something like:

ConnectionLostException cannot be resolved to a type
IOIOConnection cannot be resolved to a type
IOIOConnection cannot be resolved to a type
The import ioio.lib.api cannot be resolved
The import ioio.lib.spi cannot be resolved
...

INSERT PICTURE (dependecy-symptoms)

Solution

IOIOLibAccessory and IOIOLibBT as well as any application project depend on IOIOLibAndroid. Application projects may additional depend on IOIOLibBT and/or IOIOLibAccessory. These two are optional: if you don't require Bluetooth support or OpenAccessory support in your project, you can simply remove the dependency, as explained below, and the application should build fine.

One of the dependent projects is either:

  • Doesn't exist in the workspace: Import it!
  • Closed: Open it!
  • Dependency is Broken: This is indicated by a red-cross icon in the Android properties page. It can be easily fixed by removing the broken dependency and re-adding it.

INSERT IMAGE

Explanation

The project dependency, among other things, tells the compiler where to search for some of the classes that the dependent project uses. If the depended project is not there, the compiler will (rightfully) complain.