0

I need to integrate GoogleVR support into an existing project built with the ADT tool chain in Eclipse.

So far I've extracted base.aar and common.aar (from Gradle), moved the classes.jar into a "libs" folder with unique names (base-classes.jar, etc.), created a library projects with the "New Android Project From Existing Sources" tool, and attached them to the main app as dependent library projects.

This seems to build ok, and can at least get to the "main" splash screen activity just fine, however, the app crashes at runtime when I attempt to activate a GvrActivity like so:

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

...where FinditVRActivity is essentially a blank GvrActivity with a few lines of GL to set a background color (aka "hello world")... the application crashes with the following error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.YourCompany.Findit3D/com.YourCompany.Findit3D.FinditVRActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class com.google.vr.sdk.base.GvrView

Here is the last few bits of the log before it crashes...

07-07 12:42:01.466: D/Activity(8246): performCreate Call secproduct feature valuefalse
07-07 12:42:01.466: D/Activity(8246): performCreate Call debug elastic valuetrue
07-07 12:42:01.656: D/CardboardViewNativeImpl(8246): NativeProxy not found
07-07 12:42:01.656: D/CardboardViewNativeImpl(8246): Loading native library gvrbase

I did confirm the stock example in Android Studio works on my test device, so this shouldn't be the issue. I am assuming I'm missing something in my project linkage in ADT, but I'm not sure what. Any ideas where I go from here?

Thanks for your time!

edit removed unneeded code in startActivity example

edit2 note: ProGuard is disabled on all projects

edit3

I've done some further digging, and have narrowed down the crash to the following code examples.

As expected, this example activity will set a blue background when launched.

public class FinditVRActivity extends GvrActivity {

    private GLSurfaceView _glSurfaceView;

    public static class GLRenderer implements Renderer {
        @Override
        public void onSurfaceCreated(GL10 gl, EGLConfig config) {
            glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
        }

        @Override
        public void onSurfaceChanged(GL10 gl, int width, int height) {
            // No-op
        }

        @Override
        public void onDrawFrame(GL10 gl) {
            glClear(GL_COLOR_BUFFER_BIT);
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        _glSurfaceView = new GLSurfaceView(this);
        _glSurfaceView.setEGLContextClientVersion(2);
        _glSurfaceView.setRenderer(new GLRenderer());
        setContentView(_glSurfaceView);
    }

    @Override
    protected void onPause() {
        super.onPause();

         _glSurfaceView.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();

        _glSurfaceView.onResume();
    }
}

This similar activity using GrvView crashes with a new error, which seems closer to the goal at least.

public class FinditVRActivity extends GvrActivity {

    private GvrView _gvrView;

    public static class GVRRenderer implements GvrView.StereoRenderer {

        @Override
        public void onSurfaceCreated(EGLConfig config) {
            glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
        }

        @Override
        public void onNewFrame(HeadTransform headTransform) {
            glClear(GL_COLOR_BUFFER_BIT);
        }

        @Override
        public void onSurfaceChanged(int width, int height) {}

        @Override
        public void onFinishFrame(Viewport viewport) {}

        @Override
        public void onDrawEye(Eye eye) {}

        @Override
        public void onRendererShutdown() {}
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        _gvrView = new GvrView(this);
        _gvrView.setEGLContextClientVersion(2);
        _gvrView.setRenderer(new GVRRenderer());
        setContentView(_gvrView);
    }

    @Override
    protected void onPause() {
        super.onPause();

        _gvrView.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();

        _gvrView.onResume();
    }
}

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.YourCompany.Findit3D-1/base.apk"],nativeLibraryDirectories=[/data/app/com.YourCompany.Findit3D-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libgvrbase.so"

I do not actually see libgvrbase.so anywhere in the build artifact, so it looks like @Morrison Chang 's assumption was correct.

Is this located in another library .aar package perhaps?

Thanks again!

drkstr101
  • 760
  • 1
  • 6
  • 23
  • Are native (jni) libraries missing in the ADT built version? – Morrison Chang Jul 07 '16 at 20:24
  • No, I have confirmed libgvr.so is packaged in the APK file. Upon further investigation, I found I could prevent the crash by removing everything from onCreate in my GvrActivity, which leads me to believe there is a code error of some sorts (although, same basic test with GLSurfaceView works ok). I will do some more digging and report back with what I find. Cheers and thank you! – drkstr101 Jul 07 '16 at 22:25
  • @MorrisonChang please see edits for additional relevant information. Thanks! – drkstr101 Jul 07 '16 at 23:56
  • Haha @MorrisonChang was spot on! The existing app had a "libvrapi.so", which I mistook for the GVR libs. I copied base/jni/armeabi-v7a/libgvrbase.so into the appropriate sub-dir in my main libs directory, and now the test activity works as expected. If you would like to put up an "official" answer, I will mark as accepted. Cheers! – drkstr101 Jul 08 '16 at 00:40
  • feel free to write up the steps needed so that you were able to successful build using ADT – Morrison Chang Jul 08 '16 at 04:52
  • @MorrisonChang FYI, I discovered that I will also need to integrate native GVR support as described in gvr-ndk-walkthrough (the render thread is native GL). Once I have this up and running, I will update your answer with the full steps. Cheers! – drkstr101 Jul 08 '16 at 10:32

1 Answers1

0

You mention that you are manually extracting from the existing .aar files to build your project. The logcat shown before the app crashes:

07-07 12:42:01.656: D/CardboardViewNativeImpl(8246): NativeProxy not found
07-07 12:42:01.656: D/CardboardViewNativeImpl(8246): Loading native library gvrbase

implies that NativeProxy in CardboardViewNativeImpl is missing, which is why I suggested to check the JNI libraries.

Based on your replies it looks like you've found the appropriate files and placed them in your project/libraries such that you were able to build correctly using ADT.

** Update **

The final steps to get everything up and running were quite involved, so I have posted my work to GitHub, to serve as a guide for those who may stumble across this thread in the future. At the time of this writing, this is still a work in progress. See active Issues for more information.

https://github.com/drkstr101/gvr-android-sdk

drkstr101
  • 760
  • 1
  • 6
  • 23
Morrison Chang
  • 11,691
  • 3
  • 41
  • 77
  • The final steps to get everything up and running were quite involved, so I have posted my work to GitHub, to serve as a guide for those who may stumble across this thread in the future. I am still having trouble getting the native NDK samples to build, so any help would be greatly apprecated! https://github.com/drkstr101/gvr-android-sdk – drkstr101 Jul 11 '16 at 19:39