universal-tools / UTNotificationsFeedback

7 stars 0 forks source link

NoClassDefFoundError at Unity 2019.2 #113

Closed greymag closed 4 years ago

greymag commented 4 years ago

Unity 2019.2.0 Platform: Android

Problem: When I launch application on device, on every extension call (for example Manager.Instance.NotificationsAllowed()) - I got exception in console


AndroidJavaException: java.lang.NoClassDefFoundError: android.support.v4.app.NotificationManagerCompat

Managed Stack Trace:

java.lang.NoClassDefFoundError: android.support.v4.app.NotificationManagerCompat
universal.tools.notifications.Manager.notificationsAllowed(Manager.java:189)
com.unity3d.player.UnityPlayer.nativeRender(Native Method)
com.unity3d.player.UnityPlayer.c(Unknown Source)
com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source)
android.os.Handler.dispatchMessage(Handler.java:98)
android.os.Looper.loop(Looper.java:146)
com.unity3d.player.UnityPlayer$e.run(Unknown Source)
UnityEngine.AndroidJNISafe.CheckException () (at <00000000000000000000000000000000>:0)
UnityEngine.AndroidJNISafe.CallStaticBooleanMethod (System.IntPtr clazz, System.IntPtr methodID, UnityEngine.jvalue[] args) (at <00000000000000000000000000000000>:0)
UnityEngine.AndroidJavaObject._CallStatic[ReturnType] (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)
UTNotifications.ManagerImpl.NotificationsAllowed () (at <00000000000000000000000000000000>:0)
Innim.Sherlock.Game.Controller.PushNotification.PushNotificationTask`1[TResultData].CheckIsAllowedOrFail () (at <00000000000000000000000000000000>:0)
Innim.Sherlock.Game.Controller.PushNotification.PushNotificationScheduleTask.DoExecute () (at <00000000000000000000000000000000>:0)
Innim.Sherlock.Game.Controller.PushNotification.PushNotificationController.ScheduleNotificationIfEnabled (Innim.Sherlock.Game.Model.PushNotification.IPushNotification pushNotification) (at <00000000000000000000000000000000>:0)
Innim.Sherlock.Game.Controller.PushNotification.PushNotificationProvider.UpdateNotifications () (at <00000000000000000000000000000000>:0)
Innim.Sherlock.Game.Controller.PushNotification.PushNotificationProvider.SetupReturningNotifications () (at <00000000000000000000000000000000>:0)
Innim.Sherlock.Game.Controller.PushNotification.PushNotificationController.UpdateReturningNotifications (Innim.Sherlock.Game.Model.Timer.ITimer obj) (at <00000000000000000000000000000000>:0)
System.EventHandler.Invoke (System.Object sender, System.EventArgs e) (at <00000000000000000000000000000000>:0)
Innim.Sherlock.Game.Controller.Investigation.InvestigationController.set_investigation (Innim.Sherlock.Game.Model.Investigation.IInvestigation value) (at <00000000000000000000000000000000>:0)
Innim.Sherlock.Game.Controller.Chapter.LoadChapterTask.InitInvestigation (Innim.Sherlock.Game.Model.Chapter.IChapter chapter, Innim.Sherlock.Game.Model.Investigation.IInvestigation investigation) (at <00000000000000000000000000000000>:0)
Innim.UnityCoreLib.Task.TaskDidExecuteCallback`2[TTask,TResultData].Invoke (Innim.UnityCoreLib.Task.ITaskResult`2[TTask,TResultData] result) (at <00000000000000000000000000000000>:0)
Innim.UnityCoreLib.Task.Task`1[TResultData].DoComplete () (at <00000000000000000000000000000000>:0)
Innim.UnityCoreLib.Task.TaskDidExecuteCallback`2[TTask,TResultData].Invoke (Innim.UnityCoreLib.Task.ITaskResult`2[TTask,TResultData] result) (at <00000000000000000000000000000000>:0)
Innim.UnityCoreLib.Task.Task`1[TResultData].DoComplete () (at <00000000000000000000000000000000>:0)
Innim.UnityCoreLib.Task.TaskDidExecuteCallback`2[TTask,TResultData].Invoke (Innim.UnityCoreLib.Task.ITaskResult`2[TTask,TResultData] result) (at <00000000000000000000000000000000>:0)
Innim.UnityCoreLib.Task.Task`1[TResultData].DoComplete () (at <00000000000000000000000000000000>:0)
Innim.Sherlock.Game.Controller.Resource.LoadBundleByNameTask+<LoadFromUrl>d__33.MoveNext () (at <00000000000000000000000000000000>:0)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <00000000000000000000000000000000>:0)```
yuriy-universal-ivanov commented 4 years ago

Hi @greymag,

I've briefly reviewed the project you've sent (btw, thank you a lot for that, it really helps). You seem to have incompatible versions of Android libraries imported in your project (or AndroidX libraries enabled in Play Services Resolver settings while using AndroidX-conflicting versions of Android libraries). Fortunately, the fix should be pretty simple: see https://forum.unity.com/threads/released-utnotifications-professional-cross-platform-push-notifications-and-more.333045/page-17#post-4777697. Please let me know if it doesn't help, I'll try to reproduce and research your issue deeper using the demo project you've sent (though it may take a little more time then).

Best regards, Yuriy, Universal Tools team.

greymag commented 4 years ago

Thanks for answer!

I did read forum topic and try it, but it's doesn't help - still got errors.

yuriy-universal-ivanov commented 4 years ago

Hi @greymag,

Thank you, I did research your issue and was able to reproduce it and find a solution. That's what helped me:

  1. Update both versions of Google Play Services and Android Support Lib in UTNotifications settings to LATEST.
  2. Enable dependencies resolution with Gradle by turning on Custom Gradle Template in project settings (seems that Play Services Resolver fails to run Jetifier properly). image
  3. Resolve dependencies with Assets -> Play Services Resolver -> Android Resolver -> Resolve.

Should help (helps in my case). I'll check if Google has fixed the issue in newer versions of Play Services Resolver, and if so, will update the asset with this fix.

Best regards, Yuriy, Universal Tools team.

yuriy-universal-ivanov commented 4 years ago

Fixed in 1.8.3