viro
viro copied to clipboard
ViroVideo is getting stuck if I use it
Requirements:
Please go through this checklist before opening a new issue
- [X] Review the documentation
- [X] Search for existing issues in: viromedia/viro & ViroCommunity/viro
- [X] Use the latest ViroReact release
Environment
Please provide the following information about your environment:
- Development OS: Mac
- Device OS & Version: Android 12
- Version: 2.23.0
- Device(s): Android Xiaomi Poco Phone
Description
I am trying to use ViroVideo, I am not having problems with installation, but if i use VIroVideo the app crash, I have been trying with media scenas, ViroNodes, and other techniques that I found on internet. Someone can help me ? this is my code:
import React, { useState, useEffect } from 'react';
import { StyleSheet } from 'react-native';
import {
ViroARScene,
ViroARSceneNavigator,
ViroARTrackingTargets,
ViroARImageMarker,
ViroVideo,
ViroTrackingStateConstants,
} from '@viro-community/react-viro';
const HelloWorldSceneAR = () => {
const [isTracking, setIsTracking] = useState(false);
const [isVideoPlaying, setIsVideoPlaying] = useState(false);
useEffect(() => {
ViroARTrackingTargets.createTargets({
testImage: {
source: require('./app/assets/images/ollie.jpeg'),
orientation: 'Up',
physicalWidth: 0.1, // Ancho fΓsico del marcador en metros
},
});
}, []);
const onInitialized = (state, reason) => {
if (state === ViroTrackingStateConstants.TRACKING_NORMAL) {
setIsTracking(true);
} else {
setIsTracking(false);
}
};
const onAnchorFound = (anchor) => {
setIsVideoPlaying(true);
};
return (
<ViroARScene onTrackingUpdated={onInitialized}>
<ViroARImageMarker target="testImage" onAnchorFound={onAnchorFound}>
<ViroVideo
source={require('./app/assets/videos/480p.mp4')}
paused={!isTracking || !isVideoPlaying}
loop={true}
transformBehaviors={['billboard']}
/>
</ViroARImageMarker>
</ViroARScene>
);
};
const App = () => {
return (
<ViroARSceneNavigator autofocus={true} initialScene={{ scene: HelloWorldSceneAR }} style={styles.f1} />
);
};
const styles = StyleSheet.create({
f1: { flex: 1 },
});
export default App;
My dependencies on package.json
"dependencies": {
"@viro-community/react-viro": "^2.23.0",
"react": "18.2.0",
"react-native": "0.71.8"
},
"typescript": "4.8.4"
Reproducible Demo
Just add ViroVideo component and the app crash and the console don't show any error
on android studio i am getting this error:
java_vm_ext.cc:594] JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception java.lang.NoSuchMethodError: No direct method <init>(Lcom/google/android/exoplayer2/upstream/BandwidthMeter;)V in class Lcom/google/android/exoplayer2/trackselection/AdaptiveTrackSelection$Factory; or its super classes (declaration of 'com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection$Factory' appears in /data/app/~~Vug9ilRT7GjQDkDHltGrmw==/com.artear-tWqGys52-EPeneXQz4HZQg==/base.apk) java_vm_ext.cc:594] at void com.viro.core.internal.AVPlayer.<init>(long, android.content.Context) (AVPlayer.java:98) java_vm_ext.cc:594] at void com.viro.core.internal.PlatformUtil.runTask(int) (PlatformUtil.java:-2) java_vm_ext.cc:594] at void com.viro.core.internal.PlatformUtil.access$000(int) (PlatformUtil.java:77) java_vm_ext.cc:594] at void com.viro.core.internal.PlatformUtil$TaskRunnable.run() (PlatformUtil.java:97) java_vm_ext.cc:594] at void android.opengl.GLSurfaceView$GLThread.guardedRun() (GLSurfaceView.java:1502) java_vm_ext.cc:594] at void android.opengl.GLSurfaceView$GLThread.run() (GLSurfaceView.java:1272) java_vm_ext.cc:594] java_vm_ext.cc:594] in call to NewGlobalRef java_vm_ext.cc:594] from void com.viro.core.internal.PlatformUtil.runTask(int)
Can you give it a try with React Native version 0.68?
I'm getting the same error. Checked upgreding to rn 0.68.7 but still no luck.
I moved to starter kit, i install all the dependecies, but you will need install your packages with --legacy-peer-deps
after that I opened the android folder on android studio and the android studio show some errors and helpers that will help you fix the dependencies that are broken. take a look if you need more details I can help you
Thanks fernando for the reply.
I cannot event bring up the starter-kit without anything else:
package.json:
"dependencies": {
"@viro-community/react-viro": "^2.20.2",
"react": "17.0.2",
"react-native": "0.65.1"
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/runtime": "^7.15.3",
"@react-native-community/eslint-config": "^3.0.0",
"babel-jest": "^27.0.6",
"eslint": "^7.32.0",
"jest": "^27.0.6",
"metro-react-native-babel-preset": "^0.66.2",
"react-native-codegen": "^0.0.7",
"react-test-renderer": "17.0.2"
},
app build.gradle:
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation project(':gvr_common')
implementation project(':arcore_client')
implementation project(':react_viro')
implementation project(':viro_renderer')
implementation 'com.google.android.exoplayer:exoplayer:2.17.1'
implementation 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7'
project build.gradle:
buildscript {
ext {
RNNKotlinVersion = "1.5.31"
kotlinVersion = "1.5.31"
buildToolsVersion = "28.0.3"
playServicesVersion = "18.0.0"
supportLibVersion = "28.0.0"
androidMapsUtilsVersion = "2.3.0"
minSdkVersion = 24
compileSdkVersion = 33
targetSdkVersion = 33
}
repositories {
google()
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
classpath('com.android.tools.build:gradle:7.0.2')
classpath 'com.google.gms:google-services:4.3.3' // Google Services plugin
}
}
Hello @robertjcolley, I also have the same error. When I try to debug log using flipper, I get an error like this:
java_vm_ext.cc:577] JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/media3/exoplayer/trackselection/DefaultTrackSelector; java_vm_ext.cc:577] at void com.viro.core.internal.AVPlayer.(long, android.content.Context) (AVPlayer.java:91) java_vm_ext.cc:577] at void com.viro.core.internal.PlatformUtil.runTask(int) (PlatformUtil.java:-2) java_vm_ext.cc:577] at void com.viro.core.internal.PlatformUtil.-$$Nest$smrunTask(int) (PlatformUtil.java:-1) java_vm_ext.cc:577] at void com.viro.core.internal.PlatformUtil$TaskRunnable.run() (PlatformUtil.java:97) java_vm_ext.cc:577] at void android.opengl.GLSurfaceView$GLThread.guardedRun() (GLSurfaceView.java:1510) java_vm_ext.cc:577] at void android.opengl.GLSurfaceView$GLThread.run() (GLSurfaceView.java:1272) java_vm_ext.cc:577] Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.media3.exoplayer.trackselection.DefaultTrackSelector" on path: DexPathList[[zip file "/data/app/~~6h859rJAnqdl5JLFWjXt2Q==/com.rnplaygroundarea-5U60Yu9A1U_bCFYeMAKWMQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~6h859rJAnqdl5JLFWjXt2Q==/com.rnplaygroundarea-5U60Yu9A1U_bCFYeMAKWMQ==/lib/arm64, /data/app/~~6h859rJAnqdl5JLFWjXt2Q==/com.rnplaygroundarea-5U60Yu9A1U_bCFYeMAKWMQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64, /vendor/lib64, /odm/lib64]] java_vm_ext.cc:577] at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:207) java_vm_ext.cc:577] at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379) java_vm_ext.cc:577] at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312) java_vm_ext.cc:577] at void com.viro.core.internal.AVPlayer. (long, android.content.Context) (AVPlayer.java:91) java_vm_ext.cc:577] at void com.viro.core.internal.PlatformUtil.runTask(int) (PlatformUtil.java:-2) java_vm_ext.cc:577] at void com.viro.core.internal.PlatformUtil.-$$Nest$smrunTask(int) (PlatformUtil.java:-1) java_vm_ext.cc:577] at void com.viro.core.internal.PlatformUtil$TaskRunnable.run() (PlatformUtil.java:97) java_vm_ext.cc:577] at void android.opengl.GLSurfaceView$GLThread.guardedRun() (GLSurfaceView.java:1510) java_vm_ext.cc:577] at void android.opengl.GLSurfaceView$GLThread.run() (GLSurfaceView.java:1272) java_vm_ext.cc:577] java_vm_ext.cc:577] in call to NewGlobalRef java_vm_ext.cc:577] from void com.viro.core.internal.PlatformUtil.runTask(int)