我正在尝试将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
在代码中添加print之后,我发现导致上述错误的代码行是
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
发布于 2021-02-25 18:03:34
语音安卓3.2.0+
# Twilio Programmable Voice
-keep class com.twilio.** { *; }
-keep class tvo.webrtc.** { *; }
-dontwarn tvo.webrtc.**
-keep class com.twilio.voice.** { *; }
-keepattributes InnerClasses
这些规则可确保ProGuard不会删除可编程语音库。
https://stackoverflow.com/questions/66366100
复制相似问题