f111fei / react-native-unity-demo

103 stars 80 forks source link

Error when run demo #53

Open TunTin opened 2 years ago

TunTin commented 2 years ago

When I run your demo on Emulator or Device I get the above error, please help me to solve it, thanks

image

ThinhVu commented 2 years ago

It's quite hard to resolve dependencies. Alternative solution is bundling RN source code files in release mode then checking const keyword in this file instead.

To do this thing, use this command at the RN root folder: npx react-native bundle --dev false --platform android --entry-file index.js --bundle-output ./android/app/src/main/assets/react/release/index.android.bundle --assets-dest ./android/app/src/main/res

Note that you should create android/app/src/main/assets/react/release folder before execute this command.

I already check this for you so I certainly sure that this error no longer exist in bundling file. But you'll get another error. "That's how things works".


FYI, later versions of RN using assets/index.android.bundle instead of assets/react/release/index.android.bundle so you may need to change the path to bundle file if you consider upgrate RN version.

ThinhVu commented 2 years ago

If you see an error about String resource 0x0, add these 2 lines of code to strings.xml and it'll work.

<string name="game_view_content_description">Game view</string>
<string name="unity_root">unity_root</string>
ThinhVu commented 2 years ago

Or you can use my forked repo instead:

https://github.com/ThinhVu/react-native-unity-demo

TunTin commented 2 years ago

Thank you, I will try it.