赞
踩
文章出处:http://blog.csdn.net/shift_wwx
请转载的朋友标明出处~~
前言:为了这个问题找了好长时间,网上复制的太多,没什么解决的办法,弄了半天才搞定,分享出来。
今天创建了一个项目,在运行的时候死活都不行,一直报错:
- trouble writing output: Too many method references: 83462; max is 65536.
- You may try using --multi-dex option.
- References by package:
- 27 android
- 147 android.accessibilityservice
- 598 android.accounts
- 34 android.alsa
- 714 android.animation
- 11 android.annotation
- 5560 android.app
- 551 android.app.admin
- 411 android.app.backup
- 140 android.app.job
- 60 android.app.trust
- 89 android.app.usage
- 134 android.appwidget
- 1787 android.bluetooth
- 222 android.bluetooth.le
- 1886 android.content
- 1550 android.content.pm
- 568 android.content.res
- 532 android.database
- 498 android.database.sqlite
- 117 android.ddm
- 168 android.drm
- 30 android.emoji
- 23 android.filterfw
- 817 android.filterfw.core
- 26 android.filterfw.format
- 42 android.filterfw.geometry
- 46 android.filterfw.io
- 83 android.filterpacks.base
- 410 android.filterpacks.imageproc
- 6 android.filterpacks.numeric
- 17 android.filterpacks.performance
- 18 android.filterpacks.text
- 29 android.filterpacks.ui
- 18 android.filterpacks.videoproc
- 21 android.filterpacks.videosink
- 86 android.filterpacks.videosrc
- 223 android.gesture
- 1461 android.graphics
- 1404 android.graphics.drawable
- 40 android.graphics.drawable.shapes
- 107 android.graphics.pdf
- 532 android.hardware
- 277 android.hardware.camera2
- 19 android.hardware.camera2.dispatch
- 339 android.hardware.camera2.impl
- 469 android.hardware.camera2.legacy
- 25 android.hardware.camera2.marshal
- 213 android.hardware.camera2.marshal.impl
- 137 android.hardware.camera2.params
- 153 android.hardware.camera2.utils
- 247 android.hardware.display
- 443 android.hardware.hdmi
- 183 android.hardware.input

太多了,不贴了。
最后会提示:
Conversion to Dalvik format failed with error 2
从提示来看,是method太多了,这个我理解的,因为我从外面导入了一个jar 包。
这里有一些解释,还是很受用的。例如在项目中创建lib 目录的时候,千万不要叫libs,可以改成任何的,因为你会发现在Android private Libraries 里面直接默认包含libs这个目录里面的jars。
顺着这个方向继续找,最后找到了.classpath:
- <?xml version="1.0" encoding="UTF-8"?>
- <classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="lib" path="mylib/classes.jar"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
- <classpathentry kind="output" path="bin/classes"/>
- </classpath>
如果在build path里面选择order and export就会在.classpath中变成:
<classpathentry exported="true" kind="lib" path="mylib/classes.jar"/>
试着取消掉这些export ,clean之后编译应该就过了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。