AndroidJavaException: java.lang.ClassNotFoundException: com.unity.udp.sdk.ChannelService

Hi,

I’m trying to get a game ready for UDP, using the Unity IAP plugin.

I’m getting this error :

And here’s my initialization code :

ConfigurationBuilder builder = ConfigurationBuilder.Instance (StandardPurchasingModule.Instance (AppStore.UDP));
foreach (var kv in BillingManager.products) {
    BillingProduct p = kv.Value;
    builder.AddProduct (p.GetKey (store), p.isConsumable ? ProductType.Consumable : ProductType.NonConsumable);
}
UnityPurchasing.Initialize (iapListener, builder);

Any help would be appreciated. Thanks!

I figured it out, my build tools had overwritten the plugin’s setting so it wasn’t properly targeting UDP, so that was my bad. All good now.

1 Like

Could you try to make a step by step of how you resolve this?

Typically it would be from the Window/Unity IAP/Android/Target UDP menu in the Unity Editor.

I need to make a build for google play, so I have to set the target to target google play, and now I get this error, how to I fix it?

Hi @peeka ,

Which error are you getting on GooglePlay, exactly?

I am on unity 2019.4.20f1 , IAP in pakcagemanager it says it’s 2.2.2, in services it says it’s 2.2.7

when I select unity IAP → Android → Target UDP everything works fine,
but now I need to make a google play build, so I select IAP → Android → Target Google Play.

the aab file for google is built, and pushed to mobile device, when I ran the game, I got this error.

2021/02/15 19:19:44.975 17294 17315 Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.unity.udp.sdk.ChannelService
2021/02/15 19:19:44.975 17294 17315 Error Unity java.lang.ClassNotFoundException: com.unity.udp.sdk.ChannelService
2021/02/15 19:19:44.975 17294 17315 Error Unity     at java.lang.Class.classForName(Native Method)
2021/02/15 19:19:44.975 17294 17315 Error Unity     at java.lang.Class.forName(Class.java:454)
2021/02/15 19:19:44.975 17294 17315 Error Unity     at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
2021/02/15 19:19:44.975 17294 17315 Error Unity     at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
2021/02/15 19:19:44.975 17294 17315 Error Unity     at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:83)
2021/02/15 19:19:44.975 17294 17315 Error Unity     at android.os.Handler.dispatchMessage(Handler.java:103)
2021/02/15 19:19:44.975 17294 17315 Error Unity     at android.os.Looper.loop(Looper.java:214)
2021/02/15 19:19:44.975 17294 17315 Error Unity     at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
2021/02/15 19:19:44.975 17294 17315 Error Unity Caused by: java.lang.ClassNotFoundException: com.unity.udp.sdk.ChannelService
2021/02/15 19:19:44.975 17294 17315 Error Unity     ... 8 more
2021/02/15 19:19:44.975 17294 17315 Error Unity   at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0
2021/02/15 19:19:44.975 17294 17315 Error Unity   at UnityEngine.AndroidJNISafe.FindClass (System.String name) [0x00000] in <00000000000000000000000000000000>:0
2021/02/15 19:19:44.975 17294 17315 Error Unity   at UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) [0x00000] in <000000000000000000

I previously had UDP installed from packagemanager, I have now uninstalled it, and only use latest version IAP 2.2.7 and it comes with UDP

I tried aab and apk, both same error

Are you using code stripping or ProGuard settings? Can you provide detailed steps to reproduce, perhaps start with the Sample IAP Project and upgrade? https://discussions.unity.com/t/700293

Sorry, didn’t see this before - but no, I have no idea, sorry. Been a long time since I made Android builds, and I don’t remember how I solved it.

Hey there, what build tools of yours have overwrite the settings, can you share it? I have encountered the same issues, switched target store to UDP instead of Playstore, but udp.sdk class not found error still shows up.

For me, I fixed this issue by changing the build settings from debug to release.
Project Settings → Player → Publishing Settings → Minify → Tick Release. Untick Debug.

Having the same issue now, I tried with release and debug, without debug, without release and debug but it didnt work. I dont know what could be the problem, I am using custom proguard file, people solved this in this thread https://www.higithub.com/playgameservices/issue/play-games-plugin-for-unity/3072
But it didnt work for me

And it works without the proguard settings? Are you targeting UDP? Ensure to be using IAP 4.1.2 (In App Purchasing in Package Manager)

Oh, I am sorry Jeff, its actually very similar not the same error. I have almost the same thing but with Google Play services. You can check out my other threads that I posted, there are a lot of screenshots:
https://github.com/playgameservices/play-games-plugin-for-unity/issues/3111
https://github.com/googlesamples/unity-jar-resolver/issues/497
https://discussions.unity.com/t/868537

