问题

项目工程中,引用了一个第三方的SDK,它的jar包是已经混淆过的。在IDE下代码编译没问题,但是运行在手机上就报错。

Error:Execution failed for task ‘:app:shrinkDebugMultiDexComponents’.
java.io.IOException: Can’t read [src\app\build\intermediates\multi-dex\debug\allclasses.jar] (Can’t process class [com/dvrcam/DvrCamSDK/a$d.class] (Unknown verification type [255] in stack map frame))

大致意思是jar包目录com/dvrcam/DvrCamSDK/a/下的内部类d.class混淆失败。

解决方案

在工程的根目录下创建一个文件夹proguard,放入proguard.jar文件,下载地址:proguard.jar

Android引入第三方SDK混淆报错shrinkDebugMultiDexComponents的解决方案_第1张图片

在根目录的build.gradle文件中加入
flatDir { dirs ‘proguard’ }classpath ‘proguard.io:proguard:5.2.1’

// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript {    repositories {        flatDir { dirs 'proguard' }//1.依赖库类目录        jcenter()    }    dependencies {        classpath 'com.android.tools.build:gradle:1.2.3'        classpath 'proguard.io:proguard:5.2.1'//2.依赖的库类    }}allprojects {    repositories {        jcenter()    }}

按照以上步骤操作,就能运行成功!

更多相关文章

  1. Android 一套完整的 Socket 解决方案
  2. android如何在xml中引用内部类
  3. Toast 在android 4.0中问题解决方案
  4. android去掉titlebar的最优解决方案

随机推荐

  1. 疯狂Android讲义
  2. Android XML解析
  3. 知乎3000多人关注!27w+阅读开发者进阶难题
  4. Android新增一个音频类型及双音频输出的
  5. Objective C - 与Android交互时高低位转
  6. android 学习示例
  7. 集成Android免费语音合成功能(在线、离线
  8. Android上 PeerConnection 与 PeerConnec
  9. eclipse如何进行真机调试
  10. 【Android】TypedArray和obtainStyledAtt