Geckoview不起作用

时间:2018-04-14 23:01:28

标签: android-studio gecko

我正在使用android studio中的geckoview进行项目。当我到达包含活动时,应用程序会一直崩溃。使用log cat我发现它给了我以下错误

    FATAL EXCEPTION: main

    Process: app, PID: 2815

  java.lang.RuntimeException: Unable to start activity ComponentInfo{project name}: android.view.InflateException: Binary XML file line #27: Binary XML file line #27: Error inflating class org.mozilla.gecko.GeckoView

我不知道如何解决这个或者它意味着什么或做什么...... 这是我的代码,我希望它有所帮助

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_page);
        Button Nav=(Button) findViewById(R.id.Nav);


        GeckoView geckoView = (GeckoView) findViewById(R.id.geckoview);


        GeckoSession session = new GeckoSession();
        geckoView.setSession(session);


        session.loadUri("http://google.com");


    }

XML

<org.mozilla.gecko.GeckoView
    android:id="@+id/geckoview"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_alignParentEnd="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_marginBottom="82dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/guideline2" />

提前谢谢..

1 个答案:

答案 0 :(得分:0)

如下更改xml中的Geckoview

<org.mozilla.geckoview.GeckoView
    android:id="@+id/geckoview"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_alignParentEnd="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_marginBottom="82dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/guideline2" />