Unity-Technologies / HuaweiServiceSample

Public repository for HUAWEI HMS & AGC Unity SDK
43 stars 19 forks source link

NoSuchMethodError exception when calling setConsentStatus #19

Open kiloophilipullersted opened 3 years ago

kiloophilipullersted commented 3 years ago

Hello

When calling the setConsentStatus, via the SetConsentStatus(bool personal) method(in HuaweiServiceSample/Assets/HuaweiServiceDemo/Scripts/test/ads/AdsTest.cs) on a P9 (Android 6) and a MediaPad M5 lite (Android 8), I get this exception.

04-12 12:47:20.292 11526 11564 E Unity : AndroidJavaException: java.lang.NoSuchMethodError: no non-static method "Lcom/huawei/hms/ads/consent/constant/ConsentStatus;.<init>()V" 04-12 12:47:20.292 11526 11564 E Unity : java.lang.NoSuchMethodError: no non-static method "Lcom/huawei/hms/ads/consent/constant/ConsentStatus;.<init>()V" 04-12 12:47:20.292 11526 11564 E Unity : at com.unity3d.player.UnityPlayer.nativeRender(Native Method) 04-12 12:47:20.292 11526 11564 E Unity : at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0) 04-12 12:47:20.292 11526 11564 E Unity : at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95) 04-12 12:47:20.292 11526 11564 E Unity : at android.os.Handler.dispatchMessage(Handler.java:104) 04-12 12:47:20.292 11526 11564 E Unity : at android.os.Looper.loop(Looper.java:166) 04-12 12:47:20.292 11526 11564 E Unity : at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20) 04-12 12:47:20.292 11526 11564 E Unity : at UnityEngine.AndroidJNISafe.CheckException () [0x00096] in <0c28e1e730cf4a17bc80dd76531d408b>:0 04-12 12:47:20.292 11526 11564 E Unity : at UnityEngine.AndroidJNISafe.GetMethodID (System.IntPtr obj, System.String name, System.String sig) [0x0000e] in <0c28e1e730cf4a17bc80dd76531d408b>:0 04-12 12:47:20.292 11526 11564 E Unity : at UnityEngine._AndroidJNIHelper.GetConstructorID (System.IntPtr jclass, System.String signature) [0x0001b] in <0c28e1e730cf4a17bc80dd76531d408b>:0

You should be able to reproduce it by downloading the project(HuaweiServiceSample) building it and pressing "set content personal" or "set consent not personal" button.

Any ideas of how to fix it or what the issue causing this could be?

Attached is a device log for when the exception happens on one of the devices mentioned. The exception is starting at line 9309 FullDeviceLogForConsentError.txt

marcuslao commented 3 years ago

Hi @kiloophilipullersted , we will be on holiday before May 5th but will investigate it and get back to you asap.

SiyaoHuang commented 3 years ago

Hi @kiloophilipullersted, I failed to reproduce this bug. I tried all test devices I can reach. Does this happen only on these two devices? Does the ads scene work on your other devices?

This is possible because of android version. I create a branch issue/19 and add some fix. I have not verified this for all the packages. So, I will not update this onto master immediately. Could you try it and see if it works?

kiloophilipullersted commented 3 years ago

Hi @SiyaoHuang

This only happens on those 2 devices. It works fine on my other devices(Galaxy S10+, Huawei P40)

I will try the issue/19 branch and see if that fixes the issue.

kiloophilipullersted commented 3 years ago

I have tried the issue/19 branch and the issue still occurs on the branch on the devices(P9, MediaPad M5 lite)

SiyaoHuang commented 3 years ago

@kiloophilipullersted I tried it on HUAWEI P9 PLUS(EMUI 8.0.0, Android8.0.0,HMS Core 5.1.1.303), and failed to reproduce the error. I will try to find a HUAWEI P9.

kiloophilipullersted commented 3 years ago

Hi @SiyaoHuang

After having the Huawei out for a while, we have found some more devices, where the issue occurs.

