dar*_*mir 2 android proguard gradle
当我尝试在互联网上找到解决方案时,与我的案子没有太大关系
接下来的问题是,构建失败并出现错误:错误:未捕获的翻译错误:com.android.dx.cf.code.SimException:本地变量类型不匹配:尝试使用本地设置或访问类型为java.lang.Object的值类型为int的变量。这是忽略局部变量信息的.class转换工具的症状。
我有2个配置
buildTypes {
debug {
debuggable true
minifyEnabled true
signingConfig signingConfigs.defaultKey
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
debuggable false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Run Code Online (Sandbox Code Playgroud)
}
问题是,如果我关闭debug proguard(minifyEnabled为false),我会遇到构建问题
Error:Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type java.lang.Object using a local variable of type int. This is symptomatic of .class transformation tools that ignore local variable information.
Error:Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type int using a local variable of type android.util.SparseIntArray. This is symptomatic of .class transformation tools that ignore local variable information.
Run Code Online (Sandbox Code Playgroud)
启用Proguard后,Inta-Run被禁用
因此,即使我创建了一个单独的proguard文件(调试一个文件)并放入下一个文件,我也无法逾越这一点:-renamesourcefileattribute SourceFile -keepattributes SourceFile,LineNumberTable -dontobfuscate -dontoptimize -dontpreverify -ignorewarnings
得到相同的结果,尝试使用:multiDexEnabled是,但仍然没有成功在这种情况下,启用了proguard的情况下,我可以进行构建,正常地进行调试/发布以及除调试以外的所有工作(我需要很多东西)
这是我第二天遇到问题,无法解决,有人有类似问题吗?我该如何解决?
PS gradle与stacktrace和debug标志给我什么都没有用,所以没有帮助
如果我正确理解了您的问题,则仅在调试版本中禁用ProGuard时才遇到问题。
这表明您的从属jar之一尚未正确构建,并且包含无效的LocalVariableTable或LocalVariableTypeTable属性,从而导致出现错误,如问题所示。
启用ProGuard时看不到该问题的原因是,ProGuard将默认删除相关属性(除非您添加-keepattributes xxx配置)。
要解决此问题,您将需要确定引起该问题的jar,并获取正确的版本(通过使用ProGuard自行处理以删除LocalVariable表或获取正确构建的更新版本)。
有时问题是由于ProGuard已优化了广口瓶。已知一种特定的优化技术存在问题,应该对库禁用(-optimizations!code / allocation / variable)。
归档时间: |
|
查看次数: |
2666 次 |
最近记录: |