【发布时间】:2019-12-26 23:37:42
【问题描述】:
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 文件,来源:@ArturoMejiaactivity_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 [开发频道]
【问题讨论】:
-
是否添加了依赖:
implementation "org.mozilla.components:browser-engine-gecko:{latest-version}"? -
您必须将 {latest-version} 更改为该库的最新版本。检查图书馆的文档。好像是 9.0.0
-
我的评论解决了您的问题吗?
-
谢谢。刚刚发布了答案。