Programm mobile Android applications with eclipse – Pitfalls when setting up the environment

To program mobile applications Android an appropriate IDE is needed, like Android Studio or eclipse with suitable plug-in. When setting up the eclipse environment you may face some problems. Here are the most common mistakes and solutions when setting up the eclipse environment for Android.

Eclipse JDT

Your current eclipse should have JDT. JDT provides “a set of plug-ins that add the capabilities of a full-featured Java IDE to the Eclipse platform. The JDT plugins provide APIs so that they can themselves be further extended by other tool builders”[1]. To check if you already have installed JDT click Help->About Eclipse -> Installation Details. You will find the Eclipse Java Development Tools in Features.

Android SDK Manger

The SDK Manger has many different SDKs that can be installed. But which SDKs shall be installed? If you want to test your application on diverse emulators/ devices the more you install the better. I would recommend checking which version will cover almost all Android devices on the current market.

What you certainly need to install is the Android Support Library. Otherwise your projects will be built with errors. After the installation you have to import the library in your workspace. You can look up the required steps here [2].

Set the right version in the AndroidManifest.xml

The AndroidManifest.xml is crucial for your application as it contains all information to run the app. Check the versions defined in this file. For example android:minSdkVersion=”8″ or android:targetSdkVersion=”21. Remember never to set the supported versions higher than your actually installed SDK. Otherwise compilation will fail.

If you want to maintain your app along with the Android releases adapt the version in the AndroidManifest.xml with each new release. Don’t forget to test your application.

Errormessage “the project target (android 2.2) was not properly loaded”

Do run eclipse as an administrator.

Errormessage “AppCompat v7 r21 returning error in values.xml”

When I received this error the latest version was Android 5.0. So the according API has to be installed. In order to compile the application with AppCompat it also has to compile against API 21 [6]. In your Android SDK Manager do install the SDK Version 21 AND the buildToolsVersion (21.0.1). Use always the highest Version because it is the latest build tool. Always check if you have installed the right SDKs for the set version.

Errormessage “Parsing data for Android-21 failed.Unsupported major.minor version 51.0”

First check if you really have installed the SDK version (in the Android SDK Manager) mentioned in this error. Otherwise this problem occurs because the Android version and the installed java version are incompatible. You may have to update java. With Android version 51.0 at least java 7 is needed. The number indicates with which java JRE it is compatible [3,4]:

J2SE 8 = 52,
J2SE 7 = 51,
J2SE 6.0 = 50,
J2SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45

Errormessage “Unsupported major.minor version”

You may have changed the used java version in eclipse (Window->Preferences->Java->Installed JRE). Now check the version which is used when starting eclipse (in the CommandLine with java -version). The java version you use to start eclipse and the version you use within eclipse differ. You have to start and run eclipse with the same java version. When installing a new java version, bear in mind:

  • For a 32-bit eclipse you have to install a java 32-bit version. Don’t mix 64 bit and 32 bit versions
  • For multiple java versions on your computer, make sure to set your PATH variable with the right version. It is best to write the version at the beginning of the PATH [5].
  • Check your registry, if it doesn’t contain the different java versions the command java-version won’t find any.

Clean and restart

Whenever all these tips don’t help, start eclipse as administrator, try to clean your projects (Project–> Clean…) or just restart eclipse. Sometimes it is the only thing needed to make everything work.

 References

[1] https://eclipse.org/jdt/overview.php

[2] http://developer.android.com/tools/support-library/setup.html

[3] http://en.wikipedia.org/wiki/Java_class_file

[4] http://stackoverflow.com/questions/10382929/unsupported-major-minor-version-51-0

[5] http://stackoverflow.com/questions/3333553/how-can-i-change-the-java-runtime-version-on-windows-7

[6] http://stackoverflow.com/questions/26457096/appcompat-v7-r21-returning-error-in-values-xml

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s