GeckoEngineView 无法膨胀,尽管使用了最新的依赖项。
该代码来自GeckoView上的官方文档。所有最新的依赖项和 repos 都已在项目中成功解决。
错误:
Error inflating class mozilla.components.browser.engine.gecko.GeckoEngineView
搜索错误日志后:
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]]
更新的 XML 文件,来源:@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/");
}
}
该文档暗示代码应该毫无问题地加载 web 视图。同样无法验证。
笔记:
Android Studio 版本:3.5 RC 3 [开发频道]