weibo sdk Multiple dex files define Lcom/sina/weibo/sdk/BuildConfig

集成新浪微博SDK,用gradle编译时,报如下错误:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/sina/weibo/sdk/BuildConfig;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)

原因是weibosdkcore.jar里面的BuildConfig.class,本来这个文件不应该存在于jar里,不知微博的开发怎么搞进去的。
解决方法很简单:解包weibosdkcore.jar,删除里面的 BuildConfig.class,然后重新打包 jar。


具体如下:
1. 解压jar包:
    jar xf weibosdkcore.jar
2. 删除解压后目录里面的com/sina/weibo/sdk/BuildConfig.class
3. 重新打包:
    jar cvf weibosdkcore.jar *

你可能感兴趣的:(android,新浪微博)