Unity-Technologies / NotificationsSamples

Sample project for Unity Notifications
Other
282 stars 51 forks source link

NoSuchMethodError - findResourceidInContextByName #30

Closed JabluszkoPL closed 3 years ago

JabluszkoPL commented 4 years ago

Hi, I am using mobile notification and so some phone like SM-N950F (I don't have those devices) my gamie is getting errors:

AndroidJavaException: java.lang.NoSuchMethodError: no static method with name='findResourceidInContextByName' signature='(Ljava/lang/String;Landroidx.multidex.MultiDexApplication;Lcom.unity3d.player.UnityPlayerActivity;)I' in class Lcom.unity.androidnotifications.UnityNotificationManagerOreo;
  at java.lang.NoSuchMethodError: no static method with name='findResourceidInContextByName' signature='(Ljava/lang/String;Landroidx.multidex.MultiDexApplication;Lcom.unity3d.player.UnityPlayerActivity;)I' in class Lcom.unity.androidnotifications.UnityNotificationManagerOreo;
  at com.unity3d.player.ReflectionHelper.getMethodID(Unknown Source:180)
  at com.unity3d.player.UnityPlayer.nativePause(Native Method)
  at com.unity3d.player.UnityPlayer.l(Unknown Source:0)
  at com.unity3d.player.UnityPlayer$25.run(Unknown Source:2)
  at android.os.Handler.handleCallback(Handler.java:873)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:214)
  at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
  at UnityEngine.AndroidJNISafe.CheckException () (at <00000000000000000000000000000000>:0)
  at UnityEngine.AndroidJNISafe.CallStaticObjectMethod (System.IntPtr clazz, System.IntPtr methodID, UnityEngine.jvalue[] args) (at <00000000000000000000000000000000>:0)
  at UnityEngine.AndroidReflection.GetMethodMember (System.IntPtr jclass, System.String methodName, System.String signature, System.Boolean isStatic) (at <00000000000000000000000000000000>:0)
  at UnityEngine._AndroidJNIHelper.GetMethodID (System.IntPtr jclass, System.String methodName, System.String signature, System.Boolean isStatic) (at <00000000000000000000000000000000>:0)
  at UnityEngine.AndroidJavaObject._CallStatic[ReturnType] (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)
  at Unity.Notifications.Android.AndroidNotificationCenter.SendNotification (System.Int32 id, Unity.Notifications.Android.AndroidNotification notification, System.String channel) (at <00000000000000000000000000000000>:0)
  at Unity.Notifications.Android.AndroidNotificationCenter.SendNotification (Unity.Notifications.Android.AndroidNotification notification, System.String channel) (at <00000000000000000000000000000000>:0)

I added to proguard

-keep class com.unity.androidnotifications.** { *;}
-keepclassmembers class com.unity.androidnotifications.** { *;}
-keepnames class com.unity.androidnotifications.** { *;}
-keepclassmembernames class com.unity.androidnotifications.** { *;}

but nothing changed. any idea what i need to change?

JabluszkoPL commented 4 years ago

found fix, add to proguard: -keep class com.unity.* { ;} - fixed some other issue not this one

SamiSdd commented 4 years ago

We're also seeing this issue. Please advise

bw-atif commented 4 years ago

@JabluszkoPL, I am facing the same issue. do you have any workaround for this?

JabluszkoPL commented 4 years ago

Hi, I previously closed this because I was thinking that Proguard should have

-keep class com.unity.** { *;}
-keep class com.unity.androidnotifications.** { *;}
-keepclassmembers class com.unity.androidnotifications.** { *;}
-keepnames class com.unity.androidnotifications.** { *;}
-keepclassmembernames class com.unity.androidnotifications.** { *;}

I know that guys did update notification package to newest. And I think both of those fixes did help, but I don't have final results because app is still not in store to verify. You can try this and post me if this did help you guys

SamiSdd commented 4 years ago

