【发布时间】:2021-02-25 09:46:18
【问题描述】:
我正在尝试将 TWILIO 集成到我的应用中使用
implementation group: "com.twilio.sdk", name: "twilio", version: "8.7.0"
但出现以下错误
More than one file was found with OS independent path 'META-INF/DEPENDENCIES'.
然后搜索了这个错误发现可以通过添加解决
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
添加应用后现在构建成功。运行应用程序后出现以下错误
Caused by: j.a.a.b.b: java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'org.apache.commons.logging.impl.LogFactoryImpl' cannot be converted to 'org.apache.commons.logging.LogFactory'. Please check the custom implementation
然后为了解决这个错误我添加了
-keep class org.apache.** { *; }
到 proguard-rules 文件
再次运行代码后出现以下错误
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)
我无法找到解决方案。有人可以帮我解决这些错误以将 TWILIO 添加到我的项目中吗?
编辑 - 1
在代码中添加打印后,我发现导致上述错误的代码行是
Token token = Token.creator().create();
我正在尝试实现以下代码
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Token;
public class Example {
// Find your Account Sid and Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
Token token = Token.creator().create();
System.out.println(token.getUsername());
}
}
来自
https://www.twilio.com/docs/stun-turn
【问题讨论】:
标签: android android-studio twilio twilio-api