Android InflateException - 在com.google.vr.sdk.base.GvrView类中出错

时间:2016-09-01 12:54:13

标签: java android proguard google-cardboard inflate-exception

我正在尝试在x86_64模拟器上启动并运行Google Cardboard SDK的模块“audio”,“base”和“common”的新项目,但我不断收到以下错误:

09-01 14:38:36.378 8768-8768/com.verbraeken.joost.roarenginedemo W/System: ClassLoader referenced unknown path: /data/app/com.verbraeken.joost.roarenginedemo-2/lib/x86_64
09-01 14:38:36.514 8768-8768/com.verbraeken.joost.roarenginedemo W/System: ClassLoader referenced unknown path: /data/app/com.verbraeken.joost.roarenginedemo-2/lib/x86_64
09-01 14:38:36.714 8768-8768/com.verbraeken.joost.roarenginedemo D/ConfigUtils: Parameters file not found for reading: java.io.FileNotFoundException: /storage/emulated/0/Cardboard/current_device_params: open failed: ENOENT (No such file or directory)
09-01 14:38:36.714 8768-8768/com.verbraeken.joost.roarenginedemo D/CardboardViewNativeImpl: NativeProxy not found
09-01 14:38:36.714 8768-8768/com.verbraeken.joost.roarenginedemo D/CardboardViewNativeImpl: Loading native library gvrbase
09-01 14:38:36.718 8768-8768/com.verbraeken.joost.roarenginedemo D/AndroidRuntime: Shutting down VM
09-01 14:38:36.719 8768-8768/com.verbraeken.joost.roarenginedemo E/AndroidRuntime: FATAL EXCEPTION: main
   Process: com.verbraeken.joost.roarenginedemo, PID: 8768
   java.lang.RuntimeException: Unable to start activity ComponentInfo{com.verbraeken.joost.roarenginedemo/com.verbraeken.joost.roarenginedemo.MainActivity}: android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class com.google.vr.sdk.base.GvrView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class com.google.vr.sdk.base.GvrView
        at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
        at android.app.Activity.setContentView(Activity.java:2166)
        at com.verbraeken.joost.roarenginedemo.MainActivity.onCreate(MainActivity.java:29)
        at android.app.Activity.performCreate(Activity.java:6237)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5417) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
     Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.google.vr.sdk.base.GvrView
        at android.view.LayoutInflater.createView(LayoutInflater.java:645)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
        at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
        at android.app.Activity.setContentView(Activity.java:2166) 
        at com.verbraeken.joost.roarenginedemo.MainActivity.onCreate(MainActivity.java:29) 
        at android.app.Activity.performCreate(Activity.java:6237) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5417) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at android.view.LayoutInflater.createView(LayoutInflater.java:619)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
        at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
        at android.app.Activity.setContentView(Activity.java:2166) 
        at com.verbraeken.joost.roarenginedemo.MainActivity.onCreate(MainActivity.java:29) 
        at android.app.Activity.performCreate(Activity.java:6237) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5417) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
     Caused by: java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex file "/data/data/com.verbraeken.joost.roarenginedemo/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.verbraeken.joost.roarenginedemo/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.verbraeken.joost.roarenginedemo/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.verbraeken.joost.roarenginedemo/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.verbraeken.joost.roarenginedemo/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.verbraeken.joost.roarenginedemo/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.verbraeken.joost.roarenginedemo/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.verbraeken.joost.roarenginedemo/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.verbraeken.joost.roarenginedemo/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.verbraeken.joost.roarenginedemo/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.verbraeken.joost.roarenginedemo/files/instant-run/dex/slice-logansquare-1.3.6_716acd6a9767b2e8e1dfddc8c163119e550e393e-classes.dex", dex file "/data/data/com.verbraeken.joost.roarenginedemo/files/instant-run/dex/slice-jackson-core-2.5.1_d4f9878edbf4e7675b2818a3e9e4f0b8
09-01 14:38:46.911 8768-8768/com.verbraeken.joost.roarenginedemo I/Process: Sending signal. PID: 8768 SIG: 9

关于同一问题的其他一些帖子说可以通过在build.gradle和proguard文件中放入一些代码来修复它。对于build.gradle:

buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            ndk {
                abiFilters "armeabi-v7a", "armeabi", "x86", "x86_64"
            }
        }
        debug {
            ndk {
                abiFilters "armeabi-v7a", "armeabi", "x86", "x86_64" 
            }
        }
    }
    splits {
        abi {
            enable true
            reset()
            include 'x86', 'armeabi-v7a'
            universalApk false
        }
    }

对于proguard文件:

-keep class com.google.vr.**
-keepclassmembers class com.google.vr.** { *; }
-keep class com.google.vr.**$*
-keepclassmembers class com.google.vr.**$* { *; }
-keep class com.google.geo.render.**
-keepclassmembers class com.google.geo.render.** { *; }
-keep class com.google.vrtoolkit.cardboard.** { *; }

然而,它不起作用,我不断收到错误。有没有人知道如何解决它?

P.S。抱歉我的英语不好,我不是母语为英语的人

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,然后我检查了来自Google VR SDK的示例应用,我复制了相同的gradle.build文件,它对我有用。请试试这可能有帮助..

更改build.gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles.add(file('../../proguard-gvr.txt'))
        }
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    testCompile 'junit:junit:4.12'
    compile project(':audio')
    compile project(':base')
    compile project(':common')
    compile project(':commonwidget')
    compile project(':controller')
    compile project(':panowidget')
    compile project(':videowidget')

    compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7'
}