title: Android Studio using jars
body: <p>I'm new on Android Studio since I've used Eclipse till now. Now I'm trying to import two libraries (MPChartLib and datetimepicker-library) as a jar.</p>
  
  <p>The steps I did:<br>
  1. Create a folder called libraries<br>
  2. Drag and drop the jars to the folder<br>
  3. Right click on them --> Add to library (something like that)<br>
  (As I have seen on some tutorials)</p>
  
  <p>The system recognizes those jars and I am able to work with them. But when I want to run the project, I get the following error:</p>
  
  <pre><code>Information:Gradle tasks [:app:assembleDebug]
  :app:preBuild
  :app:compileDebugNdk UP-TO-DATE
  :app:preDebugBuild
  :app:checkDebugManifest
  :app:preReleaseBuild
  :app:prepareComAndroidSupportAppcompatV72100Library UP-TO-DATE
  :app:prepareComAndroidSupportGridlayoutV72100Library UP-TO-DATE
  :app:prepareComAndroidSupportMediarouterV72100Library UP-TO-DATE
  :app:prepareComAndroidSupportRecyclerviewV72100Library UP-TO-DATE
  :app:prepareComAndroidSupportSupportV42100Library UP-TO-DATE
  :app:prepareDebugDependencies
  :app:compileDebugAidl UP-TO-DATE
  :app:compileDebugRenderscript UP-TO-DATE
  :app:generateDebugBuildConfig UP-TO-DATE
  :app:generateDebugAssets UP-TO-DATE
  :app:mergeDebugAssets UP-TO-DATE
  :app:generateDebugResValues UP-TO-DATE
  :app:generateDebugResources UP-TO-DATE
  :app:mergeDebugResources UP-TO-DATE
  :app:processDebugManifest UP-TO-DATE
  :app:processDebugResources UP-TO-DATE
  :app:generateDebugSources UP-TO-DATE
  :app:compileDebugJava UP-TO-DATE
  :app:preDexDebug UP-TO-DATE
  :app:dexDebug UP-TO-DATE
  :app:processDebugJavaRes UP-TO-DATE
  :app:validateDebugSigning
  :app:packageDebug
  Error:duplicate files during packaging of APK   
  
  C:\Users\Markus\Documents\AndroidStudiosWORKSPACE\TestProject\app\build\outputs\apk\app-debug-    unaligned.apk
  Path in archive: res/values/colors.xml
  Origin 1:     C:\Users\Markus\Documents\AndroidStudiosWORKSPACE\TestProject\app\libraries\datetimepicker-library.jar
  Origin 2:     C:\Users\Markus\Documents\AndroidStudiosWORKSPACE\TestProject\app\libraries\MPChartLib.jar
  You can ignore those files in your build.gradle:
  android {
    packagingOptions {
      exclude 'res/values/colors.xml'
    }
  }
  Error:Execution failed for task ':app:packageDebug'.
  &gt; Duplicate files copied in APK res/values/colors.xml
  File 1:     C:\Users\Markus\Documents\AndroidStudiosWORKSPACE\TestProject\app\libraries\datetimepicker-library.jar
  File 2:     C:\Users\Markus\Documents\AndroidStudiosWORKSPACE\TestProject\app\libraries\datetimepicker-library.jar
  </code></pre>
  
  <p>It's not the first time I get this error, so I have searched for a solution for hours - vainly.<br>
  The following is my build.gradle where I have already excluded many files:</p>
  
  <pre><code> apply plugin: 'com.android.application'
  
      android {
      compileSdkVersion 21
      buildToolsVersion "20.0.0"
  
      packagingOptions {
          exclude 'AndroidManifest.xml'
          exclude 'bin/AndroidManifest.xml'
          exclude 'bin/R.txt'
          exclude 'bin/jarlist.cache'
          exclude 'build.gradle'
          exclude 'proguard-project.txt'
          exclude 'project.properties'
      }
  
      defaultConfig {
          applicationId "com.nomax.gymdiary"
          minSdkVersion 16
          targetSdkVersion 21
          versionCode 1
          versionName "1.0"
      }
      buildTypes {
          release {
              runProguard false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile 'com.android.support:support-v4:21.0.0'
      compile 'com.android.support:appcompat-v7:21.0.0'
      compile 'com.android.support:gridlayout-v7:21.0.0'
      compile 'com.android.support:mediarouter-v7:21.0.0'
      compile 'com.android.support:recyclerview-v7:21.0.0'
      compile files('libraries/datetimepicker-library.jar')
      compile files('libraries/MPChartLib.jar')
  }
  </code></pre>
  
  <p>I'm sure that I don't have to exclude those important files (which can be seen on latest error where I also have to exclude res/values/colors.xml)</p>
  
  <p>Greetings from Austria!</p>
  
  <p>PS: I have exported the libs from an android project from Eclipse to a jar file. Can this be the problem?</p>