UnityWidget crashing upon loading using flutter_unity_widget

Viewed 300

Ive created a simple flutter program to test out the plugin on flutter. ive set up a simple unity project with a button and imported it using the plugin to the flutter project. everything builds up correctly and my app runs, however the app crashes upon loading the UnityWidget

To Reproduce Steps to reproduce the behavior: create simple app in unity and flutter exported unity as per instructions on Readme moved unityLibrary from 'project Root/unity/android' to 'project Root/android' in order to fix unityLibrary not found build error

UnityWidgetController? overallController;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Second Route'),
      ),
      body: SafeArea(
        top: true,
        bottom: true,
        child: Stack(
          children: [
            UnityWidget(
              onUnityCreated: onUnityCreate,
              borderRadius: BorderRadius.zero,
            ),
          ],
        ),
      ),
    );
  }

  void onUnityCreate(UnityWidgetController controller) {
    overallController = controller;
    controller.postMessage("ButtonManager", "setFromFlutter", "message");
  }

**Unity (please complete the following information): ver 2020.3.5f1

OS: MacOS BigSur 11.4 (20F71)

Smartphone (please complete the following information):

OnePlus 5T Android 10

heres the error message

W/Gralloc3(31563): mapper 3.x is not supported
I/IL2CPP  (31563): JNI_OnLoad
E/_flutter_widge(31563): Invalid ID 0x00000000.
D/AndroidRuntime(31563): Shutting down VM
E/AndroidRuntime(31563): FATAL EXCEPTION: main
E/AndroidRuntime(31563): Process: com.example.unity_flutter_widget, PID: 31563
E/AndroidRuntime(31563): android.content.res.Resources$NotFoundException: String resource ID #0x0
E/AndroidRuntime(31563):    at android.content.res.Resources.getText(Resources.java:367)
E/AndroidRuntime(31563):    at android.content.res.Resources.getString(Resources.java:460)
E/AndroidRuntime(31563):    at com.unity3d.player.UnityPlayer.GetGlViewContentDescription(Unknown Source:20)
E/AndroidRuntime(31563):    at com.unity3d.player.UnityPlayer.<init>(Unknown Source:271)
E/AndroidRuntime(31563):    at com.xraph.plugin.flutter_unity_widget.UnityPlayerUtils$Companion$createPlayer$1.run(UnityPlayerUtils.kt:45)
E/AndroidRuntime(31563):    at android.os.Handler.handleCallback(Handler.java:883)
E/AndroidRuntime(31563):    at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime(31563):    at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime(31563):    at android.app.ActivityThread.main(ActivityThread.java:7697)
E/AndroidRuntime(31563):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(31563):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
E/AndroidRuntime(31563):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
D/ViewRootImpl[MainActivity](31563): windowFocusChanged hasFocus=false inTouchMode=true
I/Process (31563): Sending signal. PID: 31563 SIG: 9
Lost connection to device.
Exited (sigterm)
1 Answers

After a few days of googling, i managed to find the answer. After exporting to android, i needed to enter this

<string name="game_view_content_description">Game view</string>

into the styles.xml file, within the resources tag

it is located in unityLibrary/src/main/res/values

Related