googlevr / gvr-android-sdk

Google VR SDK for Android
http://developers.google.com/vr/android/
Other
3.28k stars 1.28k forks source link

Different gvr libraries in build.gradle and libs/gvr/headers btw libs/gvr/jni works fine on some devices, but may crash on others #579

Closed Consti10 closed 6 years ago

Consti10 commented 6 years ago

This is more a warning than an issue, but i stumbled over the following: Because the ndk has to be extracted manually from the sources and pasted into the project folder, it is relatively easy to do the following: update the version in your build.gradle , and forget to extract the new ndk files from the source code

e.g. your build.gradle dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:design:27.1.1' implementation 'com.android.support.constraint:constraint-layout:1.1.2' //location implementation 'com.google.android.gms:play-services-location:15.0.1' //everything gvr related implementation 'com.google.vr:sdk-base:1.150.0' implementation 'com.google.vr:sdk-audio:1.150.0' //the color preference //implementation 'com.github.kizitonwose.colorpreference:support:1.0.6' implementation 'com.github.kizitonwose.colorpreference:core:1.0.6' } but under libs/gvr/headers (or whatever path the gvr lib is in) you still have the old extracted source code.

When I updated the gvr lib in build.gradle but not the extracted ndk libs, I didn't see any warning not to do so , and it worked on my zte axon 7, so i thought 'hey, maybe using different versions here actually work' but it backfired completely when my app suddenly crashed on a galaxy s6 and i had to track the issue down to the described issue.

I am opening this issue as a) a warning for everybody and b) Please confirm if different gradle and library versions are not backwards-compatible and possibly add a warning somewhere in the docs

sigmaxipi commented 6 years ago

Do you have a crash stack? While mixing headers and libs from different versions won't work, this normally causes a linker error rather than a runtime crash. GVR actually loads a runtime library from Google VR Services which is installed on Daydream devices and designed to be backwards compatible. However, the s6 isn't a Daydream device so it won't have GVR Services which is may be why the app crashed.

The build issue is similar to https://github.com/googlevr/gvr-android-sdk/issues/315

The problem is that there isn't any clean way of shipping native headers and libraries via .aars. I don't know if this has changed since the last time I investigated but the other issue has notes and possible workarounds. Since everyone has a slightly different build setup, there are hacks which will work for some people but not others.

If you find a good solution, please let us know.

Consti10 commented 6 years ago

Hello, Now that I have updated my native files to 1.6 I was not able to reproduce the issue. (when setting the version in build.gradle lower than in the cpp headers) But I noticed the malfunction on the s6 when it was the other way around: So I went back in my archive: 1.14 in the headers and 1.5 in gradle and this is basically the error: JNI DETECTED ERROR IN APPLICATION: jmethodID was NULL in call to CallStaticVoidMethodV art/runtime/java_vm_ext.cc:470] from long com.google.vr.ndk.base.GvrApi.nativeCreate(java.lang.ClassLoader, android.content.Context, long, int, int, float, float, com.google.vr.ndk.base.GvrApi$PoseTracker)

I arises when instantiating my gvr layout

But only on s6 and not on zte. I installed cradboard and googlevr services on both devices (I first thought that would solve the issue). I also found some more missing jni methods when looking for the issue.

It would be cool if you added a warning / failure that already gets thrown inside gradle (if it is possible) when the versions in the headers and build.gradle are not the same. But until then I will just learn from my mistakes and make sure to update the .so / .h files via extractndkXXX whenever i update the versions inside build.gradle

Consti10 commented 6 years ago

btw, this is not totally on-topic but while 1.16 is released on github i only find 1.15 in android studio implementation 'com.google.vr:sdk-base:1.150.0' should be ...1.160.0 but didnt have any issues with that yet

sigmaxipi commented 6 years ago

We've release 1.170 and all the build.gradle files for the samples have been updated.