Git Product home page Git Product logo

react-native-unity-demo's Introduction

react-native-unity-demo

This is a demo project for react-native-unity

Unity Version

Use the master branch (Unity >= 2018.2)

Use unity-2017 branch (Unity = 2018.1) Use unity-2017 branch (Unity < 2018)

How to Build

  1. Open unity/Cube/Assets/test.unity

  2. Click Build => Export Android or Export IOS

cd react-native-unity-demo

npm install

npm run watch

npm run android or npm run ios

Preview

gif

react-native-unity-demo's People

Contributors

f111fei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-unity-demo's Issues

test.unity can't has errors need to be fix

when I do the step : Open unity/Cube/Assets/test.unity

the unity 2017 show lot of error needs to be fix, and when I press the run button

It show me the message of "all compiler error have to be fixed before you can enter playmode"

And my unity version is 2017.4.14f1 Personal

Android export error

Hi, thanks for the plugin first of all,
but i'm having a problem here while trying to export my unity project to android, even tho, i followed the tutorial as it is, fresh project nothing yet added but cube.

says:

DirectoryNotFoundException: Could not find a part of the path 'S:\Codes\Projects\Flutter\vreals\unity\Test AR Polos\Builds\vreals.apk\vreals'. System.IO.__Error.WinIOError (System.Int32 errorCode, System.String maybeFullPath) (at <437ba245d8404784b9fbab9b439ac908>:0) System.IO.FileSystemEnumerableIterator1[TSource].HandleError (System.Int32 hr, System.String path) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.IO.FileSystemEnumerableIterator1[TSource].CommonInit () (at <437ba245d8404784b9fbab9b439ac908>:0) System.IO.FileSystemEnumerableIterator1[TSource]..ctor (System.String path, System.String originalUserPath, System.String searchPattern, System.IO.SearchOption searchOption, System.IO.SearchResultHandler1[TSource] resultHandler, System.Boolean checkHost) (at <437ba245d8404784b9fbab9b439ac908>:0) System.IO.FileSystemEnumerableFactory.CreateFileNameIterator (System.String path, System.String originalUserPath, System.String searchPattern, System.Boolean includeFiles, System.Boolean includeDirs, System.IO.SearchOption searchOption, System.Boolean checkHost) (at <437ba245d8404784b9fbab9b439ac908>:0) System.IO.Directory.InternalGetFileDirectoryNames (System.String path, System.String userPathOriginal, System.String searchPattern, System.Boolean includeFiles, System.Boolean includeDirs, System.IO.SearchOption searchOption, System.Boolean checkHost) (at <437ba245d8404784b9fbab9b439ac908>:0) System.IO.Directory.InternalGetDirectories (System.String path, System.String searchPattern, System.IO.SearchOption searchOption) (at <437ba245d8404784b9fbab9b439ac908>:0) System.IO.Directory.GetDirectories (System.String path, System.String searchPattern, System.IO.SearchOption searchOption) (at <437ba245d8404784b9fbab9b439ac908>:0) Build.Copy (System.String source, System.String destinationPath) (at Assets/Editor/Build.cs:91) Build.DoBuildAndroid () (at Assets/Editor/Build.cs:42)

I also tried to manage to solve the problem by creating the folder required manually. But after that, i face another error regarding build.gradle

I hope this error get solution, in advance.
Thanks

Unexpected Crash when toggling between ReactNative and Unity Screen

Setup

  • Unity 2018.2.14f1
  • iPhone 6s (iOS 12.0.1)
  • Nokia 6.1 (Android 8.1.0).

Problem

The app unexpectedly crashes when changing between ReactNative View and Unity View. Bug can be reproduced 100% times.

iOS

img_87af8a3c910a-1

Android

screenshot_20181106-131859

How to reproduce

  1. Tap "Toogle Unity" on React Native Screen to start Unity Screen
  2. Tap "Cube" on Unity Screen (Counter will go up by one)
  3. Tap "Toggle Unity" on Unity Screen to go back to React Native Screen
  4. Tap "Toggle Unity" on React Native Screen to go back Unity Screen
  5. Crashes on iOS and Android

Library doesn't work with Unity version 2018.2.14f1

It says that com.unity3d.player does not exist

Task :react-native-unity-view:compileDebugJavaWithJavac FAILED
Q:\LocalRepo\react-native-unity-demo-master\node_modules\react-native-unity-view\android\src\main\java\com\reactnative\unity\view\UnityUtils.java:10: error: package com.unity3d.player does not exist
import com.unity3d.player.UnityPlayer;
^
Q:\LocalRepo\react-native-unity-demo-master\node_modules\react-native-unity-view\android\src\main\java\com\reactnative\unity\view\UnityUtils.java:21: error: cannot find symbol
private static UnityPlayer unityPlayer;
^
symbol: class UnityPlayer
location: class UnityUtils
Q:\LocalRepo\react-native-unity-demo-master\node_modules\react-native-unity-view\android\src\main\java\com\reactnative\unity\view\UnityUtils.java:26: error: cannot find symbol
public static UnityPlayer getPlayer() {
^
symbol: class UnityPlayer
location: class UnityUtils
Q:\LocalRepo\react-native-unity-demo-master\node_modules\react-native-unity-view\android\src\main\java\com\reactnative\unity\view\UnityView.java:11: error: package com.unity3d.player does not exist
import com.unity3d.player.UnityPlayer;
^
Q:\LocalRepo\react-native-unity-demo-master\node_modules\react-native-unity-view\android\src\main\java\com\reactnative\unity\view\UnityView.java:19: error: cannot find symbol
private UnityPlayer view;
^
symbol: class UnityPlayer
location: class UnityView
Q:\LocalRepo\react-native-unity-demo-master\node_modules\react-native-unity-view\android\src\main\java\com\reactnative\unity\view\UnityView.java:21: error: cannot find symbol
protected UnityView(Context context, UnityPlayer view) {
^
symbol: class UnityPlayer
location: class UnityView
Q:\LocalRepo\react-native-unity-demo-master\node_modules\react-native-unity-view\android\src\main\java\com\reactnative\unity\view\UnityViewManager.java:12: error: package com.unity3d.player does not exist
import com.unity3d.player.UnityPlayer;
^
Q:\LocalRepo\react-native-unity-demo-master\node_modules\react-native-unity-view\android\src\main\java\com\reactnative\unity\view\UnityUtils.java:49: error: cannot find symbol
unityPlayer = new UnityPlayer(activity);
^
symbol: class UnityPlayer
Q:\LocalRepo\react-native-unity-demo-master\node_modules\react-native-unity-view\android\src\main\java\com\reactnative\unity\view\UnityUtils.java:73: error: cannot find symbol
UnityPlayer.UnitySendMessage(gameObject, methodName, message);
^
symbol: variable UnityPlayer
location: class UnityUtils
Note: Q:\LocalRepo\react-native-unity-demo-master\node_modules\react-native-unity-view\android\src\main\java\com\reactnative\unity\view\UnityViewManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
9 errors

Error while building application

Hey there, I am getting error while building the application running npm run android command
Here is what went wrong

  • What went wrong:
    Could not determine the dependencies of task ':app:preDebugBuild'.

Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
Could not resolve project :UnityExport.
Required by:
project :app > project :react-native-unity-view
> Unable to find a matching variant of project :UnityExport:
- Variant 'debugApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Variant 'debugBundleElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'android-bundle'.
- Variant 'debugMetadataElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Metadata'.
- Required org.gradle.usage 'java-runtime' but no value provided.
- Variant 'debugRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
- Variant 'releaseApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
- Variant 'releaseBundleElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
- Required org.gradle.usage 'java-runtime' and found incompatible value 'android-bundle'.
- Variant 'releaseMetadataElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Metadata'.
- Required org.gradle.usage 'java-runtime' but no value provided.
- Variant 'releaseRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.

Need Help regarding this
Thanks in Advance

Can not build on Xcode 10.2.1 and unity 2019.2.0b1

following the "How to Build"

  1. Open unity/Cube/Assets/test.unity
    OK

  2. Click Build => Export Android or Export IOS
    OK

  3. cd react-native-unity-demo

  4. npm install
    OK

  5. npm run watch
    image

  6. open in xcode and build failure
    UnityInitStartupTime(); //Use of undeclared identifier 'UnityInitStartupTime'

  7. npm run android or npm run ios
    OK

how to fix UnityInitStartupTime() not found ?

Can't build to phone

Using XCode Version 10.2.1, branch master, Unity 2018.2.11f1.

RN 0.57 used in the demo has an issue with this version of XCode, as indicated here: facebook/react-native#21071.

Patched RCTLinking using https://www.npmjs.com/package/patch-package, but still can't build to phone.

Order of operations:
a. npm install
b. installed patch-package
c. updated RCTLinking
d. ran patch-package
e. built from Unity ("Build => ExportiOS")
f. attempted build to iPhone XR

XCode throws error:

CpResource /Users/xzper/workspace/web/npm-package/react-native-unity-demo/ios/UnityExport/Data /Users/Taly/Library/Developer/Xcode/DerivedData/rnunitydemo-gqhpfkldifizajayqsdorbkqxfdb/Build/Products/Debug-iphoneos/rnunitydemo.app/Data (in target: rnunitydemo)
    cd /Users/Taly/Sites/react-native-unity-demo/ios
    builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -resolve-src-symlinks /Users/xzper/workspace/web/npm-package/react-native-unity-demo/ios/UnityExport/Data /Users/Taly/Library/Developer/Xcode/DerivedData/rnunitydemo-gqhpfkldifizajayqsdorbkqxfdb/Build/Products/Debug-iphoneos/rnunitydemo.app

error: /Users/xzper/workspace/web/npm-package/react-native-unity-demo/ios/UnityExport/Data: No such file or directory

Any suggested workarounds?

npm run ios results in CFBundleIdentifier, Does Not Exist, cant run from xcode on device

when running :

npm run ios

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/rnunitydemo.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist

when running same project from xcode:

"_GetAppController", referenced from:
+[RNUnityViewManager handleAppStateDidChange:] in libRNUnityView.a(RNUnityViewManager.o)
-[RNUnityViewManager setBridge:] in libRNUnityView.a(RNUnityViewManager.o)
-[RNUnityView initWithFrame:] in libRNUnityView.a(RNUnityView.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

UnityView not display

I success to build it on real device ,
but UnityView not display ,
must back to home and re-open the app


2018-08-15 15:06:24.037896+0800 rnunitydemo[7811:2394704] [DYMTLInitPlatform] platform initialization successful
2018-08-15 15:06:24.893 [info][tid:main][RCTCxxBridge.mm:214] Initializing <RCTCxxBridge: 0x1741c3390> (parent: <RCTBridge: 0x1740cd5f0>, executor: (null))
2018-08-15 15:06:24.897453+0800 rnunitydemo[7811:2394658] Initializing <RCTCxxBridge: 0x1741c3390> (parent: <RCTBridge: 0x1740cd5f0>, executor: (null))
2018-08-15 15:06:24.970 [warn][tid:main][RCTBridge.m:120] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2018-08-15 15:06:24.970113+0800 rnunitydemo[7811:2394658] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2018-08-15 15:06:25.016 [warn][tid:main][RCTModuleData.mm:69] Module RCTImageLoader requires main queue setup since it overrides init but doesn't implement requiresMainQueueSetup. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-08-15 15:06:25.015880+0800 rnunitydemo[7811:2394658] Module RCTImageLoader requires main queue setup since it overrides init but doesn't implement requiresMainQueueSetup. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-08-15 15:06:25.049 [info][tid:main][RCTRootView.m:295] Running application rnunitydemo ({
initialProps = {
};
rootTag = 1;
})
2018-08-15 15:06:25.049102+0800 rnunitydemo[7811:2394658] Running application rnunitydemo ({
initialProps = {
};
rootTag = 1;
})
2018-08-15 15:06:25.087563+0800 rnunitydemo[7811:2394658] Built from '2018.1/release' branch, Version '2018.1.1f1 (b8cbb5de9840)', Build type 'Release', Scripting Backend 'il2cpp'
2018-08-15 15:06:25.087717+0800 rnunitydemo[7811:2394692] [] nw_connection_get_connected_socket_block_invoke 2 Connection has no connected handler
2018-08-15 15:06:25.098473+0800 rnunitydemo[7811:2394658] -> registered mono modules 0x101783a9c
-> applicationDidFinishLaunching()
2018-08-15 15:06:25.200841+0800 rnunitydemo[7811:2394658] libMobileGestalt MobileGestaltSupport.m:153: pid 7811 (rnunitydemo) does not have sandbox access for frZQaeyWLUvLjeuEK43hmg and IS NOT appropriately entitled
2018-08-15 15:06:25.200925+0800 rnunitydemo[7811:2394658] libMobileGestalt MobileGestalt.c:550: no access to InverseDeviceID (see rdar://problem/11744455)

Setting UIViewControllerBasedStatusBarAppearance to NO is no longer supported.
Apple actively discourages that, and all application-wide methods of changing status bar appearance are deprecated

2018-08-15 15:06:26.687 [info][tid:com.facebook.react.JavaScript] Running application "rnunitydemo" with appParams: {"rootTag":1,"initialProps":{}}. DEV === true, development-level warning are ON, performance optimizations are OFF
2018-08-15 15:06:26.687625+0800 rnunitydemo[7811:2394726] Running application "rnunitydemo" with appParams: {"rootTag":1,"initialProps":{}}. DEV === true, development-level warning are ON, performance optimizations are OFF

2018-08-15 15:06:33.736864+0800 rnunitydemo[7811:2394694] [] nw_connection_get_connected_socket_block_invoke 11 Connection has no connected handler
-> applicationWillResignActive()
-> applicationDidEnterBackground()
-> applicationWillEnterForeground()
2018-08-15 15:06:35.946807+0800 rnunitydemo[7811:2394694] [] nw_connection_get_connected_socket_block_invoke 12 Connection has no connected handler
-> applicationDidBecomeActive()
Renderer: Apple A8 GPU
Vendor: Apple Inc.
Version: OpenGL ES 2.0 Apple A8 GPU - 96.27.1
GLES: 2
GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_depth24 GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_vertex_array_object GL_EXT_blend_minmax GL_EXT_color_buffer_half_float GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_framebuffer GL_EXT_draw_instanced GL_EXT_instanced_arrays GL_EXT_map_buffer_range GL_EXT_occlusion_query_boolean GL_EXT_pvrtc_sRGB GL_EXT_read_format_bgra GL_EXT_separate_shader_objects GL_EXT_shader_framebuffer_fetch GL_EXT_shader_texture_lod GL_EXT_shadow_samplers GL_EXT_sRGB GL_EXT_texture_filter_anisotropic GL_EXT_texture_rg GL_EXT_texture_storage GL_APPLE_clip_distance GL_APPLE_color_buffer_packed_float GL_APPLE_copy_texture_levels GL_APPLE_framebuffer_multisample GL_APPLE_rgb_422 GL_APPLE_sync GL_APPLE_texture_format_BGRA8888 GL_APPLE_texture_max_level GL_APPLE_texture_packed_float GL_IMG_r
ead_format GL_IMG_texture_compression_pvrtc
OPENGL LOG: Creating OpenGL ES 2.0 graphics device ; Context level <OpenGL ES 2.0> ; Context handle 1948410912
Initialize engine version: 2018.1.1f1 (b8cbb5de9840)

Unity Ready !

2018-08-15 15:06:36.901099+0800 rnunitydemo[7811:2394810] [] nw_connection_get_connected_socket_block_invoke 13 Connection has no connected handler
2018-08-15 15:06:38.154015+0800 rnunitydemo[7811:2394716] [] nw_connection_get_connected_socket_block_invoke 14 Connection has no connected handler
UnloadTime: 4.136166 ms
Setting up 1 worker threads for Enlighten.
Thread -> id: 16f7b7000 -> priority: 1
2018-08-15 15:06:38.916779+0800 rnunitydemo[7811:2394716] [] nw_connection_get_connected_socket_block_invoke 16 Connection has no connected handler

Could not find method bundle() for arguments

Getting this issue, not really sure why as bundle is in my build.gradle

  • Where: Build file 'C:\Users****\Documents\GitHub\react-native-unity-demo\android\UnityExport\build.gradle' line: 78 * What went wrong: A problem occurred evaluating project ':UnityExport'. > Could not find method bundle() for arguments [build_2nxm6hxyy0df3z06p7r6bwen4$_run_closure3$_closure12@1ad6f36] on object of type co m.android.build.gradle.LibraryExtension.
    --

Error when run demo

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

image

Get error when build example project

When I build your example project I get this error and as far as I find out it's because I haven't added the project's certificate to the cacerts of JDK file as shown below but Can you show me how to generate the peoject certificate file is that Okay?

image

Android Background Transparency

This may be unrelated but I have been trying to get a transparent background for Unity so you can see react-native components underneath the react-native-unity-view for Android, I have got it working for iOS.

For Android I have tried:
Preserve frame buffer alpha = true,
Set Camera to solid color RGBA { 0, 0, 0, 0 },
Using OpenGLES3

My problem is that the background is simply rendered as black, however if I ran the Unity Export by itself as an apk then it is clearly transparent. I am just wondering if there is something that react-native-unity-view does to the Unity Player that would remove this transparency.

Undefined symbols for architecture arm64: "_onUnityMessage", referenced from:

Hi,
first I want to say thank you for this react-native plugin !
It could be a best plugin to combine react-native & Unity

I have a problem with the installation of your demo.
First I had this issue : #2
It solve my first problem but a second has arrived.

Undefined symbols for architecture arm64: "_onUnityMessage", referenced from:

I'm on Unity 2017.2.0f3 & XCode 9.3

Have you an idea ?
Thanks a lot !

Cannot find Library.Extension

Hi all,
I am trying to import a Unity project in my react native application. I tried following the general instructions and it resulted in an error. Now i cloned this example file, followed the intructions and the same error appears. It is this one:

Could not find method bundle() for arguments [build_99q93k10d6vp7m7tejceyj4qi$_run_closure3$_closure12@6612fee7] on object of type com.android.build.gradle.LibraryExtension.

Any idea how I can solve this? in both cases i followed step by step the instructions that were given and in both cases this is the error i have

Thank you, silvia

'RegisterMonoModules.h' file not found on Unity 2019.3.0 and Xcode 11.3

I am just trying to get the demo project to build by following the instructions but I only get as far as here. I have seen reference to this error on the npm package repo but I don't see a clear fix.

image

Environment


  "dependencies": {
    "react": "16.5.0",
    "react-native": "0.57.0",
    "react-native-unity-view": "^1.3.0"
  },
  "devDependencies": {
    "@types/react": "^16.0.36",
    "@types/react-native": "^0.52.8",
    "babel-jest": "22.2.0",
    "metro-react-native-babel-preset": "^0.45.0",
    "jest": "22.2.1",
    "react-test-renderer": "16.2.0",
    "typescript": "^2.7.1"
  },

"Unity Click Count" always 0

I guess there is something wrong with the message bus. I tapped everywhere but the counter does not increase. Can anyone verify that the message bus is working as expected?

Unable to successfully execute: npm run ios and android

I am try to setup this demo project:

My development environment is as follows:

Unity: 2018.3.11f1
Xcode: 10.2
Android Studio: 3.0

I have project under unity/Cube/Assets/test.unity inside Unity. And the next step was to try doing Build > Export Android / Export iOS.

Export Android build fine, but when I do npm run android after "npm install" it says

* Where:
Build file '/Users/saudahmed/Downloads/react-native-unity-demo-master/android/UnityExport/build.gradle' line: 78

* What went wrong:
A problem occurred evaluating project ':UnityExport'.
> Could not find method bundle() for arguments [build_cxleajmcepp8gnsdjtwlgsv2v$_run_closure3$_closure12@4ef76084] on object of type com.android.build.gradle.LibraryExtension.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

When i do npm run ios it gives

> [email protected] ios /Users/saudahmed/Downloads/react-native-unity-demo-master
> node node_modules/react-native/local-cli/cli.js run-ios

Found Xcode project rnunitydemo.xcodeproj

Could not find iPhone 6 simulator

Error: Could not find iPhone 6 simulator

I am not able todo anything after it. the readme is incomplete to state.

Native Componet "UnityView" Does not exist

I swapped out the cube unity project with my own, followed the instructions and built for IOS. But when running from XCode on a iphone I get this issue. Any troubleshooting ideas?

The type or namespace name `Reporting' does not exist in the namespace

  1. i just simply copy the Build.cs script and encounter this problem, any solution? i got this error:
    Assets/Scripts/Editor/Build.cs.cs(9,39): error CS0234: The type or namespace name Reporting' does not exist in the namespace UnityEditor.Build'. Are you missing an assembly reference?

  2. the build button require me to change the 'Package Name', what is the package name should i give? thank you

i use Unity 2017.4.3f1

Native component for "UnityView" does not exist

I ran the following commands:
git clone https://github.com/f111fei/react-native-unity-demo
cd react-native-unity-demo
npm install
react-native upgrade
react-native link react-native-unity-view
npm run watch
npm run ios

When building with npm run ios I get the following error:

ld: warning: object file (~/code/rn_unity/ios/build/Build/Products/Debug-iphonesimulator/libRNUnityView.a(RNUnityViewManager.o)) was built for newer iOS version (11.2) than being linked (8.0)
ld: warning: object file (~/code/rn_unity/ios/build/Build/Products/Debug-iphonesimulator/libRNUnityView.a(UnityUtils.o)) was built for newer iOS version (11.2) than being linked (8.0)
ld: warning: object file (~/code/rn_unity/ios/build/Build/Products/Debug-iphonesimulator/libRNUnityView.a(RNUnityView.o)) was built for newer iOS version (11.2) than being linked (8.0)
Undefined symbols for architecture x86_64:
  "_GetAppController", referenced from:
      +[RNUnityViewManager handleAppStateDidChange:] in libRNUnityView.a(RNUnityViewManager.o)
      -[RNUnityViewManager setBridge:] in libRNUnityView.a(RNUnityViewManager.o)
      -[RNUnityView initWithFrame:] in libRNUnityView.a(RNUnityView.o)
  "_UnityInitRuntime", referenced from:
      _InitUnity in libRNUnityView.a(UnityUtils.o)
  "_UnitySendMessage", referenced from:
      _UnityPostMessage in libRNUnityView.a(UnityUtils.o)
  "RegisterFeatures()", referenced from:
      _InitUnity in libRNUnityView.a(UnityUtils.o)
  "RegisterMonoModules()", referenced from:
      _InitUnity in libRNUnityView.a(UnityUtils.o)
  "UnityInitTrampoline()", referenced from:
      _InitUnity in libRNUnityView.a(UnityUtils.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)



** BUILD FAILED **

And when the app comes up on the emulator I am seeing:

Invariant Violation: Native component for "UnityView" does not exist

I feel like I must be missing a step. Is it clear what I'm doing wrong?

For more information:
npm = 6.0.0
node = v8.11.1
unity = 2017.4

This demo is not working in iOS platform. After run "npm run watch" command as per mentioned steps, shows below error in terminal.

After run "npm run watch" command as per mentioned steps then shows below error in terminal.

node_modules/@types/react-native/index.d.ts:8745:18 - error TS2717: Subsequent property declarations must have the same type.  Property 'geolocation' must be of type 'Geolocation', but here has type 'GeolocationStatic'.
8745         readonly geolocation: Geolocation;
                      ~~~~~~~~~~~
node_modules/@types/yargs/index.d.ts:212:106 - error TS2304: Cannot find name 'unknown'.
212         demand<K extends string>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<T & { [key in K]: unknown }>;
                                                                                                             ~~~~~~~
node_modules/@types/yargs/index.d.ts:225:112 - error TS2304: Cannot find name 'unknown'.
225         demandOption<K extends string>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<T & { [key in K]: unknown }>;
                                                                                                                   ~~~~~~~
node_modules/@types/yargs/index.d.ts:575:28 - error TS2304: Cannot find name 'unknown'.
575         [argName: string]: unknown;
                               ~~~~~~~
node_modules/@types/yargs/index.d.ts:733:9 - error TS2304: Cannot find name 'unknown'.
733         unknown;
            ~~~~~~~
Found 5 errors. Watching for file changes.

Could not find path for Manifest and incorrect build path on build for android

Ok, so i had this two issues.

Both fixed in Build.cs . In comments after // ... it is version which was before changes!

public static void DoBuildAndroid()
{
string buildPath = Path.Combine(apkPath); // -not working version Path.Combine(apkPath, Application.productName);
string exportPath = Path.GetFullPath(Path.Combine(ProjectPath, "../../android/UnityExport"));

    if (Directory.Exists(apkPath))
        Directory.Delete(apkPath, true);

    if (Directory.Exists(exportPath))
        Directory.Delete(exportPath, true);

    EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle;

    var options = BuildOptions.AcceptExternalModificationsToPlayer;
    var report = BuildPipeline.BuildPlayer(
        GetEnabledScenes(),
        apkPath,
        BuildTarget.Android,
        options
    );

    if (report.summary.result != BuildResult.Succeeded)
        throw new Exception("Build failed");

    Copy(buildPath, exportPath);

    // Modify build.gradle
	var build_file = Path.Combine(exportPath, "build.gradle");
	var build_text = File.ReadAllText(build_file);
	build_text = build_text.Replace("com.android.application", "com.android.library");
    build_text = build_text.Replace("implementation fileTree(dir: 'libs', include: ['*.jar'])", "api fileTree(include: ['*.jar'], dir: 'libs')");
    // build_text = build_text.Replace("implementation(name: 'VuforiaWrapper', ext:'aar')", "api(name: 'VuforiaWrapper', ext: 'aar')");
	build_text = Regex.Replace(build_text, @"\n.*applicationId '.+'.*\n", "\n");
	File.WriteAllText(build_file, build_text);

    // Modify AndroidManifest.xml
    var manifest_file = Path.Combine(exportPath, "unityLibrary/src/main/AndroidManifest.xml"); //   -not working version, missed 'unityLibrary/' + src/main/AndroidManifest.xml");
    var manifest_text = File.ReadAllText(manifest_file);
    manifest_text = Regex.Replace(manifest_text, @"<application .*>", "<application>");
    Regex regex = new Regex(@"<activity.*>(\s|\S)+?</activity>", RegexOptions.Multiline);
    manifest_text = regex.Replace(manifest_text, "");
    File.WriteAllText(manifest_file, manifest_text);
}

Cheers!

Build/Export iOS Error

hi! thanks for this package!

I'm getting this error in Unity when running Build -> Export iOS. I'm not familiar with Unity, any ideas what might be going on here?

To reproduce:

  1. Open unity/Cube/Assets/test.unity (using Unity v. 2017.2.0f3)

  2. Click Build => Export IOS

Assets/Scripts/UnityMessageManager.cs(143,10): error CS0111: A member 
'UnityMessageManager.onUnityMessage(string)' is already defined. Rename this member or use 
different parameter types

Error building Player because scripts had compiler errors

Exception: Build failed: 2 errors
Build.DoBuildIOS () (at Assets/Scripts/Editor/Build.cs:78)

screenshot 2018-05-26 13 06 10

Fails to register native method for 'isAutoRotationOn'

On a Samsung Galaxy S7 Edge I'm receiving the following error:

03-23 10:30:12.444 20044-20044/? E/art: Failed to register native method com.unity3d.player.UnityPlayer.nativeIsAutorotationOn()Z in /data/app/com.rnunitydemo-1/split_lib_dependencies_apk.apk:classes33.dex
03-23 10:30:12.445 20044-20044/? E/art: ----- class 'Lcom/unity3d/player/UnityPlayer;' cl=0x12caba90 -----

Will let you know if I figure anything out but perhaps you have some better intution about this?

(I'm using Unity 2017.3.1p2 to compile, fyi)

Could not get unknown property 'MYAPP_RELEASE_STORE_FILE'

after using npm run android I get the following error:

FAILURE: Build failed with an exception.

* Where:
Build file '/home/jose/tmp/react-native-unity-demo/android/app/build.gradle' line: 129

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not get unknown property 'MYAPP_RELEASE_STORE_FILE' for SigningConfig_Decorated{name=release, storeFile=null, storePassword=null, keyAlias=null, keyPassword=null, storeType=null, v1SigningEnabled=true, v2SigningEnabled=true} of type com.android.build.gradle.internal.dsl.SigningConfig.

iOS Message / Unity view enabled as default

I am able to run the demo, that is working fine on Android, but on iOS the message isn't received from Unity. Am I missing something?

I also would like to have the Unity view starting already enabled instead of clicking on "Toggle Unity", but just changing the state.renderUnity to true doesn't work.

Any idea?
My Unity version is 2017.4.0f1 and React Native is 0.53.0.

Thanks!

react-native-unity-demo/ios/UnityExport/Classes/UnityAppController.mm:519:13: no matching function for call to 'objc_msgSend'

Hello!

First I would like to thanks you for this effort!

  • Using code from master (24/06/2018)
  • Unity version 2018.1.3f1
  • Xcode 9.4.1

I have been trying to run the demo on iOS but haven't been able to do it. Initially I got this error:

Scanning folders for symlinks in /Users/federico/code/react-native-unity-demo/node_modules (12ms)
Found Xcode project rnunitydemo.xcodeproj
We couldn't boot your defined simulator due to an already booted simulator. We are limited to one simulator launched at a time.
Launching iPhone 6 (iOS 11.4)...
Building using "xcodebuild -project rnunitydemo.xcodeproj -configuration Debug -scheme rnunitydemo -destination id=1CB7B72C-5493-4834-A164-E16E25D0C743 -derivedDataPath build"
xcodebuild: error: The project named "rnunitydemo" does not contain a scheme named "rnunitydemo". The "-list" option can be used to find the names of the schemes in the project.

Installing build/Build/Products/Debug-iphonesimulator/rnunitydemo.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=22):
Failed to install the requested application
The bundle identifier of the application could not be determined.
Ensure that the application's Info.plist contains a value for CFBundleIdentifier.
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/rnunitydemo.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Then to fix it I duplicated the rndemo schema and named it rnunitydemo. After that I get the following error:

▸ Check Dependencies
▸ Precompiling UnityExport/Classes/Prefix.pch
▸ Compiling rnunitydemo_vers.c
▸ Compiling AppDelegate.m
▸ Compiling main.m
▸ Compiling CrashReporter.mm
▸ Compiling UnityAppController+UnityInterface.mm
▸ Compiling UnityAppController+Rendering.mm
▸ Compiling UnityAppController.mm

❌  /Users/federico/code/react-native-unity-demo/ios/UnityExport/Classes/UnityAppController.mm:519:13: no matching function for call to 'objc_msgSend'

            UNITY_OBJC_CALL_ON_SELF(_self, @selector(setFrameInterval:), SetFrameIntervalFunc, (int)(60.0f / fps));
                       ^


▸ Compiling iPhone_Sensors.mm
▸ Compiling main.mm
▸ Compiling Bulk_Assembly-CSharp_0.cpp
▸ Compiling Bulk_Generics_0.cpp
▸ Compiling Bulk_Generics_1.cpp
▸ Compiling Bulk_Generics_2.cpp
▸ Compiling Bulk_Generics_3.cpp
▸ Compiling Bulk_Generics_4.cpp
** BUILD FAILED **


The following commands produced analyzer issues:

	Analyze Base/RCTModuleMethod.mm normal x86_64
(1 command with analyzer issues)

The following build commands failed:
	CompileC build/Build/Intermediates.noindex/rnunitydemo.build/Debug-iphonesimulator/rnunitydemo.build/Objects-normal/x86_64/UnityAppController.o UnityExport/Classes/UnityAppController.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

Installing build/Build/Products/Debug-iphonesimulator/rnunitydemo.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=22):
Failed to install the requested application
The bundle identifier of the application could not be determined.
Ensure that the application's Info.plist contains a value for CFBundleIdentifier.
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/rnunitydemo.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Any help is very much appreciated, and I am willing to contribute to the project. Let me know how can I help!

why run app defualt show untiy view

i use "react-native": "0.57.3",
"react-native-unity-view": "^1.1.6",
my first view is an rn view,but when i run the src by xcode ,show the untiy view by default,can not reach my other rn view.

Build fail on Android. Cannot invoke method ndk() on null object

Error: Cannot invoke method ndk() on null object

Output of running ./gradlew --stacktrace:

Caused by: java.lang.NullPointerException: Cannot invoke method ndk() on null object
at build_9w0ju6ghzv8qetl0kt4hr45xk$_run_closure3$_closure6.doCall(/Users/hitwicket/Code/ReactNative/HitwicketArenas/android/UnityExport/build.gradle:31)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:71)
at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:160)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:106)
at org.gradle.util.ConfigureUtil$1.execute(ConfigureUtil.java:123)
at com.android.build.gradle.BaseExtension.defaultConfig(BaseExtension.java:431)
at com.android.build.gradle.LibraryExtension_Decorated.defaultConfig(Unknown Source)
at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:464)
at org.gradle.internal.metaobject.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:176)
at org.gradle.internal.metaobject.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:96)

'RegisterMonoModules.h' file not found

Hey - very awesome project excited to try this out.
Unfortunately the instructions you have in the read me are not working for me...

When I try to run npm run ios I get this output:

MacBook-Pro:react-native-unity-demo cenotaph65$ npm run ios
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'ios' ]
npm info using [email protected]
npm info using [email protected]
npm verb run-script [ 'preios', 'ios', 'postios' ]
npm info lifecycle [email protected]~preios: [email protected]
npm info lifecycle [email protected]~ios: [email protected]

> [email protected] ios /Users/cenotaph65/Documents/react-native-unity-demo
> node node_modules/react-native/local-cli/cli.js run-ios

Scanning folders for symlinks in /Users/cenotaph65/Documents/react-native-unity-demo/node_modules (10ms)
Found Xcode project rnunitydemo.xcodeproj
Launching iPhone 6 (iOS 11.3)...
Building using "xcodebuild -project rnunitydemo.xcodeproj -configuration Debug -scheme rnunitydemo -destination id=0AA60518-BFB2-46F2-8AB0-BA1F144C2972 -derivedDataPath build"
User defaults from command line:
    IDEDerivedDataPathOverride = /Users/cenotaph65/Documents/react-native-unity-demo/ios/build


xcodebuild: error: The project named "rnunitydemo" does not contain a scheme named "rnunitydemo". The "-list" option can be used to find the names of the schemes in the project.

Installing build/Build/Products/Debug-iphonesimulator/rnunitydemo.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/rnunitydemo.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist

When I try to open the project using XCode, the build fails with:

screen shot 2018-05-24 at 2 18 18 pm

Will keep trying things but any advice would be appreciated!

Thanks

  • J

Crashes on Android due to error "libmain.so not found" with RN > 0.60

While everything works fine with React Native below any version under 0.60 (and already reported at As already reported in f111fei/react-native-unity-view#142), on Android the application will crash upon activating the UnityView with RN > 0.60.

The final error happens because of a "libmain.so" could not be loaded:

E Unity   : Failed to load 'libmain.so', the application will terminate.
D AndroidRuntime: Shutting down VM
E AndroidRuntime: FATAL EXCEPTION: main
E AndroidRuntime: Process: com.rnunitydemo, PID: 16887
E AndroidRuntime: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.rnunitydemo-bKGyotdcwjVnBxuR9zLE4Q==/base.apk"],nativeLibraryDirectories=[/data/app/com.rnunitydemo-bKGyotdcwjVnBxuR9zLE4Q==/lib/arm64, /data/app/com.rnunitydemo-bKGyotdcwjVnBxuR9zLE4Q==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]] couldn't find "libmain.so"

According to a crash-report in the official Unity-Forum, we took care to use the same settings in both build.gradle for ndk-abiFilter:

android {
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 28
        ndk {
            abiFilters 'armeabi-v7a', 'x86'
        }
        multiDexEnabled true
        versionCode 1
        versionName '0.1'
    }
}

but it won't fix the issue. There is a big chance that the issues f111fei/react-native-unity-view#120 and f111fei/react-native-unity-view#129 might be related to this one.

Anybody found a proper solution for this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.