如何在GeckoSession $ NavigationDelegate.onLoadRequest处修复AbstractMethodError?

时间:2019-01-19 20:12:44

标签: android gecko

我正在通过mozilla-mobile创建一个带有android-components的简单浏览器应用。我在“中等”中受this tutorial的引导。这似乎很容易,但是在尝试启动应用程序时出现了此异常:

 java.lang.AbstractMethodError: abstract method "org.mozilla.geckoview.GeckoResult org.mozilla.geckoview.GeckoSession$NavigationDelegate.onLoadRequest(org.mozilla.geckoview.GeckoSession, java.lang.String, int, int)"
    at org.mozilla.geckoview.GeckoSession$2.handleMessage(GeckoSession.java:321)
    at org.mozilla.geckoview.GeckoSession$2.handleMessage(GeckoSession.java:175)
    at org.mozilla.geckoview.GeckoSessionHandler.handleMessage(GeckoSessionHandler.java:79)
    at org.mozilla.gecko.EventDispatcher$2.run(EventDispatcher.java:344)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6626)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)

这是MainActivity.class:

class MainActivity : AppCompatActivity() {

private val engine: Engine by lazy {
    GeckoEngine(this)
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    val session = engine.createSession()
    engineView.render(session)
    session.loadUrl("https://mozilla.org")
}

override fun onCreateView(parent: View?, name: String, context: Context, attrs: AttributeSet): View? =
    when (name) {
        EngineView::class.java.name -> engine.createView(context, attrs).asView()
        else -> super.onCreateView(parent, name, context, attrs)
    }
}

这是activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <mozilla.components.concept.engine.EngineView
            android:id="@+id/engineView"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

build.gradle依赖项:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
    implementation 'androidx.core:core-ktx:1.1.0-alpha03'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'org.mozilla.components:concept-engine:0.38.0'
    implementation 'org.mozilla.components:browser-engine-gecko:0.38.0'
    x86Implementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}-x86:${geckoviewVersion}"
    x86_64Implementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}-x86_64:${geckoviewVersion}"
    armImplementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}-armeabi-v7a:${geckoviewVersion}"
    aarch64Implementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}-arm64-v8a:${geckoviewVersion}"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

我不明白自己在做什么。

0 个答案:

没有答案