Java – Eclipse does not build Android projects for 5.0 Lollipop

Eclipse does not build Android projects for 5.0 Lollipop… here is a solution to the problem.

Eclipse does not build Android projects for 5.0 Lollipop

I updated the Android SDK using the SDK Manager in Eclipse (Kepler). When I change the build target to Android 5.0 Lollipop, Eclipse no longer builds the project. After cleaning up the project, the “gen” folder becomes empty and the R.java and other files are not generated again, although I have “automatic build” enabled. Running “Build Project” or “Build All” manually also doesn’t work. I don’t think this was caused by a source code or resource file error, because when I change the build target to any older Android version (20 and below), it restarts the build.

SDK

updates include almost everything, including the latest build tools (21.1.1), SDK tools (23.0.5), platform tools (21), and of course, Android 5.0 (API 21) itself. I’m using a computer running Windows Vista Home Premium SP2 (32-bit). I also tried compiling the same project on my Mac but there was no such problem.

Who can see what went wrong?


Update November 24, 2014:

I turned on verbose logging of the build process in the Windows -> preferences -> Android -> build -> build output – verbose. When Auto Build is enabled and the Android build target is 5.0 (level 21), I only have two lines of output:

Removing generated java classes.
Starting full Package build.

However, when I change the build target to Android 4.4.2 (level 19), the output is long.


Updated December 1, 2014:

Thanks to @sagis, I am now able to build Android projects for Android 5.0. At first I tried to change only the “Installed JRE” and “Compiler” preferences, but it didn’t work. So sagis is right, I have to uninstall the existing JRE (actually I also uninstalled the JDK).

Other issues I’ve encountered in this process:

  1. Eclipse fails to start after uninstalling the JRE. Use The solution in this SO thread has been resolved
  2. Changing the project-specific Java compiler version to 1.8 will not work. This means that you must check Enable Project-Specific Settings (right-click the project name -> Java Compiler) and select a project-specific Compiler Compliance Level other than 1.8.

Solution

The exact same issue was solved by migrating to JRE 1.8

After setting the project’s build target to Android 5 and restarting Eclipse, I get the following error that this is the problem:

Parsing Data for android-21 failed unsupported major.minor version
51.0

That’s what I did, I hope it helps you (Windows 7 x64, Eclipse x64, JREs x64):

  1. Uninstall all existing JREs.
  2. Verify that there is no “java” command when running “cmd”.
  3. Install JRE 8
  4. Run Eclipse.
  5. “Window”=> “Preferences”=> “Java”=> “

  6. Installed JREs”=> Verify that it points to the new folder.
  7. “Window”=> “Preferences”=> “Java”=> “

  8. Compiler”=> Set to compiler compliance 1.8
  9. Some projects do not compile, use right-click the project, “Android Tools” = > “Fix Project Properties”.

Notes:

  1. Make sure to use the correct JRE version (x86 vs. x64) for your Windows and Eclipse versions.

Related Problems and Solutions