4

I'm new to Unity development. So, I would like to say sorry if my question is worthless for a thread.

I started learning to develop an application in Unity for GearVR. In my scenario, I want to export Unity app as Google Android Project to Eclipse for further development. In Eclipse, I pass a message to a function in Unity through Sendmessage().

My first step was to develop the application and running in Note4 without enabling "Virtual Reality Support". It worked fine.

However, later I enabled "Virtual Reality Support" and export as a Google Android Project. Then, tried to install and run the application through Eclipse. But app crashed. Errors I was able to find in LogCat were "Fatal signal 11 (SIGSEGV) at 0xfa57132b (code=1), thread 9384 (UnityMain)" and "Unable to find OVRPlugin".

Then, I used "Build and Run" in Unity to install the app to Note4. This time, it worked fine.

So, app doesn't work when "Virtual Reality Support" is enabled and install through Eclipse after exporting it as a Google Android Project.

I reverse engineered the apk created by Unity when I used "Build and Run". I noticed some differences in exported Google Android Project and Reverse Engineered apk Projects. Specially, contents in libs folder were different.

It would be great if anyone can help me to solve this issue.

Shanaka R
  • 101
  • 7
  • What unity version and why are you still using eclipse? Google stop updating their API to be compatible with Eclipse long time ago. Android Studio is the new way to develop for Android. – Programmer Mar 30 '16 at 06:50
  • I use Unity 5.3.4p1. Unity exports it as an Android project for Eclipse. That's why I use Eclipse. But as far as I know, it doesn't matter what the IDE you use for Unity since it works fine when "Virtual Reality Support" is disabled. – Shanaka R Mar 30 '16 at 07:22
  • "Unity exports it as an Android project for Eclipse" NOT really. Unity 5 was updated to work with Android Studio too. Just Build with **Google Android Project** checked then import it into Android Studio. Android Studio is always up to date. Try that first. – Programmer Mar 30 '16 at 07:48
  • I tried it. But it's the same result. App crashed. – Shanaka R Mar 30 '16 at 08:16
  • Ok. When Unity generates Android project, it is probably not adding OVRPlugin.so and libvrapi.so to the Project/libs/armeabi-v7a/ directory. These two files could found at Project/libs/ovrplugin.aar. So open ovrplugin.aar and look for OVRPlugin.so and libvrapi.so. If you find them, copy them to the Project/libs/armeabi-v7a/ directory. The error message should at-least change. – Programmer Mar 30 '16 at 10:46

1 Answers1

1

I've encountered the same problem and here is what eventually worked for me:

1) Export Android project with "Virtual Reality Support" enabled.

2) Open Android Studio and use Import project (Eclipse ADT, Gradle, etc.) to import your project. Choose another directory for "Import Destination". Select all three options on next screen.

3) Wait until import and Gradle's work is done.

4) Exit project or Android Studio.

5) Copy ovrplugin.aar file from Unity generated project directory (project_name/libs/ovrplugin.aar) to Android Studio generated project (project_name/app/libs/)

6) Edit build.gradle file located at project_name/app/ and add this:

allprojects {
  repositories {
    jcenter()
    flatDir {
      dirs 'libs'
    }
  }
}

and also this: compile(name:'ovrplugin', ext:'aar') in dependencies {} section

so this file looks something like this:

apply plugin: 'com.android.application'

android {
    (...)
}

allprojects {
    repositories {
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}

dependencies {
    compile(name:'ovrplugin', ext:'aar')
    (...)
}

7) Open your project and wait until Gradle finishes processing updated files.

Now this should work fine. Build APK and test.

jakub.sz
  • 63
  • 5