Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question ProGuard causing exception for Mobile Notifications

Discussion in 'Android' started by MetalCodeGames, Mar 14, 2021.

  1. MetalCodeGames

    MetalCodeGames

    Joined:
    Mar 4, 2019
    Posts:
    5
    Hi all, I'm working on implementing Unity Mobile Notifications and I've been experimenting with this provided sample on GitHub - Unity-Technologies/NotificationsSamples: Sample project for Unity Notifications. However, I'm needing some help because when I turn on ProGuard it causes an object reference exception at
    Code (CSharp):
    1. PendingNotifications.Add(result);
    in the CreateNotification() method of the GameNotificationsManager class.

    When ProGuard is off the code works. My understanding is that the solution is to setup the proguard-user.txt file to exclude the class from obfuscation. I'm not sure how to correctly identify what I need to exclude from ProGuard. Any advice on how the proguard-user.txt should be configured?

    I'm new to ProGuard and so far I've tried but this doesn't seem to work
    -keep class com.unity.notificationsamples.Android.** {*;}
     
  2. MetalCodeGames

    MetalCodeGames

    Joined:
    Mar 4, 2019
    Posts:
    5
    Solved. The ProGuard rule needs to be -keep class com.unity.androidnotifications.** { *;}
     
    Nimdanet likes this.