android - 为什么我需要这些 proguard 规则用于 Google Play 服务

标签 android google-play-services

我刚刚升级到最新的 google play 服务 (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, 可以找到。

关于android - 为什么我需要这些 proguard 规则用于 Google Play 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47759558/

相关文章:

android - Android Studio-执行任务失败:app:dexDebug

android - 在使用 Google 登录后,在应用程序中获取生日

android - 无法解析 : com. google.android.gms :play-services-measurement:9. 6.1

Android - Proguard 和 Google Play 服务的应用程序导出错误

android - 修复旧 Android 版本的 PDFium 崩溃或包含自己的库

android - kapt/annotationProcessor 的 api 等价物是什么?

android - 在单击通知操作时隐藏来自前台服务的通知

在 Nexus S 上使用 native 相机应用程序无法保存 Android 图像

android - 更新到 Google Play Services 8.3 后无法解析 GoogleApiClient

安卓 M : Effect of Selective Permissions on Ads