And links I think may be useful
https://groups.google.com/g/google-admob-ads-sdk/c/uhPLc6cHdIY
https://stackoverflow.com/questions/54991254/androidjavaexception-java-lang-classnotfoundexception-com-google-android-gms-a

Can you answer my first question please?

Hey, I have the same issue now.

I’m using Unity IAP package 4.1.3 and UDP package 2.2.5 is added via Package Manager (both latest version at this moment)
7954525--1018888--upload_2022-3-10_15-53-13.png

These are my settings, I need these custom gradles for ad mediation sdk (FairBid).

Is there anything I need to add in gradle?
I did force resolve with external dependency manager, but it didn’t help.

Thanks in advance @JeffDUnity3D !

I also get this error log when I go through implementation guide option that comes with UDP
Settings are connected with my game, IAP packages are pulled.

I select option for Unity IAP implementation with code.

NullReferenceException: Object reference not set to an instance of an object
TutorialCallbacks+<>c.<PackmanCheck>b__10_1 (UnityEditor.PackageManager.PackageInfo x) (at Library/PackageCache/com.unity.purchasing.udp@2.2.5/Editor/Tutorial/Editor/TutorialCallbacks.cs:79)
System.Collections.Generic.List`1[T].Find (System.Predicate`1[T] match) (at <9577ac7a62ef43179789031239ba8798>:0)
TutorialCallbacks.PackmanCheck () (at Library/PackageCache/com.unity.purchasing.udp@2.2.5/Editor/Tutorial/Editor/TutorialCallbacks.cs:79)
SerializableCallback.InvokableCallback`1[TReturn].Invoke (System.Object[] args) (at Library/PackageCache/com.unity.learn.iet-framework@2.0.0/Editor/ThirdParty/SerializableCallback/InvokableCallback.cs:32)
SerializableCallback.SerializableCallback`1[TReturn].Invoke () (at Library/PackageCache/com.unity.learn.iet-framework@2.0.0/Editor/ThirdParty/SerializableCallback/SerializableCallback.cs:23)
Unity.Tutorials.Core.Editor.ArbitraryCriterion.EvaluateCompletion () (at Library/PackageCache/com.unity.learn.iet-framework@2.0.0/Editor/Criteria/ArbitraryCriterion.cs:47)
Unity.Tutorials.Core.Editor.Criterion.UpdateCompletion () (at Library/PackageCache/com.unity.learn.iet-framework@2.0.0/Editor/Criteria/Criterion.cs:99)
Unity.Tutorials.Core.Editor.ArbitraryCriterion.StartTesting () (at Library/PackageCache/com.unity.learn.iet-framework@2.0.0/Editor/Criteria/ArbitraryCriterion.cs:57)
Unity.Tutorials.Core.Editor.TutorialPage.SetupCompletionRequirements () (at Library/PackageCache/com.unity.learn.iet-framework@2.0.0/Editor/Models/TutorialPage.cs:371)
Unity.Tutorials.Core.Editor.TutorialPage.Initiate () (at Library/PackageCache/com.unity.learn.iet-framework@2.0.0/Editor/Models/TutorialPage.cs:327)
Unity.Tutorials.Core.Editor.Tutorial.RaisePageInitiated (Unity.Tutorials.Core.Editor.TutorialPage page, System.Int32 index) (at Library/PackageCache/com.unity.learn.iet-framework@2.0.0/Editor/Models/Tutorial.cs:406)
Unity.Tutorials.Core.Editor.Tutorial.TryGoToNextPage () (at Library/PackageCache/com.unity.learn.iet-framework@2.0.0/Editor/Models/Tutorial.cs:329)
Unity.Tutorials.Core.Editor.TutorialWindow.OnNextButtonClicked () (at Library/PackageCache/com.unity.learn.iet-framework@2.0.0/Editor/Editor Windows/TutorialWindow.cs:1325)
UnityEngine.UIElements.Clickable.Invoke (UnityEngine.UIElements.EventBase evt) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.Clickable.ProcessUpEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.Vector2 localPosition, System.Int32 pointerId) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.Clickable.OnMouseUp (UnityEngine.UIElements.MouseUpEvent evt) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.EventCallbackFunctor`1[TEventType].Invoke (UnityEngine.UIElements.EventBase evt) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.EventCallbackRegistry.InvokeCallbacks (UnityEngine.UIElements.EventBase evt) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <a8eb1be68acb4659af00824c7808e2c0>:0)

Can I get any feedback on this @JeffDUnity3D ?

Hey, I have the same issue now.
Do you resolve this?
Could you try to make a step by step of how you resolve this?