Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio preview: This JVM does not support constant tag 15

I'm attempting to look at a preview of an xml layout that contains a couple custom views (nothing complicated... mostly wrappers). I'm getting the following error:

The following classes could not be instantiated:
- com.app.view.widget.SlidingSwipeRefreshLayout (Open Class, Show Exception, Clear Cache)
- com.app.view.widget.BetterViewAnimator (Open Class, Show Exception, Clear Cache)

java.lang.ClassFormatError: This JVM does not support constant tag 15 in class file <Unknown>
    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.lang.ClassLoader.defineClass(ClassLoader.java:471)
    at com.android.tools.idea.rendering.RenderClassLoader.loadClass(RenderClassLoader.java:150)
    at com.android.tools.idea.rendering.RenderClassLoader.loadClassFile(RenderClassLoader.java:125)
    at org.jetbrains.android.uipreview.ModuleClassLoader.loadClassFile(ModuleClassLoader.java:287)
    at com.android.tools.idea.rendering.RenderClassLoader.loadClassFromClassPath(RenderClassLoader.java:118)
    at org.jetbrains.android.uipreview.ModuleClassLoader.loadClassFromModule(ModuleClassLoader.java:202)
    at org.jetbrains.android.uipreview.ModuleClassLoader.loadClassFromModuleOrDependency(ModuleClassLoader.java:136)
    at org.jetbrains.android.uipreview.ModuleClassLoader.load(ModuleClassLoader.java:122)
    at com.android.tools.idea.rendering.RenderClassLoader.findClass(RenderClassLoader.java:53)
    at org.jetbrains.android.uipreview.ModuleClassLoader.findClass(ModuleClassLoader.java:84)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:182)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:101)
    at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:177)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:400)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:497)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:485)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:894)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:485)
    at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:590)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:644)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:79)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:586)
    at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:581)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
    at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)

Is there a suggested fix for it? I've tried the typical cleaning/re-building and restarting Android Studio.

like image 867
loeschg Avatar asked May 28 '15 15:05

loeschg


1 Answers

If you have lambdas in your custom view class, then you need to run Android Studio under Java 8. According to tools.android.com, you can do this by setting the STUDIO_JDK environment variable.

If you are on a Mac, you can set this environment variable so that it is always used by Android Studio by running the following:

launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk

(Adjust according to your actual JDK location.)

like image 141
Alec B. Plumb Avatar answered Nov 15 '22 11:11

Alec B. Plumb