本文介绍了gradlew:appengineEnhance失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Google App Engine Android Studio 创建Java移动后端。为了启动暴露我的API的本地服务器,我使用 gradlew [模块名称]:appengineRun 。然而,当我去 http:// localhost:8080 / _ah / api / explorer 时,尝试使用API​​
我得到以下错误:

  apr 29,2014 10:52:32 PM com。 google.api.server.spi.SystemService invokeServiceMethod 
SEVERE:类com.mthoresen.fest.backend.LocationBean不可持久化。
这意味着它或者没有被增强,或者
文件的增强版本不在CLASSPATH中(或者被未增强版本隐藏),或者
元数据/没有找到该类的注释。

另外,这个过程永远不会结束 - 它停留在建筑88%> ; :[模块名称]:appengineRun






编辑



这个烂摊子是由loosebazooka的答案解决的,但 appengineRun 仍然失败,并且有相同的错误。

所以我尝试了 gradlew [模块名称]:appengineEnhance ,它给了我以下输出:

 依靠包装定义主构件的扩展已被弃用,并计划在Gradle 2.0中删除
:backend:appengineDownloadSdk
:后端:compileJava升级到日期
:后端:appengineEnhance失败

失败:生成失败,出现异常。

*出错:
任务':backend:appengineEnhance'执行失败。
>增强DataNucleus类时发生错误。

*尝试:
使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。

BUILD FAILED

- info code>给了我什么都没有,并且 - debug 是输出很多的方法。 - stacktrace 也没有帮助:

  *例外是:
org.gradle.api.tasks.TaskExecutionException:任务':backend:appengineEnhance'的执行失败。在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions
(ExecuteActionsTaskExecuter.java:69)在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter
。的java:46)
。在在org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
。执行(SkipUpToDateTaskExecuter.java:64)
在org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
在org.gradle.api.internal.tasks。执行.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api。 internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:5 3)
。在org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
。在org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java: 289)
在org.gradle.execution.taskgraph.Abs​​tractTaskPlanExecutor $ TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
在org.gradle.execution.taskgraph.Abs​​tractTaskPlanExecutor $ TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java: 63)在org.gradle.execution.taskgraph.Abs​​tractTaskPlanExecutor $ TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
。在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23
)中在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:86)

在org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
。在组织.gradle.execution.DefaultBuildEx ecuter.execute(DefaultBuildExecuter.java:61)
。在org.gradle.execution.DefaultBuildExecuter.access $ 200(DefaultBuildExecuter.java:23)
。在org.gradle.execution.DefaultBuildExecuter $ 2.proceed(DefaultBuildExecuter。 Java的:在org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32 67)

