[英]Error when trying to implement amazon mturk SDK into android studio project
I am trying to implement Amazon's mechanical turk into my android app.我正在尝试将亚马逊的机械土耳其人实施到我的 android 应用程序中。 I have followed the instructions: http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMechanicalTurkGettingStartedGuide/CreatingAHIT.html#Java but when I am specifying the third party .jar files, it gives me
我已按照说明进行操作: http : //docs.aws.amazon.com/AWSMechTurk/latest/AWSMechanicalTurkGettingStartedGuide/CreatingAHIT.html#Java但是当我指定第三方 .jar 文件时,它给了我
Error:Gradle: Execution failed for task ':app:dexDebug'.错误:Gradle:任务 ':app:dexDebug' 执行失败。
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command'/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java''完成非零退出值 1
I have tried taking out every combination of .jar files and found out that jaxrpc.jar is the file causing this error.我尝试取出 .jar 文件的每个组合,发现 jaxrpc.jar 是导致此错误的文件。 Without this file, the error when running the project is:
没有这个文件,运行项目时的错误是:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/rpc/ServiceException
at com.example.mturk.HomeworkRequest.<init>(HomeworkRequest.java:20)
at com.example.mturk.HomeworkRequest.main(HomeworkRequest.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at ...
where line 20 points to:其中第 20 行指向:
service = new RequesterService(new PropertiesClientConfig("../mturk.properties"));
and line 39 points to:第 39 行指向:
HomeworkRequest app = new HomeworkRequest();
I have tried enabling multiDex and looked around but couldn't find any solution.我尝试启用 multiDex 并环顾四周,但找不到任何解决方案。 Any help would be greatly appreciated, I have been stuck on this problem for a few days now.
任何帮助将不胜感激,我已经被这个问题困住了几天。
EDIT: Here's my code so far.编辑:到目前为止,这是我的代码。 It's just a simple HIT request similar to the sample in http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMechanicalTurkGettingStartedGuide/CreatingAHIT.html#Java
这只是一个简单的 HIT 请求,类似于http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMechanicalTurkGettingStartedGuide/CreatingAHIT.html#Java 中的示例
import com.amazonaws.mturk.requester.HIT;
import com.amazonaws.mturk.service.axis.RequesterService;
import com.amazonaws.mturk.service.exception.ServiceException;
import com.amazonaws.mturk.util.PropertiesClientConfig;
public class HomeworkRequest{
private RequesterService service;
private String title= "Math Question";
private String description = "Solve the math question shown";
private int numAssignments = 3;
private double reward = 0.05;
public HomeworkRequest(){
service = new RequesterService(new PropertiesClientConfig("../mturk.properties"));
}
public void createHomeworkRequest(){
try {
HIT hit = service.createHIT(
title, description, reward, RequesterService.getBasicFreeTextQuestion(
"Can you solve this math question?"), numAssignments);
System.out.println("Created HIT: " + hit.getHITId());
System.out.println("HIT location: ");
System.out.println(service.getWebsiteURL() + "/mturk/preview?groupId=" + hit.getHITTypeId());
}
catch(ServiceException e) {
System.err.println(e.getLocalizedMessage());
}
}
public static void main(String[] args){
HomeworkRequest app = new HomeworkRequest();
app.createHomeworkRequest();
}
}
If you look at step 1 of using the MTurk Java SDK, you need to include SDK Installation Directory]\\lib\\third-party
in your classpath
.如果您查看使用 MTurk Java SDK 的第 1 步,您需要在
classpath
包含SDK Installation Directory]\\lib\\third-party
。
Your inability to find third-party jars such as JaxB seems to suggest that your IDE is facing issues finding necessary jars to build.您无法找到诸如 JaxB 之类的第三方 jar 似乎表明您的 IDE 在寻找必要的 jar 来构建时遇到了问题。
Please let us know if you are still facing difficulties.如果您仍然面临困难,请告诉我们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.