EvilMindDevs / hms-unity-plugin

The HMS Unity Plugin makes it easy to include Huawei Mobile Services into Unity-based games. Authentication, in-app purchases, push alerts, ads, and interaction with gaming services are just a few of the basic capabilities that this formidable tool makes available to your applications.
https://evilminddevs.gitbook.io/hms-unity-plugin/
305 stars 41 forks source link

HMS Unity not working , create run time error (v2.3.5 - Unity 2019/2020/2021) #465

Closed breaksoftdev closed 4 months ago

breaksoftdev commented 5 months ago

We are trying to use the HMS Unity plugin for Huawei AppGallary. but it's not working, we tried all the methods and it's not shown in test mode, when we run the code it creates an error on the start screen. please review the mentioned error

Exception: Field currentActivity or type signature not found UnityEngine._AndroidJNIHelper.GetFieldID (System.IntPtr jclass, System.String fieldName, System.String signature, System.Boolean isStatic) (at :0) UnityEngine.AndroidJNIHelper.GetFieldID (System.IntPtr javaClass, System.String fieldName, System.String signature, System.Boolean isStatic) (at :0) UnityEngine._AndroidJNIHelper.GetFieldID[ReturnType] (System.IntPtr jclass, System.String fieldName, System.Boolean isStatic) (at :0) UnityEngine.AndroidJNIHelper.GetFieldID[FieldType] (System.IntPtr jclass, System.String fieldName, System.Boolean isStatic) (at :0) UnityEngine.AndroidJavaObject._GetStatic[FieldType] (System.String fieldName) (at :0) UnityEngine.AndroidJavaObject.GetStatic[FieldType] (System.String fieldName) (at :0) HuaweiMobileServices.Utils.AndroidContext.get_ActivityContext () (at <3e917abcbb924450a121c615facfe546>:0) HuaweiMobileServices.Ads.HwAds.Init () (at <3e917abcbb924450a121c615facfe546>:0) HmsPlugin.HMSAdsKitManager.Init () (at Assets/Huawei/Scripts/Ads/HMSAdsKitManager.cs:71) HmsPlugin.HMSAdsKitManager.OnAwake () (at Assets/Huawei/Scripts/Ads/HMSAdsKitManager.cs:57) HuaweiMobileServices.Utils.HMSDispatcher.InvokeAsync (System.Action action) (at <3e917abcbb924450a121c615facfe546>:0) HmsPlugin.HMSAdsKitManager..ctor () (at Assets/Huawei/Scripts/Ads/HMSAdsKitManager.cs:50) System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) (at <4a4789deb75f446a81a24a1a00bdd3f9>:0) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) (at <4a4789deb75f446a81a24a1a00bdd3f9>:0) System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic, System.Boolean wrapExceptions) (at <4a4789deb75f446a81a24a1a00bdd3f9>:0) System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean wrapExceptions, System.Boolean skipCheckThis, System.Boolean fillCache) (at <4a4789deb75f446a81a24a1a00bdd3f9>:0) System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Boolean wrapExceptions, System.Threading.StackCrawlMark& stackMark) (at <4a4789deb75f446a81a24a1a00bdd3f9>:0) System.Activator.CreateInstance[T] () (at <4a4789deb75f446a81a24a1a00bdd3f9>:0) HMSManagerSingleton1[T].get_Instance () (at Assets/Huawei/Scripts/Utils/HMSSingleton.cs:53) AdsDemoManager.ShowBannerAd () (at Assets/Huawei/Demos/Ads/AdsDemoManager.cs:83) AdsUIView.ButtonClick_ShowBannerAd () (at Assets/Huawei/Demos/Ads/AdsUIView.cs:67) UnityEngine.Events.InvokableCall.Invoke () (at <f712b1dc50b4468388b9c5f95d0d0eaf>:0) UnityEngine.Events.UnityEvent.Invoke () (at <f712b1dc50b4468388b9c5f95d0d0eaf>:0) UnityEngine.UI.Button.Press () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:70) UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:114) UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:57) UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction1[T1] functor) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:272) UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:514)

github-actions[bot] commented 5 months ago

Thank you for reporting this issue/advice.

We will get back to you as soon as possible.
Would you like to star our plugin to support us? :sparkles:

alihan98ersoy commented 5 months ago

Hello, you should try the plugin with a real device. Huawei recommended. Also, you can use any Android device with HMS Core installed. If you don't have an Android device you can use Cloud Debugging.

breaksoftdev commented 4 months ago

yes, we tried the APK on Cloud Debugging, even it's not running in Unity, it created the error, we have already mentioned the error when it run in the Unity Editore.

alihan98ersoy commented 4 months ago

Can you provide the logs from CloudDebugging ? I need the check the logs

breaksoftdev commented 4 months ago

please the all details with logs Screenshot (20)

2024-02-07 19_41_13.log

alihan98ersoy commented 4 months ago

I couldn't find any log related with unity or our plugin. Did you use any filter? It should be something like this one resim

If you want you can sent me your APK and I can test. You can send here or email me alihan98ersoy@hotmail.com

breaksoftdev commented 4 months ago

@alihan98ersoy, please review the email.

I couldn't find any log related with unity or our plugin. Did you use any filter? It should be something like this one resim

If you want you can sent me your APK and I can test. You can send here or email me alihan98ersoy@hotmail.com

alihan98ersoy commented 4 months ago

@breaksoftdev I asked for permission to download the APK.

alihan98ersoy commented 4 months ago

Ok, I found the problem you should use your agconnect-services.json File.

Please refer to Obtaining the agconnect-services.json File or the video.

Also, there are some errors "Error Unity InvalidOperationException: Insecure connection not allowed" I believe you missed the step on quick start. Adding Fingerprint Certificate to AppGallery Connect Can you follow the quick start?

breaksoftdev commented 4 months ago

@alihan98ersoy i followed all the steps as you mentioned in the video, but when we enabled the test ads and ran on the cloud debugging, it's not show the ads. even it creates errors in the unity editor, and shoe script errors (signature not found) it's possible, can you share the project/repo with working ads.

Ok, I found the problem you should use your agconnect-services.json File.

Please refer to Obtaining the agconnect-services.json File or the video.

Also, there are some errors "Error Unity InvalidOperationException: Insecure connection not allowed" I believe you missed the step on quick start. Adding Fingerprint Certificate to AppGallery Connect Can you follow the quick start?

alihan98ersoy commented 4 months ago

The package of agconnect-services.json in your APK was com.refapp.cubesurfer.huawei. This is the same json that we loaded into the plugin as an example.

  1. First, create a project with your own package name in the AppGallery console.
  2. Enable ads kit. (Requires Merchant permission)
  3. Then add your fingerprint. (SHA-256)
  4. Download agconnect-services.json and replace it.

If you use our JSON you will connect your game to our project but you don't have the same fingerprint so it will give a 6003 fingerprint error.

These are the APK: AdsDemoTest.zip

github-actions[bot] commented 4 months ago

Thank you for using our repository! We're glad we could help solve your issue. If you found our repository helpful, please consider giving us a star ⭐ on GitHub: https://github.com/EvilMindDevs/hms-unity-plugin

Your support helps us continue to improve our repository and provide valuable resources for others.