Giter Site home page Giter Site logo

Comments (11)

m0skit0 avatar m0skit0 commented on June 8, 2024 1

Thanks! This looks like a bug on the SDK, creating issue there: EvilMindDevs/hms-sdk-unity#47

from hms-unity-plugin.

manelizzard avatar manelizzard commented on June 8, 2024 1

Hi,

This repository, when I build and Android APK and install it on my device, fires the above exception. IAP never gets fully initialized. I also tried building the DLL on my own with the SDK repo, but the result is the same.

You say:

The EnvReadyResult Java class is available on the Huawei AARs.

But if I look in the Android doc for com.huawei.hms.iap, the class name is IsEnvReadyResult (https://developer.huawei.com/consumer/en/doc/development/HMS-References/iap-IsEnvReadyResult-v4). Seeing the same class name when decompiling the AAR:

isenvresultready

And here also we can see the result object of the Task is IsEnvReadyResult: https://developer.huawei.com/consumer/en/doc/development/HMS-References/iap-IapClient-v4#isEnvReady

So:

  • May this class name difference be the cause of not finding the constructor?
  • Does the IAP Demo work for you within this repo: build android APK, execute and do a test purchase?

Thank you!

EDIT: Said nothing... I changed the class name on the SDK, built the DLL and I'm getting the same error.

06-18 14:09:03.451  2037  2037 E Unity   : MissingMethodException: Constructor on type 'HuaweiMobileServices.IAP.IsEnvReadyResult' not found.
06-18 14:09:03.451  2037  2037 E Unity   :   at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0 
06-18 14:09:03.451  2037  2037 E Unity   :   at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00000] in <00000000000000000000000000000000>:0 
06-18 14:09:03.451  2037  2037 E Unity   :   at HuaweiMobileServices.Utils.AndroidJavaObjectExtensions.AsWrapper[T] (UnityEngine.AndroidJavaObject javaObject) [0x00000] in <00000000000000000000000000000000>:0 

from hms-unity-plugin.

manelizzard avatar manelizzard commented on June 8, 2024 1

Good catch! Will follow that thread. Thank you!

from hms-unity-plugin.

manelizzard avatar manelizzard commented on June 8, 2024

Second test:

If I try to request ProductInfo after a prudent time (ignoring EnvReady crash), I do get the following error:

MissingMethodException: Constructor on type 'HuaweiMobileServices.IAP.ProductInfoResult' not found

Seems HuaweiMobileServices.IAP namespace or library is not properly included within the project.

from hms-unity-plugin.

m0skit0 avatar m0skit0 commented on June 8, 2024

Seems HuaweiMobileServices.IAP namespace or library is not properly included within the project.

Code in the SDK is correct. Namespace is accessible from the project, otherwise it wouldn't compile. There are no other ways to include it. Can you specify which version of the plugin are you using? Are you using the repo code or the packaged plugin?

from hms-unity-plugin.

manelizzard avatar manelizzard commented on June 8, 2024

I'm using the master branch of this repo. As you said, it's probably an SDK issue (EvilMindDevs/hms-sdk-unity#47).

I suspect the wrapper is correct, but somehow the HuaweiMobileServices.IAP.EnvReadyResult class is not available in the Android SDK (aar), so when the JNI tries to build that object on the Java side, it crashes.

from hms-unity-plugin.

m0skit0 avatar m0skit0 commented on June 8, 2024

I can confirm it's not an SDK issue, the EnvReadyResult class in C# has the correct constructor expected by AsWrapper(). The EnvReadyResult Java class is available on the Huawei AARs. In any case the wrapper in this case does not create the object itself, it just wraps the Java object returned from the Huawei AAR. The problem as far as I understand from the stacktrace is that when the Java EnvReadyResult is returned, the AsWrapper() method cannot find the correct constructor for the C# EnvReadyResult wrapper. However the constructor is there, so the error doesn't really makes sense unless you have a different/outdated DLL.

Since I cannot reproduce this error, to be able to advance in this problem:

  • Is there any way you can make a simple demo that can reproduce this error and share it with me?
  • Can you build the DLL yourself from the SDK repo and use that one instead?

from hms-unity-plugin.

m0skit0 avatar m0skit0 commented on June 8, 2024

Yes, sorry, my mistake, the Java class is IsEnvReadyResult . In any case the Java class name is not relevant; the error is about the C# constructor, not the Java one. We're not instantiating that Java class anywhere in the SDK, just wrapping the instance we're receiving from the HMS SDK in a C# class. This C# class we do instantiate through reflection using the AsWrapper() method:

public static T AsWrapper<T>(this AndroidJavaObject javaObject) where T : JavaObjectWrapper =>
            Activator.CreateInstance(typeof(T), javaObject) as T;

You can see this method called in the stacktrace of the error (last line). So what this is doing is instantiating C# EnvReadyResult with a constructor that has single AndroidJavaObject argument. So EnvReadyResult should have a constructor that takes AndroidJavaObject as a parameter. If you check EnvReadyResult you can see it does have that constructor

public EnvReadyResult(AndroidJavaObject javaObject) : base(javaObject) { }

Now the question remains: why it is complaining about this constructor does not exist?

from hms-unity-plugin.

manelizzard avatar manelizzard commented on June 8, 2024

Indeed. Totally agree. I can see all constructors and classes.

I'm sill investigating trying to find an answer to that question...

from hms-unity-plugin.

m0skit0 avatar m0skit0 commented on June 8, 2024

I think I found the problem. Will fix in the SDK directly.

EvilMindDevs/hms-sdk-unity#49

from hms-unity-plugin.

m0skit0 avatar m0skit0 commented on June 8, 2024

Fixed in commit 6c21d01

from hms-unity-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.