issues sendgrid for email messaging

时间秒杀一切 提交于 2019-12-13 03:45:33

问题


I an using sendgrid for email messaging but get the error below. My code is below the error.

Error:  Caused by: java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; or its superclasses (declaration of 'org.apache.http.conn.ssl.AllowAllHostnameVerifier' appears in /system/framework/framework.jar:classes3.dex)
                          at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
                          at  

Email Messaging code:

Email from = new Email("zihronProjectManagementApp@gmail.com");

    String subject = "Sending with SendGrid is Fun";

    Email to = new Email("ayobami.o.idowu@gmail.com");

    Content content = new Content("text/plain", "and easy to do anywhere, even with Java");

    Mail mail = new Mail(from, subject, to, content);

    //Toast.makeText(getApplicationContext(),System.getenv('"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"),Toast.LENGTH_LONG).show();

    SendGrid sg = new SendGrid(System.getenv("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"));

    Request request = new Request();

    try {

        request.setMethod(Method.POST);

        request.setEndpoint("mail/send");

        request.setBody(mail.build());

        Response response = sg.api(request);

        System.out.println(response.getStatusCode());

        System.out.println(response.getBody());

        System.out.println(response.getHeaders());

    } catch (IOException ex) {


    }

I have tried every possible post on Stack Overflow. Please help me in what am I doing wrong?


回答1:


org.apache.http.conn.ssl.AllowAllHostnameVerifier

Above class has been removed API level 22

You should use HttpURLConnection class instead.



来源:https://stackoverflow.com/questions/52319046/issues-sendgrid-for-email-messaging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!