0

I am trying to build android apk for my application. I have successfully installed java jdk1.7.0_79, using these Instructions (in highest voted answer). My O.S. is Ubuntu 15.10.

When I build apk using both the Jdk (jdk1.7.0_79/80) I get same build error

:app:transformClassesWithDexForDebug

Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0

    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
 com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/jdk1.7.0_79/bin/java'' finished with non-zero exit value 1

Note 1) I have updated jdk location after installing each jdk(by removing previously installed jdk), I have no problem in java installation.

2) I have previously resolved rendering error in layout which is also same as "Unsupported major.minor version 52.0" by unchecking Android API 23:N(preview).

Community
  • 1
  • 1
Chinmaya B
  • 405
  • 1
  • 7
  • 21
  • `File -> Invalidate caches/Restart` then first option - it should work. After that I recomend `Clean` than `Rebuild` project – piotrek1543 Mar 16 '16 at 17:28
  • After `File -> Invalidate caches/Restart` there is no change same error messages after building project. I have done `clean` and `rebuild` It shows success, but after clicking the run button it again gives same error. – Chinmaya B Mar 16 '16 at 18:00
  • @piotrek1543 I think jdk8 is not supported by android studio, and please rembember that I am working on linux not windows so there may be compatibility issues – Chinmaya B Mar 16 '16 at 18:01
  • 1
    I'm on Ubuntu 15.10 with Android Studio 2.1 Preview (Canary Channel) and it's using Oracle JDK 8, so it does :-) – piotrek1543 Mar 16 '16 at 18:06
  • I am working with android studio 1.5.1 is it the root cause of all problems. I would like to add that I didn't had a working sdk so I downloaded a huge amount of sdk data, but cancelled it after android 4.4 install (in decreasing order). I manually updated sdk from terminal. – Chinmaya B Mar 16 '16 at 18:18
  • try answer below: http://stackoverflow.com/questions/33369163/execution-failed-for-task-apptransformclasseswithdexfordebug-while-implement – piotrek1543 Mar 16 '16 at 18:20
  • @piotrek1543 I tried `./gradlew app:dependencies` some new files were downloaded, but no improvement? Error persists, What do you think about updating to latest version of android studio as well as oracle jdk since mine is 1.5.1? – Chinmaya B Mar 16 '16 at 18:29
  • Do you use a library in your project that is built for Java 8? – Henry Mar 16 '16 at 19:21
  • No The error is gone now I have updated android studio to version 2.1 and moved to jdk8 same config as @piotrek1543 – Chinmaya B Mar 16 '16 at 19:31

1 Answers1

0

Check if your build.gradle(Module:app) has compile

eg: compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0'