Closed guanghui1987 closed 1 year ago
Hi @guanghui1987
I am having trouble understanding the issue. To take a guess, It sounds like you are missing an android dependency which some code needs. That said, it is hard to tell from you summary what that code is. The solution could be as simple as calling Assets > External Dependency Manager > Android Force Resolve
, but I could be misunderstanding the issue.
Can you provide a sample project which reproduces this issue on the help forum?
I am sure Assets > External Dependency Manager > Android Force Resolve succeeded. But I am not sure the behavior which AndroidJNIHelper.GetFieldID mUnityPlayer is admob or Unity.
Maybe I know the reason. Unity AndroidJavaObject.CallStatic maybe need to access mUnityPlayer. Unity AndroidJavaObject.Call maybe not need to access mUnityPlayer.
I do some testing in my case that is GamePlayActivity no field mUnityPlayer. and the results:
public void Initialize(Action<IInitializationStatusClient> initCompleteAction)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
this.initCompleteAction = initCompleteAction;
AndroidJavaClass val = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject @static = ((AndroidJavaObject)val).GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaClass val2 = new AndroidJavaClass("com.google.android.gms.ads.MobileAds");
((AndroidJavaObject)val2).CallStatic("initialize", new object[2] { @static, this });
}
@guanghui1987
Thanks for checking against different Unity installs, I will take a further look.
@guanghui1987
I was unable to replicate this issue using 2021.3.25f1c1. I am not sure what is happening, but I would need to look at the project or additional logging to figure out what is happening. If you could, can you please open a support case on the on the help forum?
Step 0: Are you in the right place?
For general technical questions, or help with project-specific issues like setting up ads in your app, reach out to our support team on the Developer Forum.
For assistance with your AdMob account, reach out to AdMob Support.
For feedback on our documentation, send your feedback by pressing the Send Feedback button at the top right of the documentation page you are on.
For issues related to the code in this repository, continue filing this GitHub issue.
Once you've read this section and determined that your issue is appropriate for this repository, please delete this section.
[REQUIRED] Step 1: Describe your environment
[REQUIRED] Step 2: Describe the problem
Steps to reproduce:
What happened? How can we make the problem occur? This could be a description, log/console output, etc.
E/Unity: AndroidJavaException: java.lang.NoSuchFieldError: no "Ljava/lang/Object;" field "mUnityPlayer" in class "Lio/wx/gp/play/ui/GamePlayActivity;" or its superclasses java.lang.NoSuchFieldError: no "Ljava/lang/Object;" field "mUnityPlayer" in class "Lio/wx/gp/play/ui/GamePlayActivity;" or its superclasses at com.unity3d.player.UnityPlayer.nativeRender(Native Method) at com.unity3d.player.UnityPlayer.access$800(Unknown Source) at com.unity3d.player.UnityPlayer$g$1.handleMessage(Unknown Source) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:203) at com.unity3d.player.UnityPlayer$g.run(Unknown Source) at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.AndroidJNISafe.GetFieldID (System.IntPtr clazz, System.String name, System.String sig) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine._AndroidJNIHelper.GetFieldID (System.IntPtr jclass, System.String fieldName, System.St
Please share a downloadable sample project that reproduces the bug, if available. This greatly helps us to diagnose and fix the issue faster.
Relevant Code: