How to fix "Error inflating class GeckoEngineView" for android

SowingFiber :

The GeckoEngineView fails to be inflated, despite using latest dependencies.

The code is from an official documentation on GeckoView. All the latest dependencies and repos have been successfully resolved in the project.

The Error:

Error inflating class mozilla.components.browser.engine.gecko.GeckoEngineView

Upon scouring the error log:

 Caused by: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class mozilla.components.browser.engine.gecko.GeckoEngineView
 Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class mozilla.components.browser.engine.gecko.GeckoEngineView
 Caused by: java.lang.ClassNotFoundException: Didn't find class "mozilla.components.browser.engine.gecko.GeckoEngineView" on path: DexPathList[[zip file "/data/app/com.geckoengine.example-IQhwqfpsfzKO11EI9ak6kQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.geckoengine.example-IQhwqfpsfzKO11EI9ak6kQ==/lib/arm64, /data/app/com.geckoengine.example-IQhwqfpsfzKO11EI9ak6kQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]

Updated XML File, Credit: @ArturoMejia
activity_main.xml:

<org.mozilla.geckoview.GeckoView
    android:id="@+id/geckoview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />

MainActivity.java

public class MainActivity extends AppCompatActivity {

    GeckoView view;
    GeckoSession session;
    GeckoRuntime runtime;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        view = findViewById(R.id.geckoview);
        session = new GeckoSession();
        runtime = GeckoRuntime.create(this);
        session.open(runtime);
        view.setSession(session);


        //TODO: add any url
        //TODO: Use intent.putExtraString() to send a url from the main activity to this activity
        session.loadUri("http://theyouthbuzz.com/");
    }
}

The documentation implies that the code should load a webview without any problems. The same is not verifiable.

Notes:

Android studio version: 3.5 RC 3 [dev channel]

Gabriele Mariotti :

As described in the component doc to use it you have to add this dependencies in your build.gradle

implementation "org.mozilla.components:browser-engine-gecko:{latest-version}"

Currently the latest version is 9.0.0

implementation "org.mozilla.components:browser-engine-gecko:9.0.0"

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=139459&siteId=1