0

Getting following error after "cordova build"

BUILD FAILED
/Users/mboeckle/Android/adt-bundle-mac-x86_64-20130219/sdk/tools/ant/build.xml:892: The following error occurred while executing this line:
/Users/mboeckle/Android/adt-bundle-mac-x86_64-20130219/sdk/tools/ant/build.xml:894: The following error occurred while executing this line:
/Users/mboeckle/Android/adt-bundle-mac-x86_64-20130219/sdk/tools/ant/build.xml:906: The following error occurred while executing this line:
/Users/mboeckle/Android/adt-bundle-mac-x86_64-20130219/sdk/tools/ant/build.xml:283: null returned: 2

Total time: 3 seconds
Error code 1 for command: ant with args: debug,-f,/Users/mboeckle/Desktop/fashionista/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /Users/mboeckle/Desktop/fashionista/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)

the error in build.xml appears in the following area:

<!-- Converts this project's .class files into .dex files -->
<target name="-dex" depends="-compile, -post-compile, -obfuscate">
    <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
        <!-- only convert to dalvik bytecode is *not* a library -->
        <do-only-if-not-library elseText="Library project: do not convert bytecode..." >
            <!-- special case for instrumented builds: need to use no-locals and need
                 to pass in the emma jar. -->
            <if condition="${build.is.instrumented}">
                <then>
                    <dex-helper nolocals="true">
                        <external-libs>
                            <fileset file="${emma.dir}/emma_device.jar" />
                        </external-libs>
                    </dex-helper>
                </then>
                <else>
                    <dex-helper />
                </else>
            </if>
        </do-only-if-not-library>
    </do-only-if-manifest-hasCode>
</target>

UPDATE:

-dex:
  [dex] input: /Users/mboeckle/Desktop/fashionista/platforms/android/ant-build/classes
  [dex] input: /Users/mboeckle/Desktop/fashionista/platforms/android/CordovaLib/ant-build/classes.jar
  [dex] input: /Users/mboeckle/Desktop/fashionista/platforms/android/libs/cordova-3.6.0-dev.jar
  [dex] Using Pre-Dexed classes-a6c0218dd60ae2a0a1a01e2e8cd6990f.jar <- /Users/mboeckle/Desktop/fashionista/platforms/android/CordovaLib/ant-build/classes.jar
  [dex] Using Pre-Dexed cordova-3.6.0-dev-c2a14019ea9cd5796f0714685a70533a.jar <- /Users/mboeckle/Desktop/fashionista/platforms/android/libs/cordova-3.6.0-dev.jar
  [dex] Found modified input file
  [dex] Converting compiled files and external libraries into /Users/mboeckle/Desktop/fashionista/platforms/android/ant-build/classes.dex...
   [dx] Merged dex A (7 defs/2.2KiB) with dex B (207 defs/313.8KiB). Result is 214 defs/385.0KiB. Took 0.3s
   [dx] 
   [dx] UNEXPECTED TOP-LEVEL EXCEPTION:
   [dx] com.android.dex.DexException: Multiple dex files define Lcom/squareup/okhttp/Address;
   [dx]     at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
   [dx]     at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
   [dx]     at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
   [dx]     at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
   [dx]     at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
   [dx]     at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
   [dx]     at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
   [dx]     at com.android.dx.command.dexer.Main.run(Main.java:230)
   [dx]     at com.android.dx.command.dexer.Main.main(Main.java:199)
   [dx]     at com.android.dx.command.Main.main(Main.java:103)
   [dx] 

any idea? Is there something wrong with the manifest? If I compile it in Eclipse it works fine.

best

M

mboeckle
  • 938
  • 13
  • 29
  • 1
    Usually the error log will show the (hint of or) cause of the failure in the failed task **before** the `BUILD FAILED` section. Anything there? – ivan.sim Aug 29 '14 at 17:51
  • 1
    So looks like this is the problem `[dx] com.android.dex.DexException: Multiple dex files define Lcom/squareup/okhttp/Address;` which means that the class is getting included in the APK twice. – ivan.sim Aug 29 '14 at 19:11
  • how I can include them twice? I just created a new project – mboeckle Aug 29 '14 at 19:25
  • Those guys on this [post](http://stackoverflow.com/q/7853460/1144203) discussed some ways to deal with this. Give it a try. – ivan.sim Aug 29 '14 at 19:45
  • thx got it - I somehow copied the .jar file into the /libs folder befor the build while I was following this tutorial: http://www.pycode.com/android/creating-a-phonegap-cordova-3.0-app-in-eclipse.html - thx for the help. – mboeckle Aug 29 '14 at 19:52

0 Answers0