Skip to content

UnsupportedClassVersionError when attempting to run on Android #355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brianchirls opened this issue Mar 19, 2015 · 6 comments
Closed

UnsupportedClassVersionError when attempting to run on Android #355

brianchirls opened this issue Mar 19, 2015 · 6 comments

Comments

@brianchirls
Copy link

I am unable to run anything on Android. I am getting an UnsupportedClassVersionError when attempting to run the basic "Hello World" example, on either the emulator or the actual device. I believe I have all my paths set up and the latest versions of JDK, Ant and Android SDK. (This is on OSX.)

The following is the end of the console output when I run tns run android

BUILD SUCCESSFUL
Total time: 8 seconds
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/telerik/metadata/Generator : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Command java failed with exit code 1
@rosen-vladimirov
Copy link
Contributor

Hi @brianchirls ,
It looks like the problem is with your java version. May I ask you to update your JDK to at least version 7 or even better - 8 and above. After that can you try run command again?

@brianchirls
Copy link
Author

Thanks for the extremely quick reply, @rosen-vladimirov. I had updated to version 7 and then 8, but neither was working. Turns out that my JAVA_HOME environment variable was still pointing to the old version that came with OSX. If I point it to 7, it works fine. But 8 does not work for some reason.

Now I have a new problem, which is this error message: "Could not find an emulator image to run your project." I have an emulator installed with images for SDK 17, 19 and 21, and it works just fine in Android Studio.

The documentation is great, but it seems to assume a fresh install. It would be helpful if it accounted for systems that may already have some of this stuff installed, like Android Studio.

@brianchirls
Copy link
Author

For the record, here's the error I get when running with JDK 8 (1.8.0_40):

BUILD FAILED
/Users/Home/Library/Android/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/Users/Home/Library/Android/sdk/tools/ant/build.xml:734: Class not found: javac1.8

@rosen-vladimirov
Copy link
Contributor

Hi @brianchirls,
Thank you for sharing this information. As per the new error for missing emulator image, may I ask you to check this issue for suggestions how to fix it:
#363
As per the JDK 8 problem, this is really strange, can you share the id of your app (in the root directory of the project, there's a hidden file called ".tnsproject". Open it with any text editor and check the id and tns-android version from there). I'm asking for the id, as there are some android limitations that prevent build process when the id contains Java keywords, for example org.class.androidTest cannot be build for Android as class is Java keyword.

@brianchirls
Copy link
Author

@rosen-vladimirov, I updated #363 with my own output log.

The id of the app is org.nativescript.tnshelloworld

@rosen-vladimirov
Copy link
Contributor

@brianchirls
I'm closing this thread, lets continue the discussion in #363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants