0

I have started developing an Android application in Android Studio. After starting Android Studio it gives me an error: "compileSdkVersion android-21 requires compiling with JDK 7". So I ran java -version at the Commmand Prompt and it shows I have 1.7. But in Program Files there is a folder for JDK 1.6 but not for 1.7. JRE of 1.7 is there, but not JDK 1.7.

Any suggestions will be appreciated. Thanks in advance.

Boann
  • 48,794
  • 16
  • 117
  • 146
PPD
  • 5,660
  • 12
  • 52
  • 86
  • check Program Files and Program Files (x86) – Kamil.H Nov 21 '14 at 08:45
  • I think in using java -version only shows jre version. not jdk. am I right? – PPD Nov 21 '14 at 08:46
  • 1
    In File -> Project Structure (Strg+Alt+Shift+S) under 'SDK Location' you can check if you point to the right JDK. If only your JRE is Java 1.7 download the Java 7 JDK additionally. – Blacklight Nov 21 '14 at 08:51

3 Answers3

2

Try "javac -version" instead of "java -version" to confirm JDK installed version

It seems that you have a 1.7 Java Runtime but only 1.6 SDK installed.

Just get the correct SDK installer from java.com.

cgimeno
  • 56
  • 6
-1

new: Idea is you can simply set you projects jdk any version you want, different from os installed one, just make sure you download it and referenece from the android studio Same story different interfaces, donno if downvotes were necesary

https://askubuntu.com/questions/467870/how-to-set-the-jdk-for-android-studio

androidstudio set java version 1.7

old(sry tought is eclipse):

How to change JDK version for an Eclipse project

And make sure you have jdk available for eclipse to set it incase you dotn have it. Else just change type

Community
  • 1
  • 1
Bogdan M.
  • 2,161
  • 6
  • 31
  • 53
  • edited. my bad i was not paying attention, by the way downvotes should be reconsider when someone fixed his mistake ;) – Bogdan M. Nov 21 '14 at 08:54
-1

Uninstall all jres and jdks, reinstall the jdk you need (jre is included). Be carefull with the bit-versions, always install the correct one

Zuop
  • 584
  • 5
  • 7
  • 21