为什么我需要这些针对Google Play服务的proguard规则

时间:2017-12-11 18:56:26

标签: android google-play-services

我刚刚升级到最新的Google Play服务(11.6.0)。当我用proguard构建时,我现在得到这些警告:

Warning: com.google.android.gms.gcm.zza: can't find referenced method 'android.app.NotificationChannel getNotificationChannel(java.lang.String)' in library class android.app.NotificationManager
Warning: com.google.android.gms.gcm.zza: can't find referenced class android.app.NotificationChannel
Warning: com.google.android.gms.gcm.zza: can't find referenced class android.app.NotificationChannel
Warning: com.google.android.gms.gcm.zza: can't find referenced method 'void createNotificationChannel(android.app.NotificationChannel)' in library class android.app.NotificationManager
Warning: com.google.android.gms.gcm.zza: can't find referenced method 'android.app.Notification$Builder setChannelId(java.lang.String)' in library class android.app.Notification$Builder
Warning: com.google.android.gms.internal.zzbga: can't find referenced method 'boolean isInstantApp()' in library class android.content.pm.PackageManager
Warning: com.google.android.gms.internal.zzbgb: can't find referenced method 'boolean isInstantApp(java.lang.String)' in library class android.content.pm.PackageManager

为什么我会看到这个?我认为GMS处理了它自己的Proguard规则。来自文档link

  

注意:ProGuard指令包含在Play服务客户端中   库以保留所需的类。 Android插件   Gradle会自动将ProGuard配置文件附加到AAR中   (Android ARchive)包并将该包附加到您的ProGuard   组态。在项目创建期间,Android Studio会自动生成   创建ProGuard配置文件和build.gradle属性   用于ProGuard。要在Android Studio中使用ProGuard,您必须启用   build.gradle buildTypes中的ProGuard设置。更多   有关信息,请参阅ProGuard指南。

1 个答案:

答案 0 :(得分:9)

根据release notes for Google Play services 11.2.0

  

将应用程序的Play服务依赖项升级到11.2.0或更高版本时,还必须更新应用程序的build.gradle,以指定至少为26(Android O)的compileSdkVersion。这不会改变您的应用运行方式。

更新您的compileSdkVersion(请注意,您无需同时更新targetSdkVersion - 可以在以后完成),以便找到API 26中添加的引用方法。