试图Android应用使用Madrill时java.lang.NoSuchMethodError [英] java.lang.NoSuchMethodError when trying to use Madrill in Android app
问题描述
我想从Android应用程序发送信息,并使用Madrill服务。我tryed从他们在GitHub库采取例如code上发送我的电子邮件的东西。但我得到的 java.lang.NoSuchMethodError
I want to send information from Android app and use Madrill service. I tryed to send something on my email by taking the example code from their repository on GitHub. But i get the java.lang.NoSuchMethodError:
08-04 15:18:09.684 1890-6152/com.kll.app1 W/dalvikvm﹕ threadid=11: thread exiting with uncaught exception (group=0xb3a74ba8)
08-04 15:18:09.694 1890-6152/com.kll.app1 E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-144
Process: com.s.a.kll.app1, PID: 1890
java.lang.NoSuchMethodError: org.apache.http.util.EntityUtils.consume
at com.microtripit.mandrillapp.lutung.model.MandrillRequestDispatcher.execute(MandrillRequestDispatcher.java:104)
at com.microtripit.mandrillapp.lutung.controller.MandrillUtil.query(MandrillUtil.java:46)
at com.microtripit.mandrillapp.lutung.controller.MandrillMessagesApi.send(MandrillMessagesApi.java:94)
at com.microtripit.mandrillapp.lutung.controller.MandrillMessagesApi.send(MandrillMessagesApi.java:49)
at com.s.a.kll.app1.Landing$NotificadorEmail.notificar(Landing.java:290)
at com.s.a.kll.app1.Landing$8$1.run(Landing.java:257)
at java.lang.Thread.run(Thread.java:841)
这是我的code:
It is my code:
public void run(){
MandrillApi mandrillApi = new MandrillApi("<put ur Mandrill API key here>");
// create your message
MandrillMessage message = new MandrillMessage();
message.setSubject("Hello World!");
message.setHtml("<h1>Hi pal!</h1><br />Really, I'm just saying hi!");
message.setAutoText(true);
message.setFromEmail("kitty@yourdomain.com");
message.setFromName("Kitty Katz");
// add recipients
ArrayList<MandrillMessage.Recipient> recipients = new ArrayList<MandrillMessage.Recipient>();
MandrillMessage.Recipient recipient = new MandrillMessage.Recipient();
recipient.setEmail("myMail@gmail.com");
recipient.setName("Claire Annette");
recipients.add(recipient);
recipient = new MandrillMessage.Recipient();
recipient.setEmail("Ma@gmail.com");
recipients.add(recipient);
message.setTo(recipients);
message.setPreserveRecipients(true);
ArrayList<String> tags = new ArrayList<String>();
tags.add("test");
tags.add("helloworld");
message.setTags(tags);
// ... add more message details if you want to!
// then ... send
try {
MandrillMessageStatus[] messageStatusReports = mandrillApi.messages().send(message, false);
} catch (MandrillApiError mandrillApiError) {
mandrillApiError.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Exeption是在这一行:
Exeption is in this line:
MandrillMessageStatus[] messageStatusReports = mandrillApi.messages().send(message, false);
从我在网上我发现搜索,那麻烦是,我已经添加了库的版本,我试图改变他们,但没有成功。这些都是从 build.grade 文件我的依赖关系:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile files('build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars/libs/gson-2.3.1.jar')
compile files('build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars/libs/lutung-0.0.5.jar')
compile files('build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars/libs/internal_impl-22.2.0.jar')
compile files('build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars/libs/httpcore-4.0.1.jar')
}
推荐答案
尝试直接的gradle中定义的依赖。通过这种方式,将取回正确的依赖关系:
Try to define the dependency directly in gradle. This way it will fetch the correct dependencies:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.mandrillapp.wrapper.lutung:lutung:0.0.5'
}
确认没有在库的任何重复的文件
目录(的HttpCore,GSON,乌叶猴属等)
Make sure there is not any duplicate file in the libs
directory (httpcore, gson, lutung, etc)
这篇关于试图Android应用使用Madrill时java.lang.NoSuchMethodError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!