Comments (11)
Thanks! This looks like a bug on the SDK, creating issue there: EvilMindDevs/hms-sdk-unity#47
from hms-unity-plugin.
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:
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.
Good catch! Will follow that thread. Thank you!
from hms-unity-plugin.
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.
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.
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.
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.
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.
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.
I think I found the problem. Will fix in the SDK directly.
from hms-unity-plugin.
Fixed in commit 6c21d01
from hms-unity-plugin.
Related Issues (20)
- Fix crash in HuaweiMobileServices.Base.Status.StartResolutionForResultAsync HOT 8
- Build failure:Plugin with id 'com.huawei.agconnect' not found. HOT 11
- hms ads HOT 3
- not working in 2022.3.8f1 lts HOT 2
- This is a test HOT 1
- NullReferenceException: Failed to load the HMSIAPKitSettings. Please restart Unity Editor HOT 7
- HMS Ads not working in internal build HOT 9
- ADS Not Working in HMS 2.3.4 Unity HOT 5
- Errors during build HOT 3
- 调用SilentSignIn登录返回错误码7400 HOT 2
- This is a test HOT 2
- Help with consent HOT 8
- Developer payload cannot be passed thru PurchaseProduct method HOT 7
- Consumption of purchases in InitializeIAP should be optional HOT 6
- 3.2.5 Version on 2020 Unity version is not compling HOT 5
- 请问有没有要使用这个插件接入华为的防沉迷功能应该怎么做? HOT 15
- HMS Unity not working , create run time error (v2.3.5 - Unity 2019/2020/2021) HOT 12
- Disable 'update plugin' process on consoles HOT 3
- Ads not showing in Unity 2022.2.13 HOT 3
- About App-Ads.txt HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hms-unity-plugin.