viromedia / viro

ViroReact: AR and VR using React Native
MIT License
2.29k stars 481 forks source link

Android OvrRelease build #13

Closed ashtonlance closed 7 years ago

ashtonlance commented 7 years ago

Okay, I really need some help here.

I've successfully created and installed my "cardboard release" app on my iPhone.

Getting it over to Android for the GearVR is a whole other story. So, when I run from the testbed app or I just run a debug app on my Android - everything works (more or less - the 360videos never load but I'm chalking that up the network). I do have an oculus signature at android/app/src/assets

So I've tried building a release and signing in through Android Studio. Everything seems to install okay - but it crashes on launch. So I ran adb logcat and saw that as soon as it crashes and I'm seeing:

E/AndroidRuntime: FATAL EXCEPTION: mqt_js Process: com.virosample.ovr, PID: 27935 java.lang.RuntimeException: com.facebook.react.devsupport.JSException: Could not get BatchedBridge, make sure your bundle is packaged correctly at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:24) at com.facebook.react.devsupport.DisabledDevSupportManager.handleException(DisabledDevSupportManager.java:158) at com.facebook.react.cxxbridge.CatalystInstanceImpl.onNativeException(CatalystInstanceImpl.java:431) at com.facebook.react.cxxbridge.CatalystInstanceImpl.access$400(CatalystInstanceImpl.java:51) at com.facebook.react.cxxbridge.CatalystInstanceImpl$NativeExceptionHandler.handleException(CatalystInstanceImpl.java:447) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:33) at android.os.Looper.loop(Looper.java:207) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) at java.lang.Thread.run(Thread.java:818) Caused by: com.facebook.react.devsupport.JSException: Could not get BatchedBridge, make sure your bundle is packaged correctly at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) at android.os.Looper.loop(Looper.java:207)  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)  at java.lang.Thread.run(Thread.java:818)  Caused by: com.facebook.jni.CppException: Could not get BatchedBridge, make sure your bundle is packaged correctly at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)  at android.os.Handler.handleCallback(Handler.java:815)  at android.os.Handler.dispatchMessage(Handler.java:104)  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)  at android.os.Looper.loop(Looper.java:207)  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)  at java.lang.Thread.run(Thread.java:818)  04-20 13:49:27.441 874-915/? E/MultiWindowProxy: getServiceInstance failed! 04-20 13:49:32.647 239-455/? E/MAL-Daemon: ( rds_ru_3gpp_status_ind, 1421) [RDS-E][RU][EVENT_RU_DM_3GPP_STATUS_IND] Invalid u43gpp_status:0x6 04-20 13:49:35.629 252-1145/? E/Drm: Failed to find drm plugin 04-20 13:49:35.669 252-1145/? E/Drm: Failed to find drm plugin

So a quick Google regarding BatchedBridge not being found - I see people saying that I need to run react-native start (which worked okay okay) and then run cd android && ./gradlew assembleRelease - this gets me as far as this bit of code:

`:app:bundleOvrReleaseJsAndAssets Loading dependency graph, done. Warning: The transform cache was reset.

'node_modules/react-native/Libraries/CustomComponents/NavigationExperimental/assets/back-icon@4x.android.png' could not be found, because 'node_modules/react-native/Libraries/CustomComponents/NavigationExperimental/assets' is not a subdirectory of any of the roots ('/Users/ashtonl/Development/ViroSample')

:app:bundleOvrReleaseJsAndAssets FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:bundleOvrReleaseJsAndAssets'.

    Process 'command 'node'' finished with non-zero exit value 1

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 55.071 secs`

Now I'm pretty much stuck here. I dunno what else I should try. Help!

achuvm commented 7 years ago

Hi Ashton,

Thanks for trying out the platform.

Quick question are you attempting to do a release or debug build of the app?

Thanks,

ashtonlance commented 7 years ago

@achuvm a release build! Of the Gear VR flavor specifically.

achuvm commented 7 years ago

Hi @atlance01

Can you try running just ./gradlew bundleOvrReleaseJsAndAssets within your /android directory to build just the OVR release bundle.

Thanks,

ashtonlance commented 7 years ago

@achuvm sure!

Here's what I got:

~/Development/ViroSample/android master* ❯ ./gradlew bundleOvrReleaseJsAndAssets NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /Users/ashtonl/Development/Android/ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

Incremental java compilation is an incubating feature. :app:mergeOvrReleaseShaders UP-TO-DATE :app:compileOvrReleaseShaders UP-TO-DATE :app:generateOvrReleaseAssets UP-TO-DATE :app:preBuild UP-TO-DATE :app:preOvrReleaseBuild UP-TO-DATE :app:checkOvrReleaseManifest :app:preGvrDebugBuild UP-TO-DATE :app:preGvrReleaseBuild UP-TO-DATE :app:preOvrDebugBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2500Library :app:prepareComAndroidSupportAppcompatV72500Library :app:prepareComAndroidSupportRecyclerviewV72340Library :app:prepareComAndroidSupportSupportCompat2500Library :app:prepareComAndroidSupportSupportCoreUi2500Library :app:prepareComAndroidSupportSupportCoreUtils2500Library :app:prepareComAndroidSupportSupportFragment2500Library :app:prepareComAndroidSupportSupportMediaCompat2500Library :app:prepareComAndroidSupportSupportV42500Library :app:prepareComAndroidSupportSupportVectorDrawable2500Library :app:prepareComFacebookFbuiTextlayoutbuilderTextlayoutbuilder100Library :app:prepareComFacebookFrescoDrawee0110Library :app:prepareComFacebookFrescoFbcore0110Library :app:prepareComFacebookFrescoFresco0110Library :app:prepareComFacebookFrescoImagepipeline0110Library :app:prepareComFacebookFrescoImagepipelineBase0110Library :app:prepareComFacebookFrescoImagepipelineOkhttp30110Library :app:prepareComFacebookReactReactNative0412Library :app:prepareComFacebookSoloaderSoloader010Library :app:prepareComGoogleAndroidExoplayerExoplayerR220Library :app:prepareOrgWebkitAndroidJscR174650Library :app:prepareViroSampleGvr_commonUnspecifiedLibrary :app:prepareViroSampleReact_viroUnspecifiedLibrary :app:prepareViroSampleViro_rendererUnspecifiedLibrary :app:prepareOvrReleaseDependencies :app:mergeOvrReleaseAssets UP-TO-DATE :app:compileOvrReleaseRenderscript UP-TO-DATE :app:generateOvrReleaseResValues UP-TO-DATE :app:generateOvrReleaseResources UP-TO-DATE :app:mergeOvrReleaseResources UP-TO-DATE :app:bundleOvrReleaseJsAndAssets Loading dependency graph, done. Warning: The transform cache was reset.

'node_modules/react-native/Libraries/CustomComponents/NavigationExperimental/assets/back-icon@4x.android.png' could not be found, because 'node_modules/react-native/Libraries/CustomComponents/NavigationExperimental/assets' is not a subdirectory of any of the roots ('/Users/ashtonl/Development/ViroSample')

:app:bundleOvrReleaseJsAndAssets FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:bundleOvrReleaseJsAndAssets'.

    Process 'command 'node'' finished with non-zero exit value 1

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 57.382 secs

achuvm commented 7 years ago

Hi @atlance01

It sounds like that file is missing so either 1) a different version of react-native is being used or 2) your current installation of react-native was somehow corrupted.

To address the first issue, open your package.json file in your project root and ensure that you're targeting "react-native": "0.41.2". If not, then change it and also blow away your node_modules/ directory and re-run npm install.

To address the second issue, can you try blowing away your node_modules/ directory and re-run npm install.

Let me know if that works!

ashtonlance commented 7 years ago

Thanks for your help!

My package.json showed that I was running the correct version of react-native

So, I wiped out my node_modules folder. Ran npm install again and tada! I should've known - when in doubt, do a node_module reinstall.

So I've got my release OVR running on my phone right now - but none of my videos are playing. They're 720p mp4 360 videos. Any ideas?

achuvm commented 7 years ago

Hi @atlance01

I'm glad that works!

