Hi!
I generated a sample app by using the viro react CLI tool and then, after running ./setup_ide.sh android, I tried to install this app on an emulator running API 24. The app seems to be installed correctly, but when it starts, it closes immediatly. Checking the logs with the logcat tool, it shows that an exception occurred because it couldn't find libviro_renderer.so. Any help with this?
Thanks in advance.
Hi @itsmealves, Viro currently does not support Android emulator. You will have to use an ARCore supported device for development at this time. Let us know if you are still having issues with a device and we can investigate further
Thanks for your response, @dam00n! I'll try in a real device soon.
Just to close it properly, it did work testing on a real device. Thanks @dam00n once again!
Is there anyway this error could be handled silently so that app does not crash?
Hey @TheCodeDestroyer, as @dam00n has mentioned, Viro is not supported on Android emulators at the moment. Since libviro_renderer.so is the core library that contains main Viro components, the application should fail fast and crash when attempting to display it's core AR/VR experience. Also, there isn't really a significant benefit to continue beyond this failure on the emulator.
Having said all that, it is possible to build a 2D/AR hybrid experience with Viro, take a look at https://docs.viromedia.com/docs/android-distribution#targeting-older-android-builds
@dthian Well that applies only if the entire app is just viro components, my app crashed even before anything from viro is required. But I understand its quite counter productive to do some hotfix just to resolve an issue that will most probably be fixed in future(applies to emulators being supported in future). Thank you for your reply, I was just curious how deep the rabbit hole goes 馃槃
Hey guys, i just came across this issue after deploying our app to android. I agree with @TheCodeDestroyer that using viro only as a part of a bigger application is a common usecase. E.g. our app consists of more than 20 screens where just a single one uses viro-ar.
I'd like to start a full crossplatform development that requires to display both simulators for android and ios simultaneously.
@dthian Is there any chance to make it work on the simulator for all non-viro screens? Throwing an error when the ar view opens would be ok for me.
Thanks :-)
I'm in the same boat as oOMoeOo - In my app, A/R is just one of the many features we have. And it's a paid feature, that's mostly turned off. Since installing Viro, we can no longer use the Android emulator. We're fine with not being able to use Viro features in the emulator, but we would like to use the rest of our app.
I'm in the same boat as @ddarren & @oOMoeOo It would definitely help the development process to have everything running on my computer.
@Tino-F @ddarren @oOMoeOo
My solution is tricky but you can do:
_MainApplication.java_
class DummyPackage implements ReactPackage {
@Nonnull
@Override
public List<NativeModule> createNativeModules(@Nonnull ReactApplicationContext reactContext)
{
return Collections.emptyList();
}
@Nonnull
@Override
public List<ViewManager> createViewManagers(@Nonnull ReactApplicationContext reactContext)
{
return Collections.emptyList();
}
}
public class MainApplication extends Application implements ReactApplication {
/////
@Override
protected List<ReactPackage> getPackages() {
List<ReactPackage> additionalPackages = Collections.emptyList();
if (!com.myapp.Application.IsRunningOnEmulator()) {
additionalPackages.add(new ReactViroPackage(ReactViroPackage.ViroPlatform.AR));
}
return Arrays.asList(
new MainReactPackage(),
new RCTMGLPackage(),
new RNFSPackage(),
new RNScreensPackage(),
new AsyncStoragePackage(),
new RNLocalizePackage(),
new RNSoundPackage(),
new LottiePackage(),
new ReactNativeConfigPackage(),
new VectorIconsPackage(),
new SplashScreenReactPackage(),
new KeychainPackage(),
new RNGestureHandlerPackage(),
new RNVersionInfoPackage(),
additionalPackages.stream().findFirst().orElse(new DummyPackage())
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
}
_Application.java_
package com.myapp;
import android.os.Build;
public class Application {
public static boolean IsRunningOnEmulator() {
return (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
|| Build.FINGERPRINT.startsWith("generic")
|| Build.FINGERPRINT.startsWith("unknown")
|| Build.HARDWARE.contains("goldfish")
|| Build.HARDWARE.contains("ranchu")
|| Build.MODEL.contains("google_sdk")
|| Build.MODEL.contains("Emulator")
|| Build.MODEL.contains("Android SDK built for x86")
|| Build.MANUFACTURER.contains("Genymotion")
|| Build.PRODUCT.contains("sdk_google")
|| Build.PRODUCT.contains("google_sdk")
|| Build.PRODUCT.contains("sdk")
|| Build.PRODUCT.contains("sdk_x86")
|| Build.PRODUCT.contains("vbox86p")
|| Build.PRODUCT.contains("emulator")
|| Build.PRODUCT.contains("simulator");
}
}
Most helpful comment
@Tino-F @ddarren @oOMoeOo
My solution is tricky but you can do:
_MainApplication.java_
_Application.java_