The issue is not resolved. I've added your fixes @JabluszkoPL

tutibueno commented 4 years ago

It looks like an error on the new Mobile Notifications package. We could make a temporary fix by using SendNotificationWithExplicitID().

bw-atif commented 4 years ago

Upgrading Mobile Notifications package to 1.0.4-preview.5 has done the trick for me but it is to be noted that the version is in preview.

adlercoder commented 3 years ago

The error is also available for 1.3.0 package with proguard activated. Unity 2019.4.10f1.

The lines in the proguard file fix the issue:

The error is also available for 1.3.0 package with proguard activated. Unity 2019.4.10f1.

The lines in the proguard file fix the issue:

-keep class com.unity. { *;} -keep class com.unity.androidnotifications.* { ;} -keepclassmembers class com.unity.androidnotifications. { *;} -keepnames class com.unity.androidnotifications.* { ;} -keepclassmembernames class com.unity.androidnotifications.* { ;}

bilalemregrkn commented 3 years ago

The error is also available for 1.3.0 package with proguard activated. Unity 2019.4.10f1.

The lines in the proguard file fix the issue:

The error is also available for 1.3.0 package with proguard activated. Unity 2019.4.10f1.

The lines in the proguard file fix the issue:

-keep class com.unity.* { ;} -keep class com.unity.androidnotifications. { ;} -keepclassmembers class com.unity.androidnotifications. { ;} -keepnames class com.unity.androidnotifications. { ;} -keepclassmembernames class com.unity.androidnotifications. { ;}

this proguard syntax is wrong. It's should be :

-keep class com.unity.* { ;} -keep class com.unity.androidnotifications. { ;} -keepclassmembers class com.unity.androidnotifications. { ;} -keepnames class com.unity.androidnotifications. { ;} -keepclassmembernames class com.unity.androidnotifications. { ;}

Indrit-Vaka commented 3 years ago

The error is also available for 1.3.0 package with proguard activated. Unity 2019.4.10f1.

The lines in the proguard file fix the issue:

The error is also available for 1.3.0 package with proguard activated. Unity 2019.4.10f1.

The lines in the proguard file fix the issue:

-keep class com.unity.* { ;} -keep class com.unity.androidnotifications. { ;} -keepclassmembers class com.unity.androidnotifications. { ;} -keepnames class com.unity.androidnotifications. { ;} -keepclassmembernames class com.unity.androidnotifications. { ;}

I am out where I should put those?? pls help

Indrit-Vaka commented 3 years ago

Thanks a loooot it fixed the isue I found the proguard file by searching in my project folder and I added those lines on file named proguard , proguard-unity and in this one proguard-android.txt-3.6.0 i added the lines out of parentheses in the end. Tank You! :) error I was getting before of that

AndroidJavaException: java.lang.NoSuchMethodError: no static method with name='getNotificationManagerImpl' signature='(Landroid.app.Application;Lcom.unity3d.player.UnityPlayerActivity;)Ljava/lang/Object;' in class Lcom.unity.androidnotifications.UnityNotificationManager; java.lang.NoSuchMethodError: no static method with name='getNotificationManagerImpl' signature='(Landroid.app.Application;Lcom.unity3d.player.UnityPlayerActivity;)Ljava/lang/Object;' in class Lcom.unity.androidnotifications.UnityNotificationManager; at com.unity3d.player.ReflectionHelper.getMethodID(Unknown Source) at com.unity3d.player.UnityPlayer.nativeRender(Native Method) at com.unity3d.player.UnityPlayer.access$300(Unknown Source) at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:154) at com.unity3d.player.UnityPlayer$e.run(Unknown Source) at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <000000000000000000

That happened to me after I included google adMob

hippogamesunity commented 2 years ago

I can confirm that the issue exists in Mobile Notifications 1.4.0, but it can be fixed with -keep class com.unity.** { *; } Meanwhile it looks they lied: image