google play services shows class not found after using proguard

强颜欢笑 提交于 2019-12-12 02:34:20

问题


Im using

compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-location:9.4.0'
compile 'com.google.android.gms:play-services-places:9.4.0'
compile 'com.google.android.gms:play-services-analytics:9.4.0'

The official docs says:

ProGuard directives are included in the Play services client libraries to preserve the required classes. The Android Plugin for Gradle automatically appends ProGuard configuration files in an AAR (Android ARchive) package and appends that package to your ProGuard configuration. During project creation, Android Studio automatically creates the ProGuard configuration files and build.gradle properties for ProGuard use. To use ProGuard with Android Studio, you must enable the ProGuard setting in your build.gradle buildTypes. For more information, see the ProGuard guide.

However, on using proguard without keeping any classes from play services I get the following exception:

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.location.places.ui.SupportPlaceAutocompleteFragment"

Then I was able to solve this problem by adding:

-keep class com.google.android.gms.** { *; }

It works perfectly but unfortunately the apk size has now increased by 1MB. It's not just about SupportPlaceAutocompleteFragment, if I use those libraries without keeping their classes even GCM and getLocation features stop working.

I feel I am doing something wrong because the official docs insist on not adding proguard rules for play services. Please help.

来源:https://stackoverflow.com/questions/39212383/google-play-services-shows-class-not-found-after-using-proguard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!