当膨胀包含XWalkView的XML布局时,运行时异常出现了严重的问题.
堆栈跟踪:
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Use SharedXWalkView if you want to support shared mode
at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:233)
at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:237)
at org.xwalk.core.ReflectionHelper.init(ReflectionHelper.java:132)
at org.xwalk.core.ReflectionHelper.loadClass(ReflectionHelper.java:199)
at org.xwalk.core.ReflectionHelper$ConstructorHelper.loadConstructor(ReflectionHelper.java:37)
at org.xwalk.core.ReflectionHelper.createInstance(ReflectionHelper.java:246)
at org.xwalk.core.XWalkView.<init>(XWalkView.java:169)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.bean.project.XWalkUIActivity.onCreate(XWalkUIActivity.java:51)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.RuntimeException: Use SharedXWalkView if you want to support shared mode
at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:237)
at org.xwalk.core.ReflectionHelper.init(ReflectionHelper.java:132)XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/com_bean_project_content"
android:theme="@style/com_bean_project_black" >
<!-- bottom controls -->
<RelativeLayout
android:id="@+id/com_bean_project_bottom_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<!-- some buttons, nothing to worry about -->
</RelativeLayout>
<!-- fills most of the parent view -->
<org.xwalk.core.XWalkView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/com_bean_project_webview"
android:layout_alignParentTop="true"
android:layout_above="@id/com_bean_project_bottom_layout"/>
</RelativeLayout>
我做过的事:
1)在Android中,我使用库中的armeabi-v7a文件夹,xwalk_core_library_java_app_part.jar和xwalk_core_library_java_library_part.jar都包含在依赖项中。我不知道我是否应该只用其中一个罐子?我在任何文件里都找不到关于它的任何东西。
2) XWalkView的活性具有android:hardwareAccelerated="true"
3)在人行横道下载页面(https://crosswalk-project.org/documentation/downloads.html)上,我下载了Android webview (ARM)的11.40.277.7版本
4)我还将人行横道中的"res“文件夹合并到我的项目中,但这并没有什么区别。
5)我也尝试过程序扩展,但是,它也只是一个new XWalkView(mParentActivity, mParentActivity); (我知道,愚蠢的构造函数)除外:
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Use SharedXWalkView if you want to support shared mode
at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:233)
at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:237)
at org.xwalk.core.ReflectionHelper.init(ReflectionHelper.java:132)
at org.xwalk.core.ReflectionHelper.loadClass(ReflectionHelper.java:199)
at org.xwalk.core.ReflectionHelper$ConstructorHelper.loadConstructor(ReflectionHelper.java:37)
at org.xwalk.core.ReflectionHelper.createInstance(ReflectionHelper.java:246)
at org.xwalk.core.XWalkView.<init>(XWalkView.java:192)为了获得灵感,我看过https://crosswalk-project.org/apis/embeddingapidocs/reference/org/xwalk/core/XWalkView.html,但是在这个问题上没有帮助。
发布于 2015-04-27 07:31:25
也许这能帮到你:
起初,我还试图在我的应用程序中使用jars。那不管用,我也有和你一样的例外。
然后我偶然发现了这个示例应用程序,它展示了如何使用人行横道。然后我将构建复制到我的应用程序中,一切正常。下面是我在gradle文件中添加的内容:在存储库部分,我添加了一行(在crashlytics下面.)
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven'}
maven { url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'}}
在依赖项部分中,我还添加了一行--最后一行:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'org.xwalk:xwalk_core_library:10.39.235.15'}
这是该活动的xml:
<org.xwalk.core.XWalkView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/walk_view"
android:layout_width="fill_parent"
android:background="#000000"
android:layout_height="fill_parent"
/>这就是我在java代码中使用它的方式:
private void setXView(){
mXview = (XWalkView)findViewById(R.id.walk_view);
mXview.load("http://www.cnn.com",null);
}不要忘记删除应用程序中的jars,否则如果依赖项中包含fileTree(dir:'libs',include:'*.jar'),您可能会收到编译错误。
发布于 2015-04-02 23:53:07
经过一天的疯狂实验,我终于放弃了在当地存储图书馆的尝试。
相反,我与Maven一起使用了以下说明:aar.html
页面底部有一个链接,指向一个用Maven设置的示例应用程序--这是很有用的。
注意:要了解库的哪些版本可用,请访问此处:图书馆/
例如,您将使用compile 'org.xwalk:xwalk_core_library:12.41.296.5',而不是"beta“依赖项。
在用maven设置了它之后,我又回到了XML膨胀。
然而,我当时面对的却是
04-02 16:38:31.036 14165-14165/com.bean.project W/System.err﹕ Caused by: java.lang.ClassCastException: android.view.ContextThemeWrapper cannot be cast to android.app.Activity
04-02 16:38:31.037 14165-14165/com.bean.project W/System.err﹕ at org.xwalk.core.internal.XWalkViewInternal.<init>(XWalkViewInternal.java:197)
04-02 16:38:31.037 14165-14165/com.bean.project W/System.err﹕ at org.xwalk.core.internal.XWalkViewBridge.<init>(XWalkViewBridge.java:46)疯狂还在继续..。
public XWalkViewInternal(Context context, AttributeSet attrs) {
super(convertContext(context), attrs);
checkThreadSafety();
mActivity = (Activity) context;
mContext = getContext();
init(mContext, attrs);
}他们怎么可能认为这是个好主意呢?!!/facepalm
编辑:为了让XWalkView以编程方式添加到布局中,我在XML FULLSCREEN_YOUTUBE_CONTAINER_ID中放置了一个占位符(空) RelativeLayout,然后在onCreate()中放置了我所做的活动的占位符(空):
mYoutubeVideoViewContainer = (RelativeLayout) mLayoutView.findViewById(FULLSCREEN_YOUTUBE_CONTAINER_ID);
mYoutubeWebView = new XWalkView(mParentActivity, mParentActivity);
RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
mYoutubeVideoViewContainer.addView(mYoutubeWebView, relativeParams);https://stackoverflow.com/questions/29421985
复制相似问题