Search Issue Tracker

By Design

Votes

12

Found in

2021.3.42f1

2022.3.41f1

6000.0.15f1

7000.0.0a1

Issue ID

UUM-78110

Regression

No

[Android] Player freezes when ReflectionHelper getMethodId is called on classes defined in a higher Android API

--

-

Reproduction steps:
1. Open the attached “ASDQWE” project
2. Open the Build Settings Window (File > Build Settings)
3. Check the “Export” checkmark and export the project
4. Open the exported project with Android Studio
5. To the <project>/unityLibrary/src/main/java/UnityPlayerGameActivity.java (or UnityPlayerActivity.java) file make these changes:
5.1. Add new imports:
import android.annotation.TargetApi;
import android.window.OnBackInvokedCallback;
5.2 Add a new class to the same file:
// Make this extend either Activity or GameActivity, to match the Unity activity
class CustomActivity extends GameActivity {

@TargetApi(33)
protected OnBackInvokedCallback getOnBackInvokedCallback()

{ return null; }

}
5.3 Make the UnityPlayerGameActivity (UnityPlayerActivity) extend the new class
6. In the Android Studio, press the “Build” button to launch the app
7. Observe the Player

Expected result: The Player does not freeze
Actual result: The Player freezes and “AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/window/OnBackInvokedCallback” is logged

Reproducible with: 6000.0.15f1
Could not test with: 2021.3.42f1, 2022.3.42f1 (Could not downgrade the project due to compilation errors)

Reproducible environment: MacOS Sonoma 14.5 (Intel), Windows 10 (user’s)
Not reproducible environment: No other environment tested

Reproducible with these devices:
VLNQA00175, Samsung Galaxy Note9 (SM-N960F), Android 10, CPU: Exynos 9 (9810), GPU: Mali-G72
VLNQA00519, Google Pixel 4 (Pixel 4), Android 12, CPU: Snapdragon 855 SM8150, GPU: Adreno (TM) 640
VLNQA00372, Samsung SM-G991U (SM-G991U), Android 12, CPU: Snapdragon 888, GPU: Adreno (TM) 660

Not reproducible with these devices:
VLNQA00547 - samsung Galaxy Tab A8 (SM-X200), CPU: Unisoc Tiger T618, GPU: Mali-G52, OS: 13
{color:#1d1c1d}VLNQA00591 - samsung Galaxy S23 (SM-S911B), CPU: Snapdragon 8 Gen 2 (SM8550), GPU: Adreno 740, OS: 14{color}

Could not test with these devices::
VLNQA00057, Htc One M9+ (HTC_M9pw), Android 6.0, CPU: MediaTek Helio X10 MT6795T, GPU: PowerVR Rogue G6200
VLNQA00146, Htc 10 (HTC 10), Android 8.0.0, CPU: Snapdragon 820 MSM8996, GPU: Adreno (TM) 530
(The API requirements are not met)

  1. Resolution Note:

    Cause of issue is running app with Android 13 feature on Android 12 and lower. Interface OnBackInvokedCallback was added in API 33 (https://developer.android.com/reference/android/window/OnBackInvokedCallback). Cause of issue is JNI trying to parse method with unrecognized return type as it is yet to be defined in future version of Android. If you want to use this feature we recommend using our implementation (https://docs.unity3d.com/6000.0/Documentation/ScriptReference/PlayerSettings.Android-predictiveBackSupport.html)

Comments (3)

  1. lenzol

    Nov 25, 2024 08:14

    I got same problem inmy ar project

  2. crokrel

    Oct 24, 2024 10:10

    I got same problem in flutter project

  3. timbotimbo

    Aug 13, 2024 08:07

    I can also reproduce this on all 2021.3.x and 2022.3.x versions.

    Just use any ARFoundation project, like the "core/AR Mobile" template in Unity Hub.

    This mainly affects Unity-as-a-library, because the embedding app can have different activity contents than simply the unityplayer activity.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.