java - Android Gradle build fails due to Multiple dex files -


i had android gradle project number of external dependencies. @ point of time have decided extract functionality separate library dependencies, have packaged using maven-assembly-plugin. including newly created library dependency + remove of dependencies bundled in library.

the problem is, while building getting error, not understand:

unexpected top-level exception: com.android.dex.dexexception: multiple dex files define lcom/squareup/okhttp/address;     @ com.android.dx.merge.dexmerger.readsortabletypes(dexmerger.java:594)     @ com.android.dx.merge.dexmerger.getsortedtypes(dexmerger.java:552)     @ com.android.dx.merge.dexmerger.mergeclassdefs(dexmerger.java:533)     @ com.android.dx.merge.dexmerger.mergedexes(dexmerger.java:170)     @ com.android.dx.merge.dexmerger.merge(dexmerger.java:188)     @ com.android.dx.command.dexer.main.mergelibrarydexbuffers(main.java:439)     @ com.android.dx.command.dexer.main.runmonodex(main.java:287)     @ com.android.dx.command.dexer.main.run(main.java:230)     @ com.android.dx.command.dexer.main.main(main.java:199)     @ com.android.dx.command.main.main(main.java:103) 

this 1 of dependencies (okhttp) included directly , right packaged new library. library have created can found here.

here build files:

android app build config:

buildscript {     repositories {         mavencentral()     }     dependencies {         classpath 'com.android.tools.build:gradle:0.7.+'     } } apply plugin: 'android'  repositories {     mavencentral()     mavenrepo urls: "https://github.com/mkorszun/okrest/raw/master/repo" }  android {     compilesdkversion 15     buildtoolsversion "19.0.2"      defaultconfig {         minsdkversion 8         targetsdkversion 15     }      packagingoptions {         exclude 'meta-inf/license.txt'     }  }  dependencies {     compile 'com.android.support:appcompat-v7:19.0.1' //    compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.11' //    compile 'com.sun.jersey:jersey-client:1.8' //    compile 'com.sun.jersey:jersey-core:1.8' //    compile 'com.squareup.okhttp:okhttp:1.2.1' //    compile 'com.google.guava:guava:15.0'     compile 'com.google.android.gms:play-services:4.0.30'     compile files('libs/graphview-3.0.jar')     compile 'com.okrest:okrest:0.0.3' } 

library build config:

<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"          xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">     <modelversion>4.0.0</modelversion>      <groupid>com.okrest</groupid>     <artifactid>okrest</artifactid>     <version>0.0.3</version>     <packaging>jar</packaging>      <properties>         <project.build.sourceencoding>utf-8</project.build.sourceencoding>         <project.reporting.outputencoding>utf-8</project.reporting.outputencoding>     </properties>      <distributionmanagement>         <repository>             <id>local.repo</id>             <name>internal repository</name>             <url>file://repo</url>         </repository>     </distributionmanagement>      <dependencies>          <dependency>             <groupid>org.codehaus.jackson</groupid>             <artifactid>jackson-mapper-asl</artifactid>             <version>1.9.13</version>         </dependency>          <dependency>             <groupid>com.sun.jersey</groupid>             <artifactid>jersey-client</artifactid>             <version>1.18.1</version>         </dependency>          <dependency>             <groupid>com.squareup.okhttp</groupid>             <artifactid>okhttp</artifactid>             <version>1.5.0</version>         </dependency>          <dependency>             <groupid>junit</groupid>             <artifactid>junit</artifactid>             <version>4.11</version>             <scope>test</scope>         </dependency>          <dependency>             <groupid>com.github.rest-driver</groupid>             <artifactid>rest-client-driver</artifactid>             <version>1.1.37</version>             <scope>test</scope>         </dependency>          <dependency>             <groupid>com.googlecode.json-simple</groupid>             <artifactid>json-simple</artifactid>             <version>1.1.1</version>             <scope>test</scope>         </dependency>      </dependencies>      <build>         <plugins>              <plugin>                 <groupid>org.apache.maven.plugins</groupid>                 <artifactid>maven-compiler-plugin</artifactid>                 <version>3.1</version>                 <configuration>                     <source>1.7</source>                     <target>1.7</target>                 </configuration>             </plugin>              <plugin>                 <artifactid>maven-assembly-plugin</artifactid>                 <version>2.4</version>                 <configuration>                     <appendassemblyid>false</appendassemblyid>                     <descriptorrefs>                         <descriptorref>jar-with-dependencies</descriptorref>                     </descriptorrefs>                 </configuration>                 <executions>                     <execution>                         <id>make-assembly</id>                         <phase>package</phase>                         <goals>                             <goal>single</goal>                         </goals>                     </execution>                 </executions>             </plugin>              <plugin>                 <groupid>org.codehaus.mojo</groupid>                 <artifactid>cobertura-maven-plugin</artifactid>                 <version>2.6</version>                 <configuration>                     <format>xml</format>                     <maxmem>256m</maxmem>                     <aggregate>true</aggregate>                     <check/>                 </configuration>             </plugin>              <plugin>                 <groupid>org.eluder.coveralls</groupid>                 <artifactid>coveralls-maven-plugin</artifactid>                 <version>2.1.0</version>             </plugin>          </plugins>     </build>      <reporting>         <plugins>             <plugin>                 <groupid>org.codehaus.mojo</groupid>                 <artifactid>cobertura-maven-plugin</artifactid>                 <version>2.6</version>             </plugin>         </plugins>     </reporting>  </project> 

and here dependency tree android app:

+--- com.android.support:appcompat-v7:19.0.1 |    \--- com.android.support:support-v4:19.0.1 +--- com.google.android.gms:play-services:4.0.30 |    \--- com.android.support:support-v4:13.0.0 -> 19.0.1 \--- com.okrest:okrest:0.0.3      +--- org.codehaus.jackson:jackson-mapper-asl:1.9.13      |    \--- org.codehaus.jackson:jackson-core-asl:1.9.13      +--- com.sun.jersey:jersey-client:1.18.1      \--- com.squareup.okhttp:okhttp:1.5.0 

what means that class getting included in apk twice, isn't allowed. must have 2 dependency paths library. examine them , remove redundant one. if you're having trouble finding it, attach build files question.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -