可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
So it looks like there is a bug in the latest play-services to be deployed. Does anyone know how to work around this issue?
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':myappname:transformClassesWithAndroidGradleClassShrinkerForDevelopmentDebug'. > ProGuard configuration parser error: /Users/myusername/.gradle/caches/transforms-1/files-1.1/play-services-base-11.8.0.aar/d2ad9e16677fda9cf07a1280a66e91ca/proguard.txt line 3:88 no viable alternative at input ''
So more information. seems the problem is in the core module:
Error:Execution failed for task ':myappname:transformClassesWithAndroidGradleClassShrinkerForDevelopmentDebug'. > ProGuard configuration parser error: /Users/myusername/.gradle/caches/transforms-1/files-1.1/play-services-base-11.8.0.aar/d2ad9e16677fda9cf07a1280a66e91ca/proguard.txt line 3:88 no viable alternative at input ''
EDIT: The contents of the file that is causing that error is:
# b/35135904 Ensure that proguard will not strip the mResultGuardian. -keepclassmembers class com.google.android.gms.common.api.internal.BasePendingResult { com.google.android.gms.common.api.internal.BasePendingResult.ReleasableResultGuardian ; }
回答1:
It seems the default shrinker has changed. Adding the configuration to turn on ProGuard seemed to work.
buildTypes { release { debuggable false minifyEnabled true useProguard true ... } debug { debuggable true minifyEnabled true useProguard true ... } }
回答2:
In addition to the above solution (which works): the issue seems related to Instant Run as well. If you disable Instant Run, you can build your app without changing your build.gradle. Probably, the default shrinker has changed only when building for Instant Run.
回答3:
This solution helped me:
First, in app/build.gradle change useProguard to 'true'
Second, in proguard rules add line '-dontobfuscate'
buildTypes { release { debuggable false minifyEnabled true useProguard true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' ... } debug { debuggable true minifyEnabled true useProguard true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' ... } }
proguard-rules.pro
-dontobfuscate
So, minify would be work, but code wouldn't obfuscate.
回答4:
I am noticing that if you disable Instant Run the build still fails with the same error (if you have minify enabled but Proguard disabled to shrink your code to avoid multi-dex in the debug build). If you follow Brill Pappin answer you must enable Instant Run(and install libraries as prompted) to hit any breakpoints while debugging.
It seems enabling the shrinker as described in the Google docs now only works if you are using Instant Run with the Google Play Play Services.