当前位置:   article > 正文

Conversion to Dalvik format failed with error 2

conversion to dalvik format failed with error 2

文章出处:http://blog.csdn.net/shift_wwx

请转载的朋友标明出处~~


前言:为了这个问题找了好长时间,网上复制的太多,没什么解决的办法,弄了半天才搞定,分享出来。


今天创建了一个项目,在运行的时候死活都不行,一直报错:

  1. trouble writing output: Too many method references: 83462; max is 65536.
  2. You may try using --multi-dex option.
  3. References by package:
  4. 27 android
  5. 147 android.accessibilityservice
  6. 598 android.accounts
  7. 34 android.alsa
  8. 714 android.animation
  9. 11 android.annotation
  10. 5560 android.app
  11. 551 android.app.admin
  12. 411 android.app.backup
  13. 140 android.app.job
  14. 60 android.app.trust
  15. 89 android.app.usage
  16. 134 android.appwidget
  17. 1787 android.bluetooth
  18. 222 android.bluetooth.le
  19. 1886 android.content
  20. 1550 android.content.pm
  21. 568 android.content.res
  22. 532 android.database
  23. 498 android.database.sqlite
  24. 117 android.ddm
  25. 168 android.drm
  26. 30 android.emoji
  27. 23 android.filterfw
  28. 817 android.filterfw.core
  29. 26 android.filterfw.format
  30. 42 android.filterfw.geometry
  31. 46 android.filterfw.io
  32. 83 android.filterpacks.base
  33. 410 android.filterpacks.imageproc
  34. 6 android.filterpacks.numeric
  35. 17 android.filterpacks.performance
  36. 18 android.filterpacks.text
  37. 29 android.filterpacks.ui
  38. 18 android.filterpacks.videoproc
  39. 21 android.filterpacks.videosink
  40. 86 android.filterpacks.videosrc
  41. 223 android.gesture
  42. 1461 android.graphics
  43. 1404 android.graphics.drawable
  44. 40 android.graphics.drawable.shapes
  45. 107 android.graphics.pdf
  46. 532 android.hardware
  47. 277 android.hardware.camera2
  48. 19 android.hardware.camera2.dispatch
  49. 339 android.hardware.camera2.impl
  50. 469 android.hardware.camera2.legacy
  51. 25 android.hardware.camera2.marshal
  52. 213 android.hardware.camera2.marshal.impl
  53. 137 android.hardware.camera2.params
  54. 153 android.hardware.camera2.utils
  55. 247 android.hardware.display
  56. 443 android.hardware.hdmi
  57. 183 android.hardware.input

太多了,不贴了。

最后会提示:

Conversion to Dalvik format failed with error 2

从提示来看,是method太多了,这个我理解的,因为我从外面导入了一个jar 包。

http://stackoverflow.com/questions/15200286/android-error-conversion-to-dalvik-format-failed-with-error-2

这里有一些解释,还是很受用的。例如在项目中创建lib 目录的时候,千万不要叫libs,可以改成任何的,因为你会发现在Android private Libraries 里面直接默认包含libs这个目录里面的jars。


顺着这个方向继续找,最后找到了.classpath:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <classpath>
  3. <classpathentry kind="src" path="src"/>
  4. <classpathentry kind="src" path="gen"/>
  5. <classpathentry kind="lib" path="mylib/classes.jar"/>
  6. <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
  7. <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
  8. <classpathentry kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
  9. <classpathentry kind="output" path="bin/classes"/>
  10. </classpath>
如果在build path里面选择order and export就会在.classpath中变成:

<classpathentry exported="true" kind="lib" path="mylib/classes.jar"/>

试着取消掉这些export ,clean之后编译应该就过了。






声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/945138
推荐阅读
相关标签
  

闽ICP备14008679号