This issue typically occurs when code shrinking and obfuscation tools, like ProGuard or R8, are enabled for your release build. These tools can remove or rename classes that the Pushwoosh SDK relies on, leading to initialization failures and errors like java.lang.IllegalStateException: Could not find class for name....
To resolve this, you need to add specific rules to your ProGuard configuration file (proguard-rules.pro) to prevent essential classes from being removed or renamed.
Solution
Add the following rules to your proguard-rules.pro file:
Keep Pushwoosh SDK classes: This rule ensures that all classes within the Pushwoosh SDK are preserved.
-keep class com.pushwoosh.**{ *; } -dontwarn com.pushwoosh.**Keep your custom implementation classes: If you have created any custom classes that extend Pushwoosh functionality (such as a custom
NotificationServiceExtension), you must also add a rule to preserve them. The error log often indicates the exact class that could not be found.Replace
com.your.package.YourCustomNotificationExtensionwith the actual full path to your custom class.# Example for a custom NotificationServiceExtension -keep class com.your.package.YourCustomNotificationExtension { *; }
After adding these rules, clean and rebuild your project. This will ensure that the necessary classes are included in your release APK, allowing the Pushwoosh SDK to initialize and function correctly.
Comments
0 comments
Please sign in to leave a comment.