Agasper / unity-android-notifications

Unity3D Plugin for Android local notifications with example project
Other
555 stars 184 forks source link

AndroidJavaException: java.lang.NoSuchMethodError: no static method with name='SetNotification' #128

Open swats1010 opened 4 years ago

swats1010 commented 4 years ago
E/Unity: AndroidJavaException: java.lang.NoSuchMethodError: no static method with name='SetNotification' signature='(IJLjava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;IILjava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V' in class Lnet.agasper.unitynotification.UnityNotificationManager;
    java.lang.NoSuchMethodError: no static method with name='SetNotification' signature='(IJLjava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;IILjava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V' in class Lnet.agasper.unitynotification.UnityNotificationManager;
        at com.unity3d.player.ReflectionHelper.getMethodID(Unknown Source)
        at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
        at com.unity3d.player.UnityPlayer.c(Unknown Source)
        at com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source)
        at android.os.MessageQueue.next(MessageQueue.java:216)
        at android.os.Looper.loop(Looper.java:151)

The call from my app

LocalNotification.SendNotification(1, miliSeconds, StaticStrings.notificationTitle, StaticStrings.notificationMessage,"soundName", new Color32(0xff, 0x44, 0x44, 255), true, true, true, "app_icon");

and the call from the LocalNotification class

public static int SendNotification(int id, long delayMs, string title, string message,String soundName, Color32 bgColor, bool sound = true, bool vibrate = true, bool lights = true, string bigIcon = "")
    {

#if UNITY_ANDROID //&& !UNITY_EDITOR
        AndroidJavaClass pluginClass = new AndroidJavaClass(fullClassName);
        if (pluginClass != null)
        {
        Debug.Log(" pluginclass not nulll");
            pluginClass.CallStatic("SetNotification", id, delayMs, title, message, message, 
        sound ? 1 : 0,soundName, vibrate ? 1 : 0, lights ? 1 : 0, bigIcon, "notify_icon_small", 
        bgColor.r * 65536 + bgColor.g * 256 + bgColor.b, "bundle", "channel", Application.identifier);
        }
        Debug.Log(" pluginclass  nulll : id : " + id);
        return id;

How do i fix this and what wrong am i doing ?

samii00 commented 3 years ago

if use progaurd in your project add this line to your progaurd-user.txt file to prevent exeption:

----------------dont obfuse class name (local notification plugin) : because call them with name in C# unity

-keep class net.agasper.unitynotification.* { ; }