我下载了virocore lib的最新版本(virocore-release-v 1_7_2.aar),然后在下面的build.gradle文件中添加了依赖项
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:25.0.0'
implementation 'com.google.android.exoplayer:exoplayer:r2.2.0'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation (name:'virocore-release-v_1_7_2', ext: 'aar')
implementation 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7'
implementation 'com.amazonaws:aws-android-sdk-core:2.2.+'
implementation 'com.amazonaws:aws-android-sdk-ddb:2.2.+'
implementation 'com.amazonaws:aws-android-sdk-ddb-mapper:2.2.+'
implementation 'com.amazonaws:aws-android-sdk-cognito:2.2.+'
implementation 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.2.+'}
然后写信给我的虚拟活动代码如下:
private ViroView createGVRView() {
return new ViroViewGVR(this, new ViroViewGVR.StartupListener() {
@Override
public void onSuccess() {
onRendererStart();
}
@Override
public void onFailure(ViroViewGVR.StartupError error, String errorMessage) {
onRendererFailed(error.toString(), errorMessage);
}
}, new Runnable() {
@Override
public void run() {
}
});
}
但运行应用程序时,我总是看到下一个例外:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.virosample.gvr.ovr, PID: 17304
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/vr/ndk/base/GvrLayout;
at com.viro.core.ViroViewGVR.init(ViroViewGVR.java:287)
at com.viro.core.ViroViewGVR.<init>(ViroViewGVR.java:211)
at com.example.panorama.ui.view.ViroActivityVR.createGVRView(ViroActivityVR.java:104)
at com.example.panorama.ui.view.ViroActivityVR.onCreate(ViroActivityVR.java:90)
...
有人知道如何解决这个异常吗?
最佳答案
我解决了这个问题。我只在依赖项中添加了viro库,但必须另外添加sdk-common.aar和core.aar,您可以在官方virocore站点下载它们。