Android GCM在启用proguard的情况下不工作

Android GCM在启用proguard的情况下不工作,android,google-cloud-messaging,android-proguard,Android,Google Cloud Messaging,Android Proguard,我正在开发一个应用程序,它使用GCM从服务器接收推送通知。当proguard被禁用(minify false)时,它工作正常,但当我在启用minify的情况下进行发布构建时,它不再接收推送。 我在proguard-rules.pro中添加了一些规则,但它们仍然没有改变任何东西。 这是我的proguard-rules.pro # Add project specific ProGuard rules here. # By default, the flags in this file are ap

我正在开发一个应用程序,它使用GCM从服务器接收推送通知。当proguard被禁用(minify false)时,它工作正常,但当我在启用minify的情况下进行发布构建时,它不再接收推送。 我在proguard-rules.pro中添加了一些规则,但它们仍然没有改变任何东西。 这是我的proguard-rules.pro

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/polbins/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

# Retrofit 2
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-dontwarn okio.**

# SL4J for Android
-dontwarn javax.mail.**
-dontwarn javax.naming.Context
-dontwarn javax.naming.InitialContext

# View Pager Indicator
-dontwarn com.viewpagerindicator.**

# Bubbl Models
-keep class tech.bubbl.sdk.rest.models.** { *; }

# Needed to keep generic types and @Key annotations accessed via reflection

-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault

-keepclassmembers class * {
  @com.google.api.client.util.Key <fields>;
}

# Needed by google-http-client-android when linking against an older platform version

-dontwarn com.google.api.client.extensions.android.**

# Needed by google-api-client-android when linking against an older platform version

-dontwarn com.google.api.client.googleapis.extensions.android.**

# Needed by google-play-services when linking against an older platform version

-dontwarn com.google.android.gms.**
-dontnote com.google.android.gms.**

# com.google.client.util.IOUtils references java.nio.file.Files when on Java 7+
-dontnote java.nio.file.Files, java.nio.file.Path

# Suppress notes on LicensingServices
-dontnote **.ILicensingService

# Suppress warnings on sun.misc.Unsafe
-dontnote sun.misc.Unsafe
-dontwarn sun.misc.Unsafe
#在此处添加特定于项目的程序规则。
#默认情况下,此文件中的标志附加到指定的标志
#在/Users/polbins/Library/Android/sdk/tools/proguard/proguard-Android.txt中
#您可以通过更改文件来编辑包含路径和顺序
#build.gradle中的指令。
#
#有关详细信息,请参阅
#   http://developer.android.com/guide/developing/tools/proguard.html
#在此处添加任何特定于项目的保留选项:
#如果您的项目使用带JS的WebView,请取消注释以下内容
#并为JavaScript接口指定完全限定的类名
#类别:
#-keepclassmembers类fqcn.of.javascript.interface.for.webview{
#公众*;
#}
#改装2
-dontwarn 2**
-保持类2.*{*;}
-保留署名
-保留特例
-唐特沃恩·奥基奥**
#适用于Android的SL4J
-dontwarn javax.mail**
-dontwarn javax.naming.Context
-dontwarn javax.naming.InitialContext
#查看寻呼机指示器
-dontwarn com.viewpagerindicator**
#泡泡模型
-保留类tech.bubbl.sdk.rest.models.*{*;}
#需要保持通过反射访问泛型类型和@Key注释
-KeepAttribute签名、运行时VisibleAnnotations、AnnotationDefault
-keepclassmembers类*{
@com.google.api.client.util.Key;
}
#谷歌http客户端android在与旧平台版本链接时需要
-dontwarn com.google.api.client.extensions.android**
#谷歌api客户端android在与旧平台版本链接时需要
-dontwarn com.google.api.client.googleapis.extensions.android**
#google play服务在与旧平台版本链接时需要
-dontwarn com.google.android.gms**
-dontnote com.google.android.gms**
#在java 7上,com.google.client.util.IOUtils引用java.nio.file.Files+
-dontnote java.nio.file.Files,java.nio.file.Path
#抑制有关许可证服务的说明
-请不要注意**。爱力新服务
#抑制sun.misc.Unsafe上的警告
-dontnote sun.misc
-dontwarn sun.misc

我错过了什么规则吗?或者是什么原因导致了这种情况?

它是否会给您带来任何异常?不,我只是没有收到推送。如果您使用的是Android Studio,您可能想检查一下,以了解应该如何启用收缩功能,以及如何指定在构建过程中保留或丢弃哪些代码和资源。看看你是否错过了一些给定的注释或规则。此外,如本文所述,要在Android Studio中使用ProGuard,您必须在
build.gradle buildTypes
中启用ProGuard设置。您还可以检查此设置,看看它是否对您有帮助。帮助不大。我想我需要一些关于GCM库的特定规则,但我发现这些规则不起作用,