Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ads] Java exceptions are thrown when calling AdParam.Builder class methods #262

Closed
MantasKriksciunas opened this issue Jan 12, 2022 · 7 comments
Labels
timeout and closed A month passed after the solution was given.

Comments

@MantasKriksciunas
Copy link

Hi,

I'm having trouble with some of HuaweiMobileServices.Ads namespace classes. There seems to be an java.lang.NoSuchMethodError exception thrown at runtime when I execute the following code:

RequestOptions _options = HwAds.RequestOptions;

_options = _options.ToBuilder()
                        .SetTagForChildProtection(TagForChild.TAG_FOR_CHILD_PROTECTION_FALSE)  
                        .SetTagForUnderAgeOfPromise(UnderAge.PROMISE_FALSE)
                        .SetNonPersonalizedAd(NonPersonalizedAd.ALLOW_ALL)
                        .Build();

It seems to happen with every Builder class Set* function. I've tried updating libraries with the latest version from master and clearing the project's cache but it didn't help to solve this.

Perhaps I'm missing something? I could only find these old issues (EvilMindDevs/hms-sdk-unity#46, #56) for reference

Here are the logs: logcat.txt

Setup

Huawei device setup:

  • Huawei Y9 2019 (MRD-LX1)
  • EMUI version 9.1.0
  • Android version 9 (SDK 28)
  • HMS Core Version 6.3.0.311

Unity setup:

  • v2.1.0 - Unity 2019/2020/2021 plugin package
  • Unity 2020.3.13f1 version
  • Mono Scripting Backend

Huawei gradle implementations:

  • com.huawei.hms:ads-lite:13.4.49.301
  • com.huawei.hms:ads-consent:3.4.49.301
@sametguzeldev
Copy link
Collaborator

sametguzeldev commented Jan 13, 2022

Hello there.
Thank you for the beautiful description!

I will be looking into it and I'll get back to you 👍

@sametguzeldev
Copy link
Collaborator

sametguzeldev commented Jan 13, 2022

Hello there @MantasKriksciunas
I've tried the same code as you've described in my Init() method but I got no errors. I did change the gradle hms ad versions as you've described as well.

This is the code sample that I modified in HMSAdsKitManager.cs file.

   private void Init()
   {
       HwAds.Init();
       isInitialized = true;
       adsKitSettings = HMSAdsKitSettings.Instance.Settings;
       Debug.LogWarning("Start");
       RequestOptions _options = HwAds.RequestOptions;
       _options = _options.ToBuilder()
                               .SetTagForChildProtection(TagForChild.TAG_FOR_CHILD_PROTECTION_FALSE)
                               .SetTagForUnderAgeOfPromise(UnderAge.PROMISE_FALSE)
                               .SetNonPersonalizedAd(NonPersonalizedAd.ALLOW_ALL)
                               .Build();
       Debug.LogWarning("End");

   }

And this is the resulting screenshot of the logs.
image

Do you have proguard or something active on the Android side that is stripping some codes by any chance?

@MantasKriksciunas
Copy link
Author

Sorry, it seems that I referenced the wrong class here. After retesting, like you said, this code passes without issues.

Exceptions are related not to RequestOptions.Builder but AdParam.Builder class instead. Try executing the following code:

private void Init()
{
      HwAds.Init();
      isInitialized = true;
      adsKitSettings = HMSAdsKitSettings.Instance.Settings;
      Debug.LogWarning("Start");
      
      AdParam.Builder _builder = new AdParam.Builder();
      AdParam _ad_param;

       _ad_param = _builder
            .SetTagForChildProtection(TagForChild.TAG_FOR_CHILD_PROTECTION_FALSE)
            .SetTagForUnderAgeOfPromise(UnderAge.PROMISE_FALSE)
            .SetNonPersonalizedAd(NonPersonalizedAd.ALLOW_ALL)
            .Build();

       Debug.LogWarning("End");
}

Also, I don't have any stripping active or proguard files in the project. I've tested this on a fresh project with the only change being the min SDK version, that's set to 21 instead of the default 19.

@MantasKriksciunas MantasKriksciunas changed the title [Ads] Java exceptions are thrown when calling RequestOptions.Builder class methods [Ads] Java exceptions are thrown when calling AdParam.Builder class methods Jan 14, 2022
@sametguzeldev
Copy link
Collaborator

sametguzeldev commented Jan 15, 2022

Hello there @MantasKriksciunas
You are correct. Our wrapper was not sending the correct method signature to the SDK side so it was not able to find the corresponding method. I've fixed this issue in #263. I will be shipping a new version (2.1.1) on Monday afternoon that will fix this issue.

@MantasKriksciunas
Copy link
Author

Hello, I'm glad to hear that you've found the problem. Thank you very much!

@sametguzeldev
Copy link
Collaborator

This issue should be resolved in the v2.1.1 release.

@alihan98ersoy
Copy link
Collaborator

alihan98ersoy commented Feb 6, 2022

Hello,
Can you test again? The issue should be resolved.

@alihan98ersoy alihan98ersoy added the waiting for confirmation The solution has been given label Feb 25, 2022
@alihan98ersoy alihan98ersoy added timeout and closed A month passed after the solution was given. and removed waiting for confirmation The solution has been given labels Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
timeout and closed A month passed after the solution was given.
Projects
None yet
Development

No branches or pull requests

3 participants