简体   繁体   中英

Eclipse doesn't build Android project targeted at 5.0 Lollipop

I updated the Android SDK using SDK manager in Eclipse (Kepler). When I change the build target to Android 5.0 Lollipop, Eclipse doesn't build the projects anymore. After I clean the project, the "gen" folder becomes empty and R.java and other files are not generated again, although I have "Build Automatically" enabled. Running "Build Project" or "Build All" manually doesn't work either. I don't think it's caused by source code or resource file errors, because when I change the build target to any older Android version (20 and below), it starts building again.

The SDK update had pretty much 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. The computer I use runs Windows Vista Home Premium SP2(32 bit). I also tried to compile the same projects on my Mac, and no such problem there.

Can anyone see what is wrong?


Update 11/24/2014:

I turned on verbose logging of the build process in windows -> Preferences -> Android -> Build -> Build output - verbose. With "Build Automatically" enabled and Android build target at 5.0 (level 21), I only got 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 very long.


Update 12/1/2014:

Thanks to @sagis, I'm able to build my Android projects targeted at Android 5.0 now. At first I tried to change the "Installed JREs" and "Compiler" preferences only, but it didn't work. So sagis was right, I had to uninstall the existing JREs (I actually uninstalled the JDKs as well).

Other issues I encountered in this process:

  1. Eclipse wouldn't start up after uninstalling the JREs. It's resolved using the solution in this SO thread .
  2. Changing the project specific Java Compiler version to 1.8 wouldn't work. That means you have to keep the "Enable project specific settings" checked (right click project name -> Java Compiler), and select project specific "Compiler compliance level" other than 1.8.

Solved exactly the same problem by moving to JRE 1.8

The hint that this was the problem was getting the following error after setting the project build target to Android 5 & restarting Eclipse:

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

This is what I did, hope it helps (Windows 7 x64, Eclipse x64, JREs x64):

  1. Uninstall all existing JREs.
  2. Verify that running "cmd" there's no "java" command.
  3. Install JRE 8
  4. Run Eclipse.
  5. "Window" => "Preferences" => "Java" => "Installed JREs" => Verified it points the new folder.
  6. "Window" => "Preferences" => "Java" => "Compiler" => Set to compiler compliance 1.8
  7. Some projects didn't compile, used Right-Click on the project, "Android Tools" => "Fix Project Properties".

Notes:

  1. Make sure to use the right JRE version (x86 vs x64) depending on your Windows & Eclipse version.

I have solved it (with multiple JVM installed and without uninstall):

  • First I update android build tools.
  • then install java 1.7 JDK (or JRE, or 1.8....)
  • And then set VM in eclipse.ini, like this:

      -vm C:\\Archivos de programa\\Java\\jdk1.7.0_75\\jre\\bin -startup plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar .... .... 

It seems the last android build tools are compile with 1.7 and eclipse need to run with jvm 1.7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM