Reputation: 1599
I'm trying to integrate TWILIO in my app using
implementation group: "com.twilio.sdk", name: "twilio", version: "8.7.0"
but am getting the following error
More than one file was found with OS independent path 'META-INF/DEPENDENCIES'.
Then after searching this error I found that it can be resolved by adding
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
After adding the app now built successfully. After running the app I got the following error
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
then to solve this error I added
-keep class org.apache.** { *; }
to the proguard-rules file
After running the code again I get the following error
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)
To which I'm not able to find a solution. Could someone please help me resolve these error to add TWILIO to my project?
Edit - 1
After adding print in the code I found out the line of code cause the above error is
Token token = Token.creator().create();
I'm trying to implement the following code
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());
}
}
from
https://www.twilio.com/docs/stun-turn
Upvotes: 0
Views: 558
Reputation: 118
Voice Android 3.2.0+
# Twilio Programmable Voice
-keep class com.twilio.** { *; }
-keep class tvo.webrtc.** { *; }
-dontwarn tvo.webrtc.**
-keep class com.twilio.voice.** { *; }
-keepattributes InnerClasses
These rules ensure that the Programmable Voice library is not removed by ProGuard.
https://www.twilio.com/docs/voice/voip-sdk/android
Upvotes: 1