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

AndroidJavaException NoSuchFieldError "forceBringToFront" #1121

Open
Enormus opened this issue Dec 11, 2024 · 1 comment
Open

AndroidJavaException NoSuchFieldError "forceBringToFront" #1121

Enormus opened this issue Dec 11, 2024 · 1 comment

Comments

@Enormus
Copy link

Enormus commented Dec 11, 2024

Hello @KojiNakamaru,

First, thank you for your excellent plugin! We've been using it successfully for two years now in our app:

XRAI Glass

which has helped thousands all around the world!

Today we upgraded to the latest unitypackage and we are currently building with Unity 2022.3.50f1. After the upgraded we received the following exception immediately upon start:

2-11 15:14:38.994 E/Unity   (18441): UnityEngine.AndroidJNISafe.CheckException () (at <00000000000000000000000000000000>:0)
12-11 15:14:38.994 E/Unity   (18441): UnityEngine.AndroidJNISafe.GetStaticFieldID (System.IntPtr clazz, System.String name, System.String sig) (at <00000000000000000000000000000000>:0)
12-11 15:14:38.994 E/Unity   (18441): UnityEngine._AndroidJNIHelper.GetFieldID (System.IntPtr jclass, System.String fieldName, System.String signature, System.B
12-11 15:14:38.994 E/Unity   (18441): AndroidJavaException: java.lang.NoSuchFieldError: no "Z" field "forceBringToFront" in class "Lnet/gree/unitywebview/CWebViewPlugin;" or its superclasses
12-11 15:14:38.994 E/Unity   (18441): java.lang.NoSuchFieldError: no "Z" field "forceBringToFront" in class "Lnet/gree/unitywebview/CWebViewPlugin;" or its superclasses
12-11 15:14:38.994 E/Unity   (18441): 	at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
12-11 15:14:38.994 E/Unity   (18441): 	at com.unity3d.player.UnityPlayer.-$$Nest$mnativeRender(Unknown Source:0)
12-11 15:14:38.994 E/Unity   (18441): 	at com.unity3d.player.B0.handleMessage(Unknown Source:122)
12-11 15:14:38.994 E/Unity   (18441): 	at android.os.Handler.dispatchMessage(Handler.java:102)
12-11 15:14:38.994 E/Unity   (18441): 	at android.os.Looper.loopOnce(Looper.java:230)
12-11 15:14:38.994 E/Unity   (18441): 	at android.os.Looper.loop(Looper.java:319)
12-11 15:14:38.994 E/Unity   (18441): 	at com.unity3d.player.C0.run(Unknown Source:24)
12-11 15:14:38.994 E/Unity   (18441):   at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 
12-11 15:14:38.994 E/Unity   (18441):   at UnityEngine.AndroidJNISafe.GetStaticFieldID (System.IntPtr clazz, System.String name, System.String sig) [0x00000] in <00000000000000000000000000000000>:0 
...

Commenting out this single line in WebViewObject.cs resolves the issue and the app seems to function as expected. (I have not tested extensively yet so I don't know if commenting this out has broken anything else.)

#if UNITY_2021_1_OR_NEWER
    //  webView.SetStatic<bool>("forceBringToFront", true); // commenting this out no longer throws
#endif

Thank you so much!

@KojiNakamaru
Copy link
Member

I pushed two branches where one utilizes Packages/manifest.json to import the plugin and another directly imports the plugin by unity-webview.unitypackage. Both work without any issue.

https://github.com/gree/unity-webview/commits/example-for-1121/
https://github.com/gree/unity-webview/commits/example-for-1121b/

You might incompletely import files and still have old *.aar.tmpl. Please remove all files previously imported. Utilizing manifest.json is recommended as Package Manager treats any update correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants