Unity (Vuforia) project integrated in Android project shows a black screen on startup

一个人想着一个人 提交于 2019-11-29 15:46:57

问题


My situation:

I created an Android app and an AR Unity app that makes use of Vuforia 7.0.47. The Android app has lots of features, one of the features is the augmented reality made with Unity and Vuforia.

In order to easily include and later on replace the Unity project in the Android project, I exported the Unity app to an Android Studio project and made it a library. After that I added the .aar file inside my Android project.

All of this seems to be working as my Android project is able to detect the UnityPlayerActivity and is able to start an Intent.

I now use the following code (a normal Intent) to start the Unity app inside my Android application:

Intent intent = new Intent(this, UnityPlayerActivity.class);
startActivity(intent);

The problem I have:

Whenever The UnityPlayerActivity starts, you see the Unity splash screen followed by a black screen instead of the camera opening for the AR.

However, when I build the Unity project to my phone everything works fine aswel as when exporting it to an Android studio project and running it from there.

The problem only seems to occur when including it as a library in my existing Android project.

Tutorials and links I used/tried

In order to create a library from the exported project I followed the following tutorial: https://medium.com/@davidbeloosesky/embedded-unity-within-android-app-7061f4f473a

The Logcat

This is the Logcat I get when starting the Intent


回答1:


You need to take VuforiaWrapper.aar file from

ExportedAndroidStudioProject/libs/VuforiaWrapper.aar

and add it to your app in the same directory where you added UnityGame.aar file and add it in gradle as a dependency

 dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation(name: 'UnityGame', ext:'aar')
implementation(name: 'VuforiaWrapper', ext:'aar')}   

Hope this helps you. Good luck




回答2:


As mentioned you have to add VuforiaWrapper.aar

But sometimes you will have to add the dependency as

implementation project(':VuforiaWrapper')
implementation fileTree(dir: 'libs', include: ['*.jar'])


来源:https://stackoverflow.com/questions/49646956/unity-vuforia-project-integrated-in-android-project-shows-a-black-screen-on-st

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!