当我尝试使用带有 minifyEnabled true
的 Android Studio
构建项目时,我遇到此错误 .
错误的详细信息
:app:transformClassesWithDexForDevDebug
Uncaught translation error: com.android.dx.cf.code.SimException: expected type int but found com.apptimize.hz
Uncaught translation error: com.android.dx.cf.code.SimException: expected type int but found com.apptimize.oa
2 errors; aborting
How can I resolve it?
UPDATE*
Proguard文件的内容 .
-optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontpreverify -verbose -optimizations!code / simplification / arithmetic,!field /,!class / merge / -dontwarn android.support . ** -dontwarn com.atinternet . ** -dontwarn org . apache . ** -keep public class * extends android.app.Activity -keep public class * extends android.app.Application -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class * extends android.app.backup.BackupAgentHelper -keep public class * extends android.preference.Preference -keep public class com.android.vending.licensing.ILicensingService -keepattributes InnerClasses - keepattributes Annotation -keepattributes Signature -keepclasseswithmembernames class * {native; -keepclasseswithmembers class * {public(android.content.Context,android.util.AttributeSet); -keepclasseswithmembers class * {public(android.content.Context,android.util.AttributeSet,int); -keepclassmembers class * extends android.app.Activity {public void (android.view.View); } -keepclassmembers枚举 {public static ** [] values(); public static ** valueOf(java.lang.String); -keep class 实现android.os.Parcelable {public static final android.os.Parcelable $ Creator ; } -dontwarn java.awt . ** -dontwarn CompatHoneycomb -keep class android.support.v4 . {; -keep class com.squareup.okhttp . ** {; } -dontwarn uk.co.senab.photoview . ** -keep class uk.co.senab.photoview . ** {*; }
我用 'com.android.tools.build:gradle:1.5.0'
Is there any problem with my proguard file?
2 回答
请参阅Compile with Proguard gives SimException: "local variable type mismatch"的plowman的回答
添加此项以禁用触发proguard错误的特定优化 .
为我工作 .
经过3到4天的详细探索后,我也面临同样的问题 . 问题出现在gradle版本和处理dex和类的方式 .
修复此问题
有两种情况
Case 1 : 由于android测试用例大量复杂的Mock和Instrumentation测试用例 . 对于测试用例要通过,我们必须禁用 minifyEnabled false ,这会禁用progaurd进程 testCoverageEnabled false . 如果enbale testCoverageEnabled为true导致此问题 . 对于测试用例应该通过你必须在调试模式下禁用progaurd并在testCoverageEnable中禁用false .
情况2:定义testProgurdFile并使minifyEnabled成为调试模式中的proguard .
Compile with Proguard gives SimException: "local variable type mismatch"定义testProgurdFile,如下所示,将用于测试,您可以在其中指定testFramework使用的测试progaurd规则 .
参考链接:
proguard gradle debug build but not the tests
https://code.google.com/p/android/issues/detail?id=159831
Android - gradle testProguardFile - what is its purpose relating to unit tests
What are list of tasks thats ConnectedAndroidTest executes?