Search code examples
androidadtgoogle-vr

running googlevr TreasureHunt sample app in ADT


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!


Solution

  • 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