[英]Cannot hear twilio voice call on bluetooth speaker issue in android
[英]Facing some error in implementing twilio programmable voice call in java android studio
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
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:122)
at com.twilio.base.Creator.create(Creator.java:45)
at com.systema.twilliovoicecalltest.MakePhoneCall.main(MakePhoneCall.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
implementation (group: "com.twilio.sdk", name: "twilio", version: "7.34.1")
{
exclude group: 'org.apache.httpcomponents' ,module:'httpclient'
exclude group: 'org.apache.httpcomponents' ,module:'httpcore'
}
implementation (group: "com.sparkjava", name: "spark-core", version: "2.7.1")
{
exclude group: 'org.apache.httpcomponents' ,module:'httpclient'
exclude group: 'org.apache.httpcomponents' ,module:'httpcore'
}
implementation (group: "org.slf4j", name: "slf4j-simple", version: "1.7.21")
{
exclude group: 'org.apache.httpcomponents' ,module:'httpclient'
exclude group: 'org.apache.httpcomponents' ,module:'httpcore'
}
>Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/ProtocolVersion
at com.twilio.http.TwilioRestClient$Builder.build(TwilioRestClient.java:102)
at com.twilio.Twilio.getRestClient(Twilio.java:122)
at com.twilio.base.Creator.create(Creator.java:45)
at com.systema.twilliovoicecalltest.MakePhoneCall.main(MakePhoneCall.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
Caused by: java.lang.ClassNotFoundException: org.apache.http.ProtocolVersion
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 9 more
這是我的Java代碼:
public static void main(String[] args) throws URISyntaxException {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
String from = "+18572632XXX";
String to = "+92**********";
Call call = Call.creator(new PhoneNumber(to), new PhoneNumber(from),
new URI("http://demo.twilio.com/docs/voice.xml")).create();
System.out.println(call.getSid());
}
我已經包含了所有必要的庫:
>implementation group: "com.twilio.sdk", name: "twilio", version: "7.34.1"</br>
>implementation group: "com.sparkjava", name: "spark-core", version: "2.7.1"</br>
>implementation group: "org.slf4j", name: "slf4j-simple", version: "1.7.21"</br>
由於我在這方面沒有太多經驗,請幫助
Twilio 開發人員布道者在這里。 正如您所注意到的,Android 在使用我們的 Java SDK 時會遇到問題,因為它的依賴項之一是用於 HTTP 的 Apache 庫。 您想要做的是使用我們的Android SDK進行調用。
您可以在此處查看如何使用它的示例,也可以通過快速入門了解整個過程。
在您的示例中,您使用的 Java SDK 是您的應用程序中的一個安全問題,因為它現在將您的帳戶憑據硬編碼到您的最終 APK 中。 我在這篇博文中解釋了為什么這不是一個好主意。
希望這對你有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.