Android XML InflateException - Google Cardboard

和自甴很熟 提交于 2019-12-25 07:58:44

问题


Getting an InflateException for the following XML. The suspect line is with VrVideoView. I have looked through the XML, and cannot find any big differences between this an the demo app. Has anyone successfully used VrVideoView

XML

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/main_layout"
        android:padding="10dip"
        android:orientation="vertical" >

        <com.google.vr.sdk.widgets.video.VrVideoView
            android:id="@+id/video_view"
            android:layout_width="match_parent"
            android:layout_height="250dip"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
            <!-- Seeking UI & progress indicator.-->
            <SeekBar
                android:id="@+id/seek_bar"
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_height="32dp"
                android:layout_weight="8"
                android:layout_width="0dp"/>
        </LinearLayout>
    </LinearLayout>
</ScrollView>

Activity - onCreate()

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_layout);

    seekBar = (SeekBar) findViewById(R.id.seek_bar);
    seekBar.setOnSeekBarChangeListener(new SeekBarListener());
    statusText = (TextView) findViewById(R.id.status_text);

    // Make the source link clickable.
    TextView sourceText = (TextView) findViewById(R.id.source);
    sourceText.setText(Html.fromHtml(getString(R.string.source)));
    sourceText.setMovementMethod(LinkMovementMethod.getInstance());

    // Bind input and output objects for the view.
    videoWidgetView = (VrVideoView) findViewById(R.id.video_view);
    videoWidgetView.setEventListener(new ActivityEventListener());

    volumeToggle = (ImageButton) findViewById(R.id.volume_toggle);
    volumeToggle.setOnClickListener(new View.OnClickListener() {
       public void onClick(View v) {
         setIsMuted(!isMuted);
       }
    });

    loadVideoStatus = LOAD_VIDEO_STATUS_UNKNOWN;

    // Initial launch of the app or an Activity recreation due to rotation.
    handleIntent(getIntent());
  }

Exception

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.labs.live.duke.vrbanking/com.labs.live.duke.vrbanking.MainActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class com.google.vr.sdk.widgets.video.VrVideoView
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
                                                                                  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)
                                                                               Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class com.google.vr.sdk.widgets.video.VrVideoView
                                                                                  at android.view.LayoutInflater.createView(LayoutInflater.java:633)
                                                                                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
                                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
                                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
                                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
                                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
                                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
                                                                                  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
                                                                                  at android.app.Activity.setContentView(Activity.java:2144)
                                                                                  at com.labs.live.duke.vrbanking.MainActivity.onCreate(MainActivity.java:139)

来源:https://stackoverflow.com/questions/40092868/android-xml-inflateexception-google-cardboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!