1

Hi I am trying to develop a Twilio SMS sending app and I have added all these things to build.gradle.This is my gradle.During app runing,I am getting

`Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/org.apache.httpcomponents/httpcore/pom.xml File1: I:\AS_Projects\Tacos\app\libs\twilio-java-sdk-3.8.0-jar-with-dependencies.jar File2: I:\AS_Projects\Tacos\app\libs\httpcore-4.4.4.jar`

//I am getting this every time

'apply plugin: 'com.android.application'

android {

packagingOptions {
    exclude 'META-INF/NOTICE' // will not include NOTICE file
    exclude 'META-INF/LICENSE' // will not include LICENSE file
}


compileSdkVersion 23
buildToolsVersion '23.0.3'

defaultConfig {
    applicationId "com.twilio.client.quickstart"
    minSdkVersion 9
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}

defaultConfig {
    applicationId "android.revengine.com.tacos"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}

packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
}


buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
productFlavors {
}

}

dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.3.0' compile 'com.android.support:design:23.3.0' compile files('libs/httpclient-4.5.2.jar') compile files('libs/httpcore-4.4.4.jar') compile files('libs/httpmime-4.5.2.jar') compile files('libs/twilio-client-android.jar') compile files('libs/twilio-java-sdk-3.8.0-jar-with-dependencies.jar') }

hemen
  • 1,460
  • 2
  • 16
  • 35

2 Answers2

0

Do you need full SDK for your project? If you just need to send SMS there is REST API for that.

McOffsky
  • 205
  • 3
  • 11
0

Twilio developer evangelist here.

Your issue is that you're adding the Java library to try to send SMS messages, and that library is known to conflict with the version of Apache Android uses. That is a problem that lies neither on the Android platform nor on the Java library, as it's not built to be used with Android but with Java projects.

An aside problem to all that is the fact that even if you did a workaround (like this other developer did but we seriously not recommend) to make the Java library work with Android, you would be putting your Twilio's account security into jeopardy.

That is because It is not recommended to embed your Account SID and Auth Token within an application as an attacker could decompile the application, extract your credentials and use your Twilio account for anything they liked.

We recommend creating a web application that implements the Twilio REST API, wraps up your credentials sends SMS messages for you. Then you can call your web application from your Android application and send SMS without distributing your credentials.

Check out the tutorials section of Twilio.com to see how to build the server side component here. This tutorial on SMS notifications might be a good start.

Hope this helps you out, but do not hesitate in coming back if you still have any questions.

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