为什么 Google Play 服务需要这些混淆规则
Why do I need these proguard rules for Google Play Services
我刚刚升级到最新的 google 播放服务 (11.6.0)。当我使用混淆器构建时,我现在收到这些警告:
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:
Note: 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.
根据 release notes for Google Play services 11.2.0:
When you upgrade your app’s Play services dependencies to 11.2.0 or later, your app’s build.gradle must also be updated to specify a compileSdkVersion of at least 26 (Android O). This does not change the way your app runs.
更新您的 compileSdkVersion
(请注意,您不需要同时更新您的 targetSdkVersion
- 这可以稍后完成)以便在 API 中添加的引用方法26,可以查到。
我刚刚升级到最新的 google 播放服务 (11.6.0)。当我使用混淆器构建时,我现在收到这些警告:
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:
Note: 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.
根据 release notes for Google Play services 11.2.0:
When you upgrade your app’s Play services dependencies to 11.2.0 or later, your app’s build.gradle must also be updated to specify a compileSdkVersion of at least 26 (Android O). This does not change the way your app runs.
更新您的 compileSdkVersion
(请注意,您不需要同时更新您的 targetSdkVersion
- 这可以稍后完成)以便在 API 中添加的引用方法26,可以查到。