Below is a list, of devices, where the issue occurs. Hopefully this will help you in reproducing the issue.

KilooNGUI commented 3 years ago

Adding to Philip's post above:

A suspicion is that it relates to the version of HMS core installed on the problematic devices, so maybe it can be reproduced by installing an older version of HMS core (e.g. 3.x).

SiyaoHuang commented 3 years ago

Hi @kiloophilipullersted and @RasmusSKristensen.

Does this issue happen when this function is called from native android project?

According to document, Publisher of Ads kit needs 3.0+ emui and 4.0+ hms core.

KilooNGUI commented 3 years ago

Not sure if it happens when calling it directly from native code - we only call methods via Unity. But the sample app did reproduce it for us, so you can see exactly what the code does there I reckon.

If it is caused by HMS Core being too low a version, then maybe what we are seeing is "expected behaviour"?

SiyaoHuang commented 2 years ago

Not sure if it happens when calling it directly from native code - we only call methods via Unity. But the sample app did reproduce it for us, so you can see exactly what the code does there I reckon.

If it is caused by HMS Core being too low a version, then maybe what we are seeing is "expected behaviour"?

Hi @RasmusSKristensen, did you mean you tried hms ads project and got error as well when calling setConsentStatus?

Method in Unity calls native code via reflection. They should be the same in most cases.

KilooNGUI commented 2 years ago

Hi @SiyaoHuang

No, we have not tried with that sample project. The one we tried - although it is a while ago by now - was this one: https://github.com/Unity-Technologies/HuaweiServiceSample

SiyaoHuang commented 2 years ago

Hi @SiyaoHuang

No, we have not tried with that sample project. The one we tried - although it is a while ago by now - was this one: https://github.com/Unity-Technologies/HuaweiServiceSample

Hi @RasmusSKristensen, could you try sample project from Huawei? I could not reproduce this issue on either https://github.com/Unity-Technologies/HuaweiServiceSample or https://github.com/HMS-Core/hms-ads-demo-java.

KilooNGUI commented 2 years ago

Hi @RasmusSKristensen, could you try sample project from Huawei? I could not reproduce this issue on either https://github.com/Unity-Technologies/HuaweiServiceSample or https://github.com/HMS-Core/hms-ads-demo-java.

Hi @SiyaoHuang - we will see what we can figure out and post an update here when we have news.

andreasboyekiloo commented 2 years ago

@SiyaoHuang I reproduced the issue again today on https://github.com/Unity-Technologies/HuaweiServiceSample (f4e3f1e) on a Huawei P9 EVA-L09 (an older phone) with HMS Core 6.3.0.310.

Build steps

Test steps

As you know, it is not reproducible on all devices.

andreasboyekiloo commented 2 years ago

@SiyaoHuang I tried with https://github.com/HMS-Core/hms-ads-demo-java (17db02e) as well on the same device as yesterday. I couldn't reproduce the exception when calling setConsentStatus, but ads were still not functional, so just posting this info in case it is helpful.

Build steps

Test steps

01/26 12:13:27.396 27362 27362 Info HiAdSDK.AdMediator ad failed:494 01/26 12:13:27.397 2349 26538 Info HiAdKit.DC.DcUtil base location switch off 01/26 12:13:27.397 27362 27362 Info SplashActivity SplashAdLoadListener onAdFailedToLoad, errorCode: 3

One thing I noticed (if relevant) on this device was that the country was determined as UNKNOWN:

NetworkSdk_CountryCodeBean getVendorCountryCode|-1|countryCode by ro.hw.country is: eu NetworkSdk_CountryCodeBean getSimCountryCode|-1|countryCode by SimCountryIso is: NetworkSdk_CountryCodeBean getProductCountryCode|-1|countryCode by ro.product.locale.region is:US NetworkSdk_CountryCodeBean getLocaleCountryCode|-1|EMUI 9.0 lower System, get countryCode form ro.product.locale.region or locale HiAdKit.AccessMethod.Builder countryCode:UNKNOWN

Ads were functional using above steps on a control device.