为 libgdx 构建新 Gradle 项目模型时出错
Posted
技术标签:
【中文标题】为 libgdx 构建新 Gradle 项目模型时出错【英文标题】:Error at building model of new Gradle project for libgdx 【发布时间】:2014-11-22 23:15:37 【问题描述】:我在 Eclipse 中安装了 Gradle,并想导入一个 libgdx Gradle 项目。但是当我点击“构建模型”按钮时,我在加载栏的大约 50% 处出现错误。问题来了:
> Plug-in: org.springsource.ide.eclipse.gradle.core Severity : error
> Message : org.eclipse.osgi.internal.framework.EquinoxConfiguration$1
> Exception Stack trace : java.lang.reflect.InvocationTargetException
> at
> org.springsource.ide.eclipse.gradle.core.util.GradleRunnable.run(GradleRunnable.java:92)
> at
> org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
> Caused by: org.eclipse.core.runtime.CoreException:
> org.eclipse.osgi.internal.framework.EquinoxConfiguration$1 at
> org.springsource.ide.eclipse.gradle.core.GradleModelProvider$GroupedModelProvider.ensureModels(GradleModelProvider.java:284)
> at
> org.springsource.ide.eclipse.gradle.core.GradleProject.getGradleModel(GradleProject.java:633)
> at
> org.springsource.ide.eclipse.gradle.core.GradleProject.getSkeletalGradleModel(GradleProject.java:654)
> at
> org.springsource.ide.eclipse.gradle.ui.wizards.GradleImportWizardPageOne$11.doit(GradleImportWizardPageOne.java:516)
> at
> org.springsource.ide.eclipse.gradle.core.util.GradleRunnable.run(GradleRunnable.java:84)
> ... 1 more Caused by: org.gradle.tooling.GradleConnectionException:
> Could not fetch model of type 'HierarchicalEclipseProject' using
> Gradle distribution
> 'http://services.gradle.org/distributions/gradle-1.11-all.zip'. at
> org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:55)
> at
> org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
> at
> org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source) at
> org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
> at
> org.gradle.tooling.internal.consumer.DefaultModelBuilder.get(DefaultModelBuilder.java:48)
> at
> org.springsource.ide.eclipse.gradle.core.GradleModelProvider.buildModel(GradleModelProvider.java:385)
> at
> org.springsource.ide.eclipse.gradle.core.GradleModelProvider$GroupedModelProvider.ensureModels(GradleModelProvider.java:290)
> ... 5 more Caused by:
> org.gradle.launcher.daemon.client.DaemonConnectionException: Could not
> dispatch a message to the daemon. at
> org.gradle.launcher.daemon.client.DaemonClientConnection.dispatch(DaemonClientConnection.java:57)
> at
> org.gradle.launcher.daemon.client.DaemonClient.executeBuild(DaemonClient.java:168)
> at
> org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:151)
> at
> org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:74)
> at
> org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:42)
> at
> org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:29)
> at
> org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:53)
> at
> org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:30)
> at
> org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:106)
> at
> org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:93)
> at
> org.gradle.tooling.internal.provider.DefaultConnection.getModel(DefaultConnection.java:133)
> at
> org.gradle.tooling.internal.consumer.connection.ModelBuilderBackedModelProducer.produceModel(ModelBuilderBackedModelProducer.java:49)
> at
> org.gradle.tooling.internal.consumer.connection.GradleBuildAdapterProducer.produceModel(GradleBuildAdapterProducer.java:42)
> at
> org.gradle.tooling.internal.consumer.connection.BuildInvocationsAdapterProducer.produceModel(BuildInvocationsAdapterProducer.java:47)
> at
> org.gradle.tooling.internal.consumer.connection.ModelBuilderBackedConsumerConnection.run(ModelBuilderBackedConsumerConnection.java:55)
> at
> org.gradle.tooling.internal.consumer.DefaultModelBuilder$1.run(DefaultModelBuilder.java:59)
> at
> org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:82)
> at
> org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58)
> at
> org.gradle.tooling.internal.consumer.connection.LoggingInitializerConsumerActionExecutor.run(LoggingInitializerConsumerActionExecutor.java:44)
> at
> org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55)
> at
> org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source) Caused by:
> org.gradle.messaging.remote.internal.MessageIOException: Could not
> write message Buildid=67f4f73f-8d68-4e23-87c2-648a4fec30c8.1,
> currentDir=C:\applications\Eclipse to '/127.0.0.1:1598'. at
> org.gradle.messaging.remote.internal.inet.SocketConnection.dispatch(SocketConnection.java:115)
> at
> org.gradle.launcher.daemon.client.DaemonClientConnection.dispatch(DaemonClientConnection.java:51)
> ... 23 more Caused by: java.io.NotSerializableException:
> org.eclipse.osgi.internal.framework.EquinoxConfiguration$1 at
> java.io.ObjectOutputStream.writeObject0(Unknown Source) at
> java.io.ObjectOutputStream.writeObject(Unknown Source) at
> java.util.HashMap.internalWriteEntries(Unknown Source) at
> java.util.HashMap.writeObject(Unknown Source) at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
> java.lang.reflect.Method.invoke(Unknown Source) at
> java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) at
> java.io.ObjectOutputStream.writeSerialData(Unknown Source) at
> java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at
> java.io.ObjectOutputStream.writeObject0(Unknown Source) at
> java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) at
> java.io.ObjectOutputStream.writeSerialData(Unknown Source) at
> java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at
> java.io.ObjectOutputStream.writeObject0(Unknown Source) at
> java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) at
> java.io.ObjectOutputStream.writeSerialData(Unknown Source) at
> java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at
> java.io.ObjectOutputStream.writeObject0(Unknown Source) at
> java.io.ObjectOutputStream.writeObject(Unknown Source) at
> org.gradle.messaging.remote.internal.Message.send(Message.java:40) at
> org.gradle.messaging.remote.internal.DefaultMessageSerializer$MessageWriter.write(DefaultMessageSerializer.java:62)
> at
> org.gradle.messaging.remote.internal.inet.SocketConnection.dispatch(SocketConnection.java:112)
> ... 24 more Root exception: org.eclipse.core.runtime.CoreException:
> org.eclipse.osgi.internal.framework.EquinoxConfiguration$1 at
> org.springsource.ide.eclipse.gradle.core.GradleModelProvider$GroupedModelProvider.ensureModels(GradleModelProvider.java:284)
> at
> org.springsource.ide.eclipse.gradle.core.GradleProject.getGradleModel(GradleProject.java:633)
> at
> org.springsource.ide.eclipse.gradle.core.GradleProject.getSkeletalGradleModel(GradleProject.java:654)
> at
> org.springsource.ide.eclipse.gradle.ui.wizards.GradleImportWizardPageOne$11.doit(GradleImportWizardPageOne.java:516)
> at
> org.springsource.ide.eclipse.gradle.core.util.GradleRunnable.run(GradleRunnable.java:84)
> at
> org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
> Caused by: org.gradle.tooling.GradleConnectionException: Could not
> fetch model of type 'HierarchicalEclipseProject' using Gradle
> distribution
> 'http://services.gradle.org/distributions/gradle-1.11-all.zip'. at
> org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:55)
> at
> org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
> at
> org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source) at
> org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
> at
> org.gradle.tooling.internal.consumer.DefaultModelBuilder.get(DefaultModelBuilder.java:48)
> at
> org.springsource.ide.eclipse.gradle.core.GradleModelProvider.buildModel(GradleModelProvider.java:385)
> at
> org.springsource.ide.eclipse.gradle.core.GradleModelProvider$GroupedModelProvider.ensureModels(GradleModelProvider.java:290)
> ... 5 more Caused by:
> org.gradle.launcher.daemon.client.DaemonConnectionException: Could not
> dispatch a message to the daemon. at
> org.gradle.launcher.daemon.client.DaemonClientConnection.dispatch(DaemonClientConnection.java:57)
> at
> org.gradle.launcher.daemon.client.DaemonClient.executeBuild(DaemonClient.java:168)
> at
> org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:151)
> at
> org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:74)
> at
> org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:42)
> at
> org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:29)
> at
> org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:53)
> at
> org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:30)
> at
> org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:106)
> at
> org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:93)
> at
> org.gradle.tooling.internal.provider.DefaultConnection.getModel(DefaultConnection.java:133)
> at
> org.gradle.tooling.internal.consumer.connection.ModelBuilderBackedModelProducer.produceModel(ModelBuilderBackedModelProducer.java:49)
> at
> org.gradle.tooling.internal.consumer.connection.GradleBuildAdapterProducer.produceModel(GradleBuildAdapterProducer.java:42)
> at
> org.gradle.tooling.internal.consumer.connection.BuildInvocationsAdapterProducer.produceModel(BuildInvocationsAdapterProducer.java:47)
> at
> org.gradle.tooling.internal.consumer.connection.ModelBuilderBackedConsumerConnection.run(ModelBuilderBackedConsumerConnection.java:55)
> at
> org.gradle.tooling.internal.consumer.DefaultModelBuilder$1.run(DefaultModelBuilder.java:59)
> at
> org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:82)
> at
> org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58)
> at
> org.gradle.tooling.internal.consumer.connection.LoggingInitializerConsumerActionExecutor.run(LoggingInitializerConsumerActionExecutor.java:44)
> at
> org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55)
> at
> org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source) Caused by:
> org.gradle.messaging.remote.internal.MessageIOException: Could not
> write message Buildid=67f4f73f-8d68-4e23-87c2-648a4fec30c8.1,
> currentDir=C:\applications\Eclipse to '/127.0.0.1:1598'. at
> org.gradle.messaging.remote.internal.inet.SocketConnection.dispatch(SocketConnection.java:115)
> at
> org.gradle.launcher.daemon.client.DaemonClientConnection.dispatch(DaemonClientConnection.java:51)
> ... 23 more Caused by: java.io.NotSerializableException:
> org.eclipse.osgi.internal.framework.EquinoxConfiguration$1 at
> java.io.ObjectOutputStream.writeObject0(Unknown Source) at
> java.io.ObjectOutputStream.writeObject(Unknown Source) at
> java.util.HashMap.internalWriteEntries(Unknown Source) at
> java.util.HashMap.writeObject(Unknown Source) at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
> java.lang.reflect.Method.invoke(Unknown Source) at
> java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) at
> java.io.ObjectOutputStream.writeSerialData(Unknown Source) at
> java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at
> java.io.ObjectOutputStream.writeObject0(Unknown Source) at
> java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) at
> java.io.ObjectOutputStream.writeSerialData(Unknown Source) at
> java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at
> java.io.ObjectOutputStream.writeObject0(Unknown Source) at
> java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) at
> java.io.ObjectOutputStream.writeSerialData(Unknown Source) at
> java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at
> java.io.ObjectOutputStream.writeObject0(Unknown Source) at
> java.io.ObjectOutputStream.writeObject(Unknown Source) at
> org.gradle.messaging.remote.internal.Message.send(Message.java:40) at
> org.gradle.messaging.remote.internal.DefaultMessageSerializer$MessageWriter.write(DefaultMessageSerializer.java:62)
> at
> org.gradle.messaging.remote.internal.inet.SocketConnection.dispatch(SocketConnection.java:112)
> ... 24 more
会话数据:
eclipse.buildId=4.4.1.M20140925-0400
java.version=1.8.0_20
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.epp.package.java.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product
任何帮助将不胜感激
【问题讨论】:
我在尝试导入或创建新的 gradle 项目时遇到了同样的问题。我注意到这个问题是最近才出现的,它刚刚开始发生在我身上,就在 Eclipse 更新之后。也许更新是相关的?无论如何,这并不特定于 libgdx。 无法让它正确恢复血腥......但它似乎与怀疑的最近更新有关。昨天这里提了一个问题,已经有几个人确认了:github.com/spring-projects/eclipse-integration-gradle/issues/48 我也创建了一个 STS 问题:issuetracker.springsource.com/browse/STS-3922 【参考方案1】:感谢 Kris De Volder 和 'Alex' 的以下解释和解决方法,正如我在此地址 https://issuetracker.springsource.com/browse/STS-3922 上打开的问题所评论的那样,并且大部分只是在这里直接引用以提供此问题的完整答案:
“问题来自以下系统属性 [... 因为它们包含] 不可序列化的值。这些属性是:
osgi.configuration.area.default
osgi.user.area.default
osgi.user.area
“作为一种解决方法,人们可以将 -D 属性添加到他们的 STS.ini、eclipse.ini 或 GGTS.ini 中,以将这些属性设置为他们在 Eclipse 4.4.1 中使用的值
-Dosgi.configuration.area.default=null
-Dosgi.user.area.default=null
-Dosgi.user.area=@user.dir
“我们还将在即将发布的 3.6.2 版本中将此解决方法添加到 Gradle 工具中,以便在安装 gradle 插件时自动将这些道具添加到 .ini 文件中。
“另外值得一提的是,Gradle 似乎也已经修复了这个问题,因此另一种解决方法是使用 Gradle 2.2.BUILD-SNAPSHOT。通过工具中的 Gradle Preference 页面或通过在 gradle.wrapper 中进行设置来设置它你的 gradle 项目。”
所以你有它!一个简单的修复程序,您可以自己手动应用,也可以通过更新应用。我可以确认它有效。
【讨论】:
这是我对 Eclipse 中的 Gradle 的第一印象。我现在有点困惑,但谢谢你的修复。它有效。 NotSerializableException: org.eclipse.osgi.internal.framework.EquinoxConfiguration$1 java.lang.reflect.InvocationTargetException 我仍然在最新的 3.6.1 版本中收到此错误... :( 我添加了这些行以上是他们之后吗【参考方案2】:我认为特别是当 STS 安装有 /sts_installation_dir/configuration/config.ini 而不是 sts.ini 时编辑当前答案更容易。
编辑 config.ini 的正确格式略有不同,因为您不使用 -D 作为属性前缀。
应该是:
osgi.configuration.area.default=null
osgi.user.area.default=null
osgi.user.area=@user.dir
【讨论】:
谢谢@Ash...这对我有用!!!我已经对上面的答案感到沮丧。【参考方案3】:同样的问题发生在我身上,这是我的解决方法。首先,这很容易。
[执行 3 步]第 1 步:只需连接到互联网,然后点击构建模型。第 2 步:它将开始下载一个 zip 文件。第 3 步: 之后重新启动 eclipse。
享受编码... :)
【讨论】:
以上是关于为 libgdx 构建新 Gradle 项目模型时出错的主要内容,如果未能解决你的问题,请参考以下文章
使用新的 libgdx gradle 项目未找到 PolygonShape 本机方法
将 libgdx 项目导入 Eclipse 时出现 Gradle 错误
使用不支持我的 JDK 版本 (17) 的 Gradle 6.7.1 的 LibGDX 项目创建工具
Android Studio -Libgdx-无法使用Gradle发行版“https://services.gradle.org/distributions/gradle-4.4-all.zip”执行