我有一个使用库的应用程序,而该库又具有外部JAR-Cardboard SDK。
应用程序已编译,但在运行时我得到了NoClassDefFoundError
-它无法从硬纸板SDK中找到内部类CardboardDevice$DeviceParams
。
全栈跟踪:
java.lang.NoClassDefFoundError: com.google.vrtoolkit.cardboard.proto.CardboardDevice$DeviceParams
at com.google.vrtoolkit.cardboard.CardboardDeviceParams.createFromInputStream(CardboardDeviceParams.java:273)
at com.google.vrtoolkit.cardboard.HeadMountedDisplayManager.createCardboardDeviceParamsFromExternalStorage(HeadMountedDisplayManager.java:247)
at com.google.vrtoolkit.cardboard.HeadMountedDisplayManager.createCardboardDeviceParams(HeadMountedDisplayManager.java:200)
at com.google.vrtoolkit.cardboard.HeadMountedDisplayManager.<init>(HeadMountedDisplayManager.java:54)
at com.google.vrtoolkit.cardboard.CardboardView.init(CardboardView.java:793)
at com.google.vrtoolkit.cardboard.CardboardView.<init>(CardboardView.java:262)
at org.androidworks.villagevr.villagevr.BaseVRActivity.onCreate(BaseVRActivity.java:65)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
库
build.gradle
:apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "19.1.0"
defaultConfig {
//applicationId "org.androidworks.vrcommon"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
}
dependencies {
// compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/cardboard.jar')
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':LiveWallpaperTulipsCommon')
}
应用程序
build.gradle
:apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "org.androidworks.villagevr.villagevr"
minSdkVersion 9
targetSdkVersion 21
versionCode 15
versionName "1.5"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':LiveWallpaperTulipsCommon')
compile project(':LiveWallpaperVillageCommon')
compile project(':VRCommon')
}
最佳答案
Cardboard SDK包含一个libprotobuf jar文件。确保它存在并包含在您的构建中。