0

MY codes for twilio integration is as followed

try {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
    Message message = Message.creator(new com.twilio.type.PhoneNumber("whatsapp:+918002XXXXX"),
                                      new com.twilio.type.PhoneNumber("whatsapp:+1415XXXXXXx"),
                                      "Your appointment is coming up on {{July 21}} at {{3PM}}")
                                      .create();
    System.out.println(message.getSid());
    }
catch (Exception e){
    Toast.makeText(getApplicationContext(), "the error message is"+e, Toast.LENGTH_LONG).show();
}

The dependencies used by me is as followed

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile group: "com.twilio.sdk", name: "twilio", version: "7.24.2"
implementation 'com.android.support:multidex:1.0.3'
}

The error I am getting is this

E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.gsr.schoolreport, PID: 18267
              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!classes2.dex)
                  at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
                  at org.apache.http.conn.ssl.SSLConnectionSocketFactory.getSocketFactory(SSLConnectionSocketFactory.java:172)
                  at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.getDefaultRegistry(PoolingHttpClientConnectionManager.java:109)
                  at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:116)
                  at com.twilio.http.NetworkHttpClient.<init>(NetworkHttpClient.java:58)
                  at com.twilio.http.TwilioRestClient$Builder.build(TwilioRestClient.java:102)
                  at com.twilio.Twilio.getRestClient(Twilio.java:129)
                  at com.twilio.base.Creator.create(Creator.java:45)
                  at com.gsr.schoolreport.EditData$3$1.onComplete(EditData.java:236)
                  at com.google.android.gms.tasks.zzf.run(Unknown Source:23)
                  at android.os.Handler.handleCallback(Handler.java:790)
                  at android.os.Handler.dispatchMessage(Handler.java:99)
                  at android.os.Looper.loop(Looper.java:164)
                  at android.app.ActivityThread.main(ActivityThread.java:6494)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Application terminated. Please help me,facing this issue for last one month

Jacob Celestine
  • 1,758
  • 13
  • 23
Tanuj Raj
  • 1
  • 1

1 Answers1

0

Twilio developer evangelist here.

Seems like what you're trying to do is the Twilio Java Helper Library which is not supported by Android as it uses Apache Commons. What you want to use with Android is one of the Android SDKs though we only have one for Voice, Chat (not WhatsApp) and Video.

So if you wanted to integrate WhatsApp to your android app, I suggest you create a backend using any of your favourite backend programming languages and have your application make an HTTP request to that.

You will end up with the same functionality, but your code won't have any credentials embedded on it.

Have a look at this article I wrote in the past that explains how to do that with SMS, so you just need to change it to use WhatsApp.

Marcos Placona
  • 21,468
  • 11
  • 68
  • 93