Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/201.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 启用proguard和minification后,通知在发布模式下不起作用_Android_Notifications_Proguard - Fatal编程技术网

Android 启用proguard和minification后,通知在发布模式下不起作用

Android 启用proguard和minification后,通知在发布模式下不起作用,android,notifications,proguard,Android,Notifications,Proguard,我的通知在调试模式下工作正常。但只要minifyenabled为真,我就不会收到任何发布/签名apk的通知。我已经添加了所有可能的解决方案。还添加了firebase规则。下面是我的proguard规则文件。我的Android studio版本3.4.2和firebase消息传递版本是19.0.1 proguard rules.pro #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *;

我的通知在调试模式下工作正常。但只要minifyenabled为真,我就不会收到任何发布/签名apk的通知。我已经添加了所有可能的解决方案。还添加了firebase规则。下面是我的proguard规则文件。我的Android studio版本3.4.2和firebase消息传递版本是19.0.1

proguard rules.pro

#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#remove logs
-assumenosideeffects class android.util.Log{
  public static boolean isLoggable(java.lang.String, int);
  public static int v(...);
  public static int i(...);
  public static int w(...);
  public static int d(...);
  public static int e(...);
  public static int wtf(...);
}

#Eventbus
-keepattributes *Annotation*
-keepclassmembers class * {
    @org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }

# Only required if you use AsyncExecutor
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
    <init>(java.lang.Throwable);
}

#Retrofit
# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions

# OkHttp
-keepattributes *Annotation*
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase

# OkHttp platform used only on JVM and when Conscrypt dependency is available.
-dontwarn okhttp3.internal.platform.ConscryptPlatform

# Proguard Configuration for Realm (http://realm.io)
# For detailed discussion see: https://groups.google.com/forum/#!topic/realm-java/umqKCc50JGU
# Additionally you need to keep your Realm Model classes as well
# For example:

-keepattributes directive
#Glide
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}
# Uncomment for DexGuard only
#-keepresourcexmlelements manifest/application/meta-data@value=GlideModule


##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
-keepattributes InnerClasses
# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }

# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

##---------------End: proguard configuration for Gson  ----------
#dagger 2
-dontwarn com.google.errorprone.annotations.**

#kotlin
-keep class kotlin.Metadata { *; }
-keepclassmembers public class com.mypackage.** {
    public synthetic <methods>;
}
-keep class kotlinx.android.synthetic.**
-keepclassmembers class android.support.design.internal.BottomNavigationMenuView {
    boolean mShiftingMode;
}

#Realm
-keep @interface io.realm.annotations.RealmModule { *; }
-keep class io.realm.annotations.RealmModule { *; }


# please KEEP ALL THE NAMES
-keepnames class ** { *; }
-keep class com.mypackage.model.** { *; }

-keepclassmembers public class com.mypackage.** {
    public synthetic <methods>;
}
#FCM
-keep class com.google.firebase.** { *; }

-keepclassmembers class com.mypackage.model.** { *;}
-ignorewarnings

-dontwarn

# JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**



# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*

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

-keep class android.support.v4.app.NotificationCompat { *; }

-keep class android.support.v4.app.NotificationCompat$* { *; }

-keep class android.support.v4.app.NotificationManagerCompat { *; }

-dontnote com.google.**
#-keepclassmembers类fqcn.of.javascript.interface.for.webview{
#公众*;
#}
#取消对此的注释以保留行号信息
#调试堆栈跟踪。
#-keepattributes源文件,LineNumberTable
#如果保留行号信息,请将其取消注释为
#隐藏原始源文件名。
#-重命名SourceFileAttribute源文件
#删除日志
-assumenosideeffects类android.util.Log{
公共静态布尔isLoggable(java.lang.String,int);
公共静态INTV(…);
公共静态int i(…);
公共静态int w(…);
公共静态int d(…);
公共静态INTE(…);
公共静态int wtf(…);
}
#事件总线
-keepattributes*注释*
-keepclassmembers类*{
@org.greenrobot.eventbus.Subscribe;
}
-保持枚举org.greenrobot.eventbus.ThreadMode{*;}
#仅当使用AsyncExecutor时才需要
-keepclassmembers类*扩展org.greenrobot.eventbus.util.ThrowableFailureEvent{
(java.lang.Throwable);
}
#改造
#平台对Android上不存在的类型调用Class.forName以确定平台。
-dontnote 2.站台
#在Java 8虚拟机上运行时使用的平台。将不会在运行时使用。
-dontwarn 2.Platform$Java8
#保留泛型类型信息以供转换器和适配器反射使用。
-保留署名
#保留声明的已检查异常以供代理实例使用。
-保留特例
#OkHttp
-keepattributes*注释*
-保持类com.squareup.okhttp.*{*;}
-保持接口com.squareup.okhttp.*{*;}
-dontwarn com.squareup.okhttp**
-keepnames类okhttp3.internal.publicsuffix.PublicSuffixDatabase
#OkHttp平台仅在JVM上和Conscrypt依赖项可用时使用。
-dontwarn okhttp3.internal.platform.ConscryptPlatform
#领域的Proguard配置(http://realm.io)
#有关详细讨论,请参见:https://groups.google.com/forum/#!主题/领域java/umqKCc50JGU
#此外,还需要保留领域模型类
#例如:
-keepattributes指令
#滑翔
-keep public类*实现com.bumptech.glide.module.GlideModule
-保持公共类*扩展com.bumptech.glide.module.AppGlideModule
-保持公共枚举com.bumptech.glide.load.ImageHeaderParser$**{
**[]美元价值;
公众*;
}
#仅为DexGuard取消注释
#-keepresourcexmlelements清单/应用程序/元数据-data@value=滑动模块
##---------------开始:Gson的proguard配置----------
#Gson在处理字段时使用存储在类文件中的泛型类型信息。前卫
#默认情况下删除此类信息,因此将其配置为保留所有信息。
-保留署名
-keepattributes内部类
#用于使用GSON@Expose注释
-keepattributes*注释*
#Gson特定类
-dontwarn sun.misc**
#-保持类com.google.gson.stream.*{*;}
#将通过Gson进行序列化/反序列化的应用程序类
-保持类com.google.gson.examples.android.model.*{*;}
#防止proguard从TypeAdapterFactory中剥离接口信息,
#JsonSerializer、JsonDeserializer实例(因此可以在@JsonAdapter中使用)
-keep类*实现com.google.gson.TypeAdapterFactory
-keep class*实现com.google.gson.JsonSerializer
-keep类*实现com.google.gson.JsonDeserializer
##---------------结束:Gson的proguard配置----------
#匕首2
-dontwarn com.google.errorproof.annotations**
#科特林
-保持类kotlin.Metadata{*;}
-keepclassmembers公共类com.mypackage.*{
公共合成;
}
-保持类kotlinx.android.synthetic**
-keepclassmembers类android.support.design.internal.BottomNavigationMenuView{
布尔移动模式;
}
#王国
-保留@interface io.realm.annotations.RealmModule{*;}
-保持类io.realm.annotations.RealmModule{*;}
#请保留所有的名字
-keepnames类**{*;}
-保持类com.mypackage.model.*{*;}
-keepclassmembers公共类com.mypackage.*{
公共合成;
}
#FCM
-保持类com.google.firebase.*{*;}
-keepclassmembers类com.mypackage.model.*{*;}
-忽视警告
-唐特沃恩
#JSR305注释用于嵌入可空性信息。
-dontwarn javax.annotation**
#动物嗅探器编译依赖项,以确保API与旧版本的Java兼容。
-dontwarn org.codehaus.mojo.animal_sniffer*
-保持类com.google.android.gms.*{*;}
-保持类android.support.v4.app.NotificationCompat{*;}
-keep类android.support.v4.app.NotificationCompat$*{*;}
-保持类android.support.v4.app.NotificationManagerCompat{*;}
-dontnote com.google**

您是否提供了SHA?@Piyush我在firebase帐户中添加了SHA,然后您必须添加SHA作为发布。当你使用它是为了调试mode@Piyush我正在使用相同的密钥库生成调试和发布版本。谷歌登录在调试版本和发布版本中都能正常工作。在同一台设备上测试时,只有通知不起作用?您是否提供了SHA?Piyush我已在firebase帐户中添加了SHA,然后您必须将SHA添加为一个版本。当你使用它是为了调试mode@Piyush我正在使用相同的密钥库生成调试和发布版本。谷歌登录在调试版本和发布版本中都能正常工作。在同一台设备上测试时,只有通知不起作用?