GamePlayActivity no field mUnityPlayer cause a AndroidJavaException crash
See original GitHub issueStep 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
- Unity version: 2021.3.23f1c1
- Google Mobile Ads Unity plugin version: v8.1.0 and v8.2.0
- Platform: Android (iOS, Android, Unity Editor)
- Platform OS version: Android 7 (eg iOS 10, Android 9)
- Any specific devices issue occurs on: all
- Mediation ad networks used, and their versions: no
[REQUIRED] Step 2: Describe the problem
- java GamePlayActivity really no field “mUnityPlayer” in my case, mUnityPlayer is in other SDK.I use unity as a library;
- Unity C# code, when call MobileAds.Initialize make the problem occur;
Steps to reproduce:
- Yes. GamePlayActivity really no field “mUnityPlayer” in my case, mUnityPlayer is in other SDK.I use unity as a library.
- Unity C# code, when call MobileAds.Initialize trigger;
- UnityPlayer maybe can find by R.id.unitySurfaceView;
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:
List<String> deviceIds = new List<String>() { AdRequest.TestDeviceSimulator };
// Configure TagForChildDirectedTreatment and test device IDs.
RequestConfiguration requestConfiguration =
new RequestConfiguration.Builder()
.SetTagForChildDirectedTreatment(TagForChildDirectedTreatment.Unspecified)
.SetTestDeviceIds(deviceIds).build();
MobileAds.SetRequestConfiguration(requestConfiguration);
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(HandleInitCompleteAction);
Issue Analytics
- State:
- Created 4 months ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
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:
@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?