在org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
在org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
在org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
在org.gradle.initialization.DefaultGradleLauncher .doBuild(DefaultGradleLauncher.java:113)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
at org.gradle.launcher.exec.InProcessBuildActionExecuter $ DefaultBuildController.run(InProcessBuildActionExecuter .java:64)$ or
at org.gradle.launcher.cli.ExecuteBui ldAction.run(ExecuteBuildAction.java:33)
在org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
在org.gradle.launcher.exec.InProcessBuildActionExecuter.execute( InProcessBuildActionExecuter.java:35)
在org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
在org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java: 50)在org.gradle.internal.Actions $ RunnableActionAdapter.execute(Actions.java:171)
。在org.gradle.launcher.cli.CommandLineActionFactory $ ParseAndBuildAction.execute(CommandLineActionFactory.java:201
)中
在org.gradle.launcher.cli.CommandLineActionFactory $ ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
在org.gradle.launcher.cli.CommandLineActionFactory $ WithLogging.execute(CommandLineActionFactory.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory $ WithLogging.execute(CommandLineActionFactory.java:139)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:46)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher。 Main.main(Main.java:37)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run( ProcessBootstrap.java:32)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
在org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
在org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
引起:org.gradle .api.GradleException:增强DataNucleus类时发生错误。
,位于com.google.appengine.task.EnhanceTask.enhanceClasses(EnhanceTask.groovy:58)
位于com.google.appengine.task.EnhanceTask.executeTask(EnhanceTask.groovy:34)
在com.google.appengine.task.AbstractTask.start(AbstractTask.groovy:38)
在org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
在org.gradle .api.internal.project.taskfactory.AnnotationProcessingTaskFactory $ StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:219)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory $ StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)在org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory $ StandardTaskAction.execute
(AnnotationProcessingTaskFactory.java:201)
在org.gradle.api.internal.AbstractTask $ TaskActionWrapper.execute(AbstractTask。 java:533)
at org.gradle.api.internal.AbstractTask $ TaskActionWrapper.execute(AbstractTask.java:516)
在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter。 java:61)
... 46 more
引起:Java返回:1
at org.apache.tools.ant.taskdefs.Java.execute(Java.java:111)
at com.google.appengine.tools.enhancer.EnhancerTask.execute(EnhancerTask.java:97)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(BasicAntBuilder.java:71)
at org.gradle.api.internal.project.ant.BasicAntBuilder.doInvokeMethod(BasicAntBuilder.java:86)
at org.gradle.api.internal.project.DefaultAntBuilder.super $ 3 $ invokeMethod(DefaultAntBuilder .groovy)
在org.gradle.api.internal.pr oject.DefaultAntBuilder.invokeMethod(DefaultAntBuilder.groovy:37)
com.google.appengine.task.EnhanceTask.enhanceClasses(EnhanceTask.groovy:42)
... 56 more

我从Google可以找到的所有文档都使用 Eclipse maven ant ,但 Android Studio 有一个 Google App Engine 插件,所以说它不被支持是没有意义的。



我想要保存的java类:

  import javax。 jdo.annotations.IdGeneratorStrategy; 
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Key;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class LocationBean {

@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
私钥键;
@Persistent
私人双拉特;
@Persistent
private double lng;
@Persistent
私人双拉特;
@Persistent
私人长期结束时间;

/ **吸收器和制定者* /
}

挖掘 - debug 的输出结果,我发现了以下行:

 遇到问题:意外的异常
请参阅日志[C:\ Users \< username> \AppData\Local\Temp\enhance4980231719213251330.log]以获取更多信息。

所以我做了。这是日志文件:

  java.lang.RuntimeException:com.google.appengine.tools上的意外异常
。增强器.Enhancer.execute(Enhancer.java:76)
,com.google.appengine.tools.enhancer.Enhance。< init>(Enhance.java:71)
,com.google.appengine .tools.enhancer.Enhance.main(Enhance.java:51)
引起:java.lang.reflect.InvocationTargetException $ b $在sun.reflect.NativeMethodAccessorImpl.invoke0(本地方法)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:74)
... 2 more
引起:org.datanucleus.exceptions.NucleusException:Plugin(Bundle)org .datanucleus.enhancer已经注册。确保你没有在类路径中使用同一个插件的多个JAR版本。该URL的 file:/ C:/Users/Martin/.gradle/caches/modules-2/files-2.1/org.datanucleus/datanucleus-enhancer/3.1.1/b141c67d55cc19f14639f091b84e692e2198dc50/datanucleus-enhancer-3.1.1.jar已经注册,并且您正在尝试注册位于URLfile:/ C:/Users/Martin/.gradle/appengine-sdk/appengine-java-sdk-1.9.3/lib/opt/tools/的相同插件DataNucleus将/ V1 / DataNucleus将-增强-1.1.4.jar。在org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonManagedPluginRegistry.java:541)

在org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonManagedPluginRegistry.java:395)
在org.datanucleus .plugin.NonManagedPluginRegistry.registerExtensions(NonManagedPluginRegistry.java:219)
。在org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensionPoints(NonManagedPluginRegistry.java:160)LT
。在org.datanucleus.plugin.PluginManager&; INIT> ;(PluginManager.java:65)
at org.datanucleus.plugin.PluginManager.createPluginManager(PluginManager.java:427)
at org.datanucleus.NucleusContext。< init>(NucleusContext.java:224 )
at org.datanucleus.NucleusContext。< init>(NucleusContext.java:204)
at org.datanucleus.enhancer.DataNucleusEnhancer。< init>(DataNucleusEnhancer.java:160)
在org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1133)
... 7 more

有趣的行

 插件(Bundle)org.datanucleus.enhancer已经注册。确保你没有在类路径中使用同一个插件的多个JAR版本。的URL 
的文件:/ C:/用户/<用户名> / gradle这个/高速缓存/模块-2 /文件-2.1 / org.datanucleus / DataNucleus将增强子/ 3.1.1 / b141c67d55cc19f14639f091b84e692e2198dc50 / DataNucleus将增强子。 -3.1.1.jar
已经注册,并且您正在尝试注册位于URL
file:/ C:/ Users /< username> /。gradle / appengine- SDK / AppEngine上的Java-SDK-1.9.3 / lib目录的/ opt /工具/ DataNucleus将/ V1 / DataNucleus将-增强-1.1.4.jar。

所以它看起来像两个广泛不同的版本 datanucleus-enhancer 存在。不知何故,gradlew下载版本 3.1.1 (我已经在 build.gradle 中指定),而部分进程想要使用版本 1.1.4 。再次,我无法找到任何有关如何更改此资源的资源,因为Web上的每个教程都使用Maven。 这个答案已经有点过时了,如果你使用gradle-appengine-plugin版本1.9.5或更高版本,你应该使用新的配置

  appengine {
enhancer {
version =v2
enhanceOnBuild = true
}
}

而不是下面的内容。



原始答案:



您可能需要将增强程序配置为使用增强程序的v2。



在您的build.gradle文件中

  appengine {
enhancerVersion =v2
}


在您的build.gradle文件中创建战争之前自动增强运行





  war.dependsOn appengineEnhance 


I am creating a mobile backend in Java using Google App Engine with Android Studio. In order to start the local server exposing my API, I use gradlew [module name]:appengineRun.

However, when I go to http://localhost:8080/_ah/api/explorer, and try to use the APII get the following error:

apr 29, 2014 10:52:32 PM com.google.api.server.spi.SystemService invokeServiceMethod
SEVERE: The class "com.mthoresen.fest.backend.LocationBean" is not persistable.
This means that it either hasnt been enhanced, or that the enhanced version of
the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the
Meta-Data/annotations for the class are not found.

In addition, the process never ends - it's stuck at Building 88% > :[module name]:appengineRun


Edit

This mess is solved by loosebazooka's answer, but appengineRun still failes with the same error.

So I tried gradlew [module name]:appengineEnhance instead, which gives me the following output:

Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:backend:appengineDownloadSdk
:backend:compileJava UP-TO-DATE
:backend:appengineEnhance FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':backend:appengineEnhance'.
> An error occurred enhancing DataNucleus classes.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option  to get more log output.

BUILD FAILED

--info gives me nothing else, and --debug is way to much output. --stacktrace doesn't really help either:

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task     ':backend:appengineEnhance'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:289)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:86)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:46)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.Main.main(Main.java:37)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: org.gradle.api.GradleException: An error occurred enhancing DataNucleus classes.
    at com.google.appengine.task.EnhanceTask.enhanceClasses(EnhanceTask.groovy:58)
    at com.google.appengine.task.EnhanceTask.executeTask(EnhanceTask.groovy:34)
    at com.google.appengine.task.AbstractTask.start(AbstractTask.groovy:38)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:219)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:201)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:533)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:516)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 46 more
Caused by: : Java returned: 1
    at org.apache.tools.ant.taskdefs.Java.execute(Java.java:111)
    at com.google.appengine.tools.enhancer.EnhancerTask.execute(EnhancerTask.java:97)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(BasicAntBuilder.java:71)
    at org.gradle.api.internal.project.ant.BasicAntBuilder.doInvokeMethod(BasicAntBuilder.java:86)
    at org.gradle.api.internal.project.DefaultAntBuilder.super$3$invokeMethod(DefaultAntBuilder.groovy)
    at org.gradle.api.internal.project.DefaultAntBuilder.invokeMethod(DefaultAntBuilder.groovy:37)
    at com.google.appengine.task.EnhanceTask.enhanceClasses(EnhanceTask.groovy:42)
    ... 56 more

All documentation I can find from Google is using Eclipse with maven and ant, but Android Studio has a Google App Engine plugin, so it wouldn't make sense to say it isn't supported.

The java class I want to save:

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Key;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class LocationBean {

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;
    @Persistent
    private double lat;
    @Persistent
    private double lng;
    @Persistent
    private double rad;
    @Persistent
    private long endtime;

    /** Getters and setters */
}

Digging in the output from --debug, I found the following line:

Encountered a problem: Unexpected exception
Please see the logs [C:\Users\<username>\AppData\Local\Temp\enhance4980231719213251330.log] for further information.

So I did. This is the logfile:

java.lang.RuntimeException: Unexpected exception
at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:76)
at com.google.appengine.tools.enhancer.Enhance.<init>(Enhance.java:71)
at com.google.appengine.tools.enhancer.Enhance.main(Enhance.java:51)
Caused by: java.lang.reflect.InvocationTargetException
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 com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:74)
... 2 more
Caused by: org.datanucleus.exceptions.NucleusException: Plugin (Bundle) "org.datanucleus.enhancer" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL "file:/C:/Users/Martin/.gradle/caches/modules-2/files-2.1/org.datanucleus/datanucleus-enhancer/3.1.1/b141c67d55cc19f14639f091b84e692e2198dc50/datanucleus-enhancer-3.1.1.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/C:/Users/Martin/.gradle/appengine-sdk/appengine-java-sdk-1.9.3/lib/opt/tools/datanucleus/v1/datanucleus-enhancer-1.1.4.jar."
at org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonManagedPluginRegistry.java:541)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonManagedPluginRegistry.java:395)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensions(NonManagedPluginRegistry.java:219)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensionPoints(NonManagedPluginRegistry.java:160)
at org.datanucleus.plugin.PluginManager.<init>(PluginManager.java:65)
at org.datanucleus.plugin.PluginManager.createPluginManager(PluginManager.java:427)
at org.datanucleus.NucleusContext.<init>(NucleusContext.java:224)
at org.datanucleus.NucleusContext.<init>(NucleusContext.java:204)
at org.datanucleus.enhancer.DataNucleusEnhancer.<init>(DataNucleusEnhancer.java:160)
at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1133)
... 7 more

The interesting line being

Plugin (Bundle) "org.datanucleus.enhancer" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL
"file:/C:/Users/<username>/.gradle/caches/modules-2/files-2.1/org.datanucleus/datanucleus-enhancer/3.1.1/b141c67d55cc19f14639f091b84e692e2198dc50/datanucleus-enhancer-3.1.1.jar"
is already registered, and you are trying to register an identical plugin located at URL
"file:/C:/Users/<username>/.gradle/appengine-sdk/appengine-java-sdk-1.9.3/lib/opt/tools/datanucleus/v1/datanucleus-enhancer-1.1.4.jar."

So it looks like two widely different versions of datanucleus-enhancer is present. Somehow, gradlew downloads version 3.1.1 (which I have specified in build.gradle), while a part of the process wants to use version 1.1.4. Again, I can't find any resources on how to change this, as every single tutorial on the web are using Maven.

解决方案

Update:

This answer has gone a little out of date, if you're using gradle-appengine-plugin version 1.9.5 or higher, you should use the new configuration

appengine {
  enhancer {
    version = "v2"
    enhanceOnBuild = true
  }
}

instead of what follows below.

Original Answer:

You probably need to configure the enhancer to use v2 of the enhancer.

in your build.gradle file

appengine {
  enhancerVersion = "v2"
}

[Edit]To make enhance run automatically before creating the war

in your build.gradle file

war.dependsOn appengineEnhance

这篇关于gradlew:appengineEnhance失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 11:23