Android Studio fails to load the Visual Layout Editor - java

I've been on google and android support forums for more than 8 hours now with no luck. My Android studio was working fine 2 days ago and last night when I wanted to continue my project, I got this error :
Render error
ActiveTool: com.intellij.designer.designSurface.tools.SelectionTool#7797899
SDK: Android 4.4.2 - API 19
java.lang.NoClassDefFoundError: org/kxml2/io/KXmlParser
at com.android.ide.common.resources.IdResourceParser.parse(IdResourceParser.java:75)
at com.android.ide.common.resources.IdGeneratingResourceFile.parseFileForIds(IdGeneratingResourceFile.java:150)
at com.android.ide.common.resources.IdGeneratingResourceFile.load(IdGeneratingResourceFile.java:72)
at com.android.ide.common.resources.ResourceFolder.getFile(ResourceFolder.java:286)
at com.android.ide.common.resources.ResourceFolder.processFile(ResourceFolder.java:74)
at org.jetbrains.android.sdk.FrameworkResourceLoader$IdeFrameworkResources.ensureInitialized(FrameworkResourceLoader.java:124)
at org.jetbrains.android.sdk.FrameworkResourceLoader.loadPlatformResources(FrameworkResourceLoader.java:60)
at org.jetbrains.android.sdk.FrameworkResourceLoader.load(FrameworkResourceLoader.java:54)
at org.jetbrains.android.sdk.AndroidTargetData.getFrameworkResources(AndroidTargetData.java:207)
at com.android.tools.idea.configurations.ResourceResolverCache.getFrameworkResources(ResourceResolverCache.java:248)
at com.android.tools.idea.configurations.ResourceResolverCache.getFrameworkResources(ResourceResolverCache.java:214)
at com.android.tools.idea.configurations.ResourceResolverCache.getResourceResolver(ResourceResolverCache.java:129)
at com.android.tools.idea.configurations.Configuration.getResourceResolver(Configuration.java:1137)
at com.android.tools.idea.rendering.RenderService.getResourceResolver(RenderService.java:276)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:469)
at com.android.tools.idea.rendering.RenderService.render(RenderService.java:691)
at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$6.run(AndroidDesignerEditorPanel.java:483)
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:327)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.ClassNotFoundException: org.kxml2.io.KXmlParser PluginClassLoader[org.jetbrains.android, 10.0]
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:68)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 30 more
Anyone got some thoughts on this? Oh yeah, The first time I used android studio, it was online, then it work, then offline, still worked and now it doesn't work again.
My setup :
Windows 8.1 pro 64-bit
Java JDK 1.7 64-bit
I tired changing the API level, but still no results. Here is a screenshot :
http://snag.gy/bSr7y.jpg
If there is already a thread on this, please point me to it and I'll remove this one. I did a quick search on StackOverflow and couldn't see anything.
Thanks in advance
Solution :
Turns out, my JDK was corrupt and it didn't fully remove the installation when uninstalled.
I finally got it fixed. Here is what I did :
First, I uninstalled Java JDK1.7 and removed all it's left over files.
Then I downloaded and installed JDK1.8 and it worked.
I had an error where the Studio said it couldn't detect JDK, so I only added an JAVA_HOME environment variable which points to my new JDK and it's all working fine now. Thanks everyone for the help and suggestions. I hope this can help someone in the future.

I dont know what the exact problem was ...
But NoClassDefFoundError is kind of hard ...
Anyway try this post
3 ways to solve java.lang.NoClassDefFoundError in Java
Check the XmlParser class (try commenting any class calls)
above link describes how this error gets generated

Related

IllegalStateException: zip file closed

I have a Java desktop application that was running fine in Java 1.8; I'm upgrading to Java 1.11 for a client, and am getting the above error.
Full stacktrace:
java.lang.ExceptionInInitializerError
at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:442)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:326)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:309)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:290)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:274)
at drivingrecordtool.file.DrivingRecordPDFTextReader.getOCRText(DrivingRecordPDFTextReader.java:152)
at drivingrecordtool.file.DrivingRecordPDFTextReader.getText(DrivingRecordPDFTextReader.java:46)
at drivingrecordtool.file.DrivingRecordFileReader.doInBackground(DrivingRecordFileReader.java:78)
at drivingrecordtool.file.DrivingRecordFileReader.doInBackground(DrivingRecordFileReader.java:1)
at java.desktop/javax.swing.SwingWorker$1.call(SwingWorker.java:304)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.desktop/javax.swing.SwingWorker.run(SwingWorker.java:343)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalStateException: zip file closed
at java.base/java.util.zip.ZipFile.ensureOpen(ZipFile.java:913)
at java.base/java.util.zip.ZipFile.getEntry(ZipFile.java:348)
at java.base/java.util.zip.ZipFile$1.getEntry(ZipFile.java:1130)
at java.base/java.util.jar.JarFile.getEntry0(JarFile.java:586)
at java.base/java.util.jar.JarFile.getEntry(JarFile.java:516)
at java.base/sun.net.www.protocol.jar.URLJarFile.getEntry(URLJarFile.java:131)
at java.base/java.util.jar.JarFile.getJarEntry(JarFile.java:478)
at java.base/jdk.internal.loader.URLClassPath$JarLoader.getResource(URLClassPath.java:945)
at java.base/jdk.internal.loader.URLClassPath.getResource(URLClassPath.java:315)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:455)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(LoadLibs.java:83)
at net.sourceforge.tess4j.TessAPI.<clinit>(TessAPI.java:42)
... 15 more
The Tesseract library has a Java wrapper that I've used for months successfully but now seems involved in the error, whatever it is. I've been using the same DLL and started getting this failure, and I've updated the Tesseraact DLL and the wrapper to their latest version.
More puzzling is that the application runs fine within eclipse, and only fails like this when run from a command line (Windows 10). I have uninstalled and reinstalled the DLL a couple of times, rebooted the machine each time, and am running out of things to try. I went through the entire Maven dependencies list and deleted all files found there from my repository, then refreshed the eclipse project to reload all the files in the list.
I saw one suggestion of placing a breakpoint in ZipFile, but that won't help since the problem does not appear in eclipse.
I'm willing to upgrade the Java further, but it would be nice, first, to have some knowledge of what the problem is so that I have some confidence that will fix it.
Can someone suggest what might be wrong, or strategies to find out?

How do I solve this NPE from trying to use Journey Browser

Using journey browser project I have set up a simple maven project in eclipse, using the dependency provided on the page, I have tried to run the code example (also provided on the page)
And I get an NPE:
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:588)
at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:583)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:582)
at java.desktop/java.awt.Toolkit.getEventQueue(Toolkit.java:1494)
at java.desktop/java.awt.EventQueue.isDispatchThread(EventQueue.java:1086)
at java.desktop/javax.swing.SwingUtilities.isEventDispatchThread(SwingUtilities.java:1493)
at com.codebrig.journey.JourneyBrowserView.<init>(JourneyBrowserView.java:78)
at com.codebrig.journey.JourneyBrowserView.<init>(JourneyBrowserView.java:71)
at JourneyBrowser.main(JourneyBrowser.java:13)
Caused by: java.lang.NullPointerException
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2646)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830)
at java.base/java.lang.System.loadLibrary(System.java:1870)
at java.desktop/sun.awt.windows.WToolkit$1.run(WToolkit.java:118)
at java.desktop/sun.awt.windows.WToolkit$1.run(WToolkit.java:115)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.awt.windows.WToolkit.loadLibraries(WToolkit.java:114)
at java.desktop/sun.awt.windows.WToolkit.<clinit>(WToolkit.java:129)
... 12 more
Can anyone explain what is happening and why here, I have tried this on 64bit windows with java Coretto 11(jdk11.0.7_10),I initially found a bug here, relating to loadLibray in open JDK and thought that maybe the problem, I just don't have a good enough understanding to work out how to get around it?
I'm not sure, but I think that Corretto bug is probably the one that is causing the problem. As noted, it is from their "upstream"; i.e the OpenJDK codebase. It was due to regression that appeared in jdk11.0.7 due to a backport of a fix for another problem. Apparently, the fix changes some internal JDK fields and that breaks application code. As JDK-8240521 puts it:
The backport of the JDK-8231584 changes internal JDK fields processing. The problem is that the many third-party applications copy-pasted a hack that depends on particular JDK implementation.
If I am reading the Oracle bug entries correctly, the reversion of the broken fix should be in JDK11.0.8. Alternatively, an earlier JDK 11 release than 11.0.7 shouldn't have the broken fix.
Let me know if changing your Java 11 install solves the problem. (If not, I'll see if I can get the line numbers to match up.)

Processing on Java error on Mac OS

I got this error message in the console when I tried to run, I just switched laptops and I've wiped my old one. This project has always been stored in a USB so I use that to run it on my new laptop. (So I had to re-download all the applications), I need this to fix so bad due to its my project for class and I haven't record it and I'm supposed to do that and I don't want to fail the class please could u help thank u:
java.lang.NoClassDefFoundError: com/apple/eawt/QuitHandler
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3119)
at java.base/java.lang.Class.getMethodsRecursive(Class.java:3260)
at java.base/java.lang.Class.getMethod0(Class.java:3246)
at java.base/java.lang.Class.getMethod(Class.java:2065)
at processing.core.PApplet.runSketch(PApplet.java:10751)
at processing.core.PApplet.main(PApplet.java:10548)
at processing.core.PApplet.main(PApplet.java:10530)
at robothead.Robothead.main(Robothead.java:8)
Caused by: java.lang.ClassNotFoundException: com.apple.eawt.QuitHandler
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 9 more
I at first download JDK 10 and I read it only works with JDK 8 so I download that and delete JDK 10 in hopes that stuff will return back to normal and it does not works. Also the project, I did it in java oxygen and I downloaded photon on my new laptop and click on the yes I want to convert the files thing so I decided to make a new workspace and copy paste the code but still got that error?Before it was MacBook Air and I switch to the MacBook Pro.
You are mixing up a lot of things.
The basic problem is that starting with Java 9 oracle made changes that lead to such errors ( see https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-C86F7403-7D7C-456F-8873-18C7F1BEDE2F).
So, in order to get this to work, you have to ensure that Java 8 is used. And that your Java 10 installation was really, fully removed. You should then check your eclipse settings to also ensure that it is pointing to Java 8.

ClassNotFoundException for FileOpUtils with Android Studio 2.0 Preview

After upgrading to Android Studio 2.0 Preview I see the following exception when I try to build a project
Error:Internal error: (java.lang.ClassNotFoundException) com.android.repository.io.FileOpUtils
java.lang.ClassNotFoundException: com.android.repository.io.FileOpUtils
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
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 java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.android.sdklib.repository.local.LocalSdk.<init>(LocalSdk.java:182)
at com.android.sdklib.repository.local.LocalSdk.<init>(LocalSdk.java:191)
at org.jetbrains.jps.android.AndroidBuildDataCache.getSdk(AndroidBuildDataCache.java:145)
at org.jetbrains.jps.android.AndroidJpsUtil.getAndroidTarget(AndroidJpsUtil.java:403)
at org.jetbrains.jps.android.AndroidJpsUtil.getAndroidPlatform(AndroidJpsUtil.java:478)
at org.jetbrains.jps.android.builder.AndroidPreDexBuildTarget.computeRootDescriptors(AndroidPreDexBuildTarget.java:110)
at org.jetbrains.jps.builders.impl.BuildRootIndexImpl.addRoots(BuildRootIndexImpl.java:72)
at org.jetbrains.jps.builders.impl.BuildRootIndexImpl.<init>(BuildRootIndexImpl.java:62)
at org.jetbrains.jps.cmdline.BuildRunner.load(BuildRunner.java:83)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:266)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:125)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:232)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:42)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
It is a known issue but any comments there are "me too".
Has anyone been able to workaround this?
Update
This issue has been resolved in 2.0 Preview 4.
A workaround was posted in a comment to the issue filed.
On my Mac I performed the following steps in a Terminal:
vi /Applications/Android\ Studio.app/Contents/plugins/android/lib/android.jar
Select META-INF/plugin.xml for editing.
Add ;repository.jar to the classpath attribute in the line <compileServer.plugin classpath="sdklib.jar;common.jar;jarutils.jar;layoutlib-api.jar;manifest-merger.jar"/> and save changes.
Open Android Studio
As mentioned in the comment you may need to apply this workaround again after further updates to Android Studio if the issue still hasn't been resolved.
Warning
After applying the above changes Android Studio is no longer able to apply patch updates. You get a warning like that shown in this question. It seems the only solution is a re-install. According to the comments on the issue though the problem still exists in the latest build.

Android,GoogleAnalytics - java.lang.NullPointerException

I'm using GoogleAnalyticsServicesAndroid_3.0, And Have a min sdk of Android API 9.
I keep seeing the following error in my bug report system :
java.lang.NullPointerException
at android.app.ContextImpl.openFileOutput(ContextImpl.java:431)
at android.content.ContextWrapper.openFileOutput(ContextWrapper.java:158)
at com.google.analytics.tracking.android.ClientIdDefaultProvider.storeClientId(ClientIdDefaultProvider.java:102)
at com.google.analytics.tracking.android.ClientIdDefaultProvider.generateClientId(ClientIdDefaultProvider.java:123)
at com.google.analytics.tracking.android.ClientIdDefaultProvider.initializeClientId(ClientIdDefaultProvider.java:179)
at com.google.analytics.tracking.android.ClientIdDefaultProvider$1.run(ClientIdDefaultProvider.java:134)
I haven't been able to find a solution for this, Any help is appreciated
This seems to only happen in 2.3. OS versions
Thanks,
Shimi

Categories

Resources