Eclipse Android SDK:.class文件中的错误版本号

时间:2012-03-26 21:01:13

标签: java android eclipse sdk

我正在尝试将Android SDK集成到Eclipse Indigo中。我安装了ADT插件Android SDK r_17 mac OS,当我转到Preferences-> Android时,出现以下错误:

无法创建所选的首选项页面。 .class文件中的版本号错误

java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:676)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:626)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:608)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:562)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:486)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:459)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:400)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:476)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:345)
at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:229)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1207)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:174)
at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
at org.eclipse.ui.internal.WorkbenchPlugin$1.run(WorkbenchPlugin.java:268)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPlugin.createExtension(WorkbenchPlugin.java:264)
at org.eclipse.ui.internal.dialogs.WorkbenchPreferenceNode.createPage(WorkbenchPreferenceNode.java:47)
at org.eclipse.jface.preference.PreferenceDialog.createPage(PreferenceDialog.java:1339)
at org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.createPage(FilteredPreferenceDialog.java:376)
at org.eclipse.jface.preference.PreferenceDialog.showPage(PreferenceDialog.java:1230)
at org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.showPage(FilteredPreferenceDialog.java:674)
at org.eclipse.jface.preference.PreferenceDialog$10.run(PreferenceDialog.java:708)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.jface.preference.PreferenceDialog$9.selectionChanged(PreferenceDialog.java:704)
at org.eclipse.jface.viewers.StructuredViewer$3.run(StructuredViewer.java:888)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at org.eclipse.jface.viewers.StructuredViewer.firePostSelectionChanged(StructuredViewer.java:886)
at org.eclipse.jface.viewers.StructuredViewer.setSelection(StructuredViewer.java:1726)
at org.eclipse.jface.viewers.TreeViewer.setSelection(TreeViewer.java:1139)
at org.eclipse.jface.preference.PreferenceDialog.selectSavedItem(PreferenceDialog.java:1054)
at org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.selectSavedItem(FilteredPreferenceDialog.java:729)
at org.eclipse.jface.preference.PreferenceDialog$4.run(PreferenceDialog.java:375)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.jface.preference.PreferenceDialog.createContents(PreferenceDialog.java:371)
at org.eclipse.jface.window.Window.create(Window.java:431)
at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089)
at org.eclipse.ui.internal.dialogs.WorkbenchPreferenceDialog.createDialogOn(WorkbenchPreferenceDialog.java:102)
at org.eclipse.ui.dialogs.PreferencesUtil.createPreferenceDialogOn(PreferencesUtil.java:192)
at org.eclipse.ui.dialogs.PreferencesUtil.createPreferenceDialogOn(PreferencesUtil.java:116)
at org.eclipse.ui.internal.handlers.ShowPreferencePageHandler.execute(ShowPreferencePageHandler.java:53)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:178)
at org.eclipse.ui.internal.cocoa.CocoaUIEnhancer.runCommand(CocoaUIEnhancer.java:393)
at org.eclipse.ui.internal.cocoa.CocoaUIEnhancer.actionProc(CocoaUIEnhancer.java:535)
at org.eclipse.ui.internal.cocoa.CocoaUIEnhancer.actionProc(CocoaUIEnhancer.java:520)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
at org.eclipse.swt.widgets.Display.applicationNextEventMatchingMask(Display.java:4879)
at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5226)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
at org.eclipse.swt.internal.cocoa.NSApplication.nextEventMatchingMask(NSApplication.java:94)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3607)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)

Eclipse信息:

eclipse.buildId=M20120208-0800
java.version=1.5.0_30
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86, WS=cocoa, NL=fr_FR
Framework arguments:  -keyring /Users/stef/.eclipse_keyring -showlocation
Command-line arguments:  -os macosx -ws cocoa -arch x86 -keyring /Users/stef/.eclipse_keyring -showlocation

Java版:

    java -version
    java version "1.5.0_30"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_30-b03-389-9M3425)
    Java HotSpot(TM) Client VM (build 1.5.0_30-161, mixed mode, sharing)

在Eclipse中,它目前设置为Java Compiler 1.5和JRE J2SE 5.0。我还尝试使用Java Compiler 1.6和JRE Java SE 6,结果仍然相同。

我做错了什么?

5 个答案:

答案 0 :(得分:3)

这很可能与ADT 17 requiring Java 1.6现在有关:

  

ADT 17.0.0需要Java 1.6或更高版本。

因此,您需要将Java版本从1.5.0_30更新为更新版本。

答案 1 :(得分:0)

显然错误在于.class文件,它不是java的一部分,而是(我相信)错误所在的apk(就像一个隐藏的黑豹,等待打开首选项时打击)。你试过重新安装apk吗?可能是你的下载出来只是腐败应该导致问题。使用.iso文件会发生很多事情,但即使是像apk下载一样小的东西也会搞砸。尝试从系统中彻底清除它并重新安装它(与工具一起,也可能出现错误)。如果这不是您的问题,您可以追踪这个所谓的.class文件(使用资源管理器搜索)并找到版本号所说的内容。任何这些都是一种选择。

希望这有帮助,

-JXP

答案 2 :(得分:0)

我也有这个问题。我刚刚通过下载最新版本的Eclipse解决了这个问题,并从头开始重新安装了Android工具和SDK。

请注意,我只使用64位Eclipse成功。 32位版本对我不起作用。

我正在运行Mac OS X 10.5 Leopard。我在问题发生的时候运行了Java 1.6,所以我没有更新JRE或JDK来解决问题。

解决方案由Satyam Kandula在下面的链接中给出: https://bugs.eclipse.org/bugs/show_bug.cgi?id=376434

答案 3 :(得分:0)

为我的Mac更新了我的JDK(运行Leopard),删除了Eclipse& SDK。重新安装Eclipse(64位版本)& SDK并取得了成功。

答案 4 :(得分:0)

类似,如果不是与OP相同的问题。尝试过多种不同的东西(例如):旧的SDK,旧的ADT插件。我正在使用OS X(10.5)。

最终,我安装了64位Eclipse(eclipse-SDK-3.7.2-macosx-cocoa-x86_64.tar.gz),看起来还不错。

http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops/R-3.7.2-201202080800/eclipse-SDK-3.7.2-macosx-cocoa-x86_64.tar.gz

如果有问题会更新。