We're not aware of any issues with 360 Video Playback, but to be sure, can you check the device logs to see if there are any errors? Attaching the logs here for us to look at would maybe be helpful too.

Do the videos work on other Viro supported platforms? (iOS Cardboard, Android Cardboard, etc)

Thanks,

ashtonlance commented 7 years ago

Well I'm back to my original issue now - I'm trying to build a new version number and I'm getting my old error again. This time, wiping out the node_modules folder doesn't seem to help :(

What else could be going on? What could be causing that module to keep getting corrupted?

achuvm commented 7 years ago

Hmm, I'm stumped that you're getting the exact same error and the wiping away doesn't help...

The ./gradlew bundleOvrReleaseJsAndAssets command processes your .js files and copies and adds your assets to the android build directories under /android/build and /android/app/build.

Maybe you can try removing them and rebuilding your app?

If the error is different, I'd like to see that.

I'll continue to think more about it and let me know if you discover anything else or if the above worked/didn't work.

ashtonlance commented 7 years ago

@achuvm This morning, I tried updating to Viro 1.1.0, killing all my node modules and wiping out 'android/build' and '/android/app/build' and I'm still getting the same old error!

'node_modules/react-native/Libraries/CustomComponents/NavigationExperimental/assets/back-icon@4x.android.png' could not be found, because 'node_modules/react-native/Libraries/CustomComponents/NavigationExperimental/assets' is not a subdirectory of any of the roots ('/Users/ashtonl/Development/ViroSample')

:app:bundleGvrReleaseJsAndAssets FAILED

ashtonlance commented 7 years ago

@achuvm Update: I created a new Viro project, then immediately ran the asset bundler and everything worked out fine. Then, I copied over my javascript from my old files and BAM! build failed?

My repo is here: https://github.com/atlance01/ViroVRapp

Is there something wrong with my files?

achuvm commented 7 years ago

Hi @atlance01 ,

I pulled the repo and ran ./gradlew bundleOvrReleaseJsAndAssets just fine, although since your video files weren't included in the repo, I changed them to one of our own assets.

I noticed that the videos you do have in the js files have dashes and spaces, etc. Can you try renaming them to something simply alphanumeric ie. VIP 360 VR Montage 03-30-2017 1920x1080.mp4 -> VIP360VRMontage.mp4? I suspect this is possibly an issue, although, not sure why this could cause an error trace like the one you posted above.

If this works, then it's due to how React Native bundles its "assets" by actually placing it into the Android resources directories which cause all sorts of other problems because Android resources have a lot more restrictions on filename/filename collisions than Android assets.

Thanks,

ashtonlance commented 7 years ago

@achuvm ,

First off, I wanna thank you for working so much with me on this. I really wanna get this up and running!

So I tried changing the filenames of the videos as you suggested... and still the same error. I've updated my repo with the latest changes. When you pulled down my repo earlier, were you able to build more than once? It seems like the first build might be okay and then things are getting wonky from there?

Could there be a node version or npm version conflict or anything? I'm running node v7.8.0 with whatever version of npm that comes with it.

achuvm commented 7 years ago

@atlance01

It's no problem at all, we just want to see you guys build something awesome :).

To answer your question, I was able to run ./gradlew bundleOvrReleaseJsAndAssets more than once, with and without removing my /android/build/ and /android/app/build/ directories.

The node/npm version I'm using is:

~/ext-workspace/ViroVRapp$ node -v
v6.6.0
~/ext-workspace/ViroVRapp$ npm -v
4.4.4

I'll try updating my node version and see if I encounter this issue on my end.

In the meantime, can you confirm if you do have the file node_modules/react-native/Libraries/CustomComponents/NavigationExperimental/assets/back-icon@4x.android.png in your project when you encounter the issue?

I also realized that I'm currently still on react-viro 1.0.0 based on the package.json, but you were running into this issue regardless of react-viro version.

ashtonlance commented 7 years ago

Thanks!

I do indeed have that asset! Now the packager is throwing the same error when I try to run the testbed app too.

image

achuvm commented 7 years ago

Closing this issue due to lack of activity.

Feel free to reopen this issue, create another issue or contact us at support@viromedia.com.

Thanks!