0

I seem to have solved the immediate compile errors, but would appreciate some deeper insight and have not found anything on StackExchange or Googling the error message that appears directly applicable.

Have been using Android Development Kit plugin for Eclipse for only a few weeks now. I understand that Android only uses syntax through Java 1.5 and suspect that may be a clue to my problem which only occurred after I added a Debug.startMethodTracing("filename.trace"); and added WRITE_EXTERNAL_STORAGE uses-permissions.

Successfully compiled and ran simple (hello world style) apps, then all of a sudden: bam!!

Brand new error message:

"Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment."

When I checked the Java Build path for my app:

Right click project name > Properties > Java Build Path > Libraries

There were only four items: 1) An imported jar file library (for an API) 2) Android 4.4.2 3) Android Dependencies 4) Android Private Libraries

I seem to have solved the problem by following these non-Android specific instructions:

Java Build Path

which essentially said to:

'Add Library" > 'JRE System Library" > "Workspace default JRE (jre7)

and now my code appears to be compiling again. However, I am somewhat uncomfortable with my level of understanding of why it was necessary to do this (I just checked and Jdk1.7 is still in my system path and seemed to work fine before). Is this usually necessary when developing for Android?

In other words, is it normal for a JRE to be explicitly listed in the libraries section with the ADK? Is there any problem with using JRE 1.7 instead of an older version?

I also read these instructions, but again, the answer is not specific to Android: Warning - Build path specifies execution environment J2SE-1.4

Community
  • 1
  • 1
Dell Anderson
  • 143
  • 2
  • 7
  • 1
    actually depends on api level which java 1.5 or 1.6 or now 1.7 as api level 8 and beow was java .15 and api 9 to 18 was java 1.6 and now api 19 is java 1.7 for the most part. – Fred Grott Dec 31 '13 at 02:02

1 Answers1

1

The warning is letting you know that you don't have any actual 1.6-version JDKs available, even though your code is set to a 1.6 compliance level. The practical pitfall is that since the only JRE runtime available is the 1.7 runtime, you might use some class or method that was added in 1.7: Your code would still compile just fine, but then you'd get a NoSuchMethodError or such if it was run on a 1.6 runtime.

In practical terms, since you're targeting Android, you probably don't need to worry; the ADK is going to recompile your code anyway, and any such errors should show up immediately. If you do want the warning gone, just install the 1.6 JDK alongside the 1.7.

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152
  • Thanks, chrylis, I accepted your answer. It seems a bit counterintuitive that the Eclipse option for setting compliance level requires a completely different JDK version rather than some kind of limited subset of JDK7. It appears that there is sufficient difference between JDK7 and JDK6 not to allow backward compatibility (in other words, 7 is more than just expanded syntax). – Dell Anderson Feb 01 '14 at 02:42
  • @DellAnderson The compliance level is about syntax. The other difference is the additional API that's added with each version. – chrylis -cautiouslyoptimistic- Feb 01 '14 at 05:41