简体   繁体   English

与Eclipse崩溃的人行横道

[英]Crosswalk with Eclipse crashes

I added Crosswalk to eclipse as in this tutorial: ClickHere I did everything exactly as in the tutorial and got no errors, but as i start the app on my phone I have this: 我在本教程中添加了Crosswalk eclipse: ClickHere我完成了教程中的所有操作并且没有错误,但是当我在手机上启动应用程序时,我有这样的:

02-19 13:37:08.147: E/AndroidRuntime(21108): FATAL EXCEPTION: main
02-19 13:37:08.147: E/AndroidRuntime(21108): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.crosswalktest/com.example.crosswalktest.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class org.xwalk.core.XWalkView
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2092)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.app.ActivityThread.access$700(ActivityThread.java:134)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.os.Looper.loop(Looper.java:137)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.app.ActivityThread.main(ActivityThread.java:4867)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at java.lang.reflect.Method.invokeNative(Native Method)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at java.lang.reflect.Method.invoke(Method.java:511)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at dalvik.system.NativeStart.main(Native Method)
02-19 13:37:08.147: E/AndroidRuntime(21108): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class org.xwalk.core.XWalkView
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.view.LayoutInflater.createView(LayoutInflater.java:613)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:316)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.app.Activity.setContentView(Activity.java:1901)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at com.example.crosswalktest.MainActivity.onCreate(MainActivity.java:17)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.app.Activity.performCreate(Activity.java:5047)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)
02-19 13:37:08.147: E/AndroidRuntime(21108):    ... 11 more
02-19 13:37:08.147: E/AndroidRuntime(21108): Caused by: java.lang.reflect.InvocationTargetException
02-19 13:37:08.147: E/AndroidRuntime(21108):    at java.lang.reflect.Constructor.constructNative(Native Method)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at android.view.LayoutInflater.createView(LayoutInflater.java:587)
02-19 13:37:08.147: E/AndroidRuntime(21108):    ... 21 more
02-19 13:37:08.147: E/AndroidRuntime(21108): Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Use SharedXWalkView if you want to support shared mode
02-19 13:37:08.147: E/AndroidRuntime(21108):    at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:233)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:237)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at org.xwalk.core.ReflectionHelper.init(ReflectionHelper.java:132)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at org.xwalk.core.ReflectionHelper.loadClass(ReflectionHelper.java:199)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at org.xwalk.core.ReflectionHelper$ConstructorHelper.loadConstructor(ReflectionHelper.java:37)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at org.xwalk.core.ReflectionHelper.createInstance(ReflectionHelper.java:246)
02-19 13:37:08.147: E/AndroidRuntime(21108):    at org.xwalk.core.XWalkView.<init>(XWalkView.java:169)
02-19 13:37:08.147: E/AndroidRuntime(21108):    ... 24 more
02-19 13:37:08.147: E/AndroidRuntime(21108): Caused by: java.lang.RuntimeException: Use SharedXWalkView if you want to support shared mode
02-19 13:37:08.147: E/AndroidRuntime(21108):    ... 30 more

MainActivity: 主要活动:

public class MainActivity extends Activity {

private  XWalkView mXWalkView;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mXWalkView = (XWalkView) findViewById(R.id.AM);
    mXWalkView.load("http://crosswalk-project.org/", null);
  }

} }

activity_main.xml: activity_main.xml中:

<org.xwalk.core.XWalkView android:id="@+id/AM"
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
</org.xwalk.core.XWalkView>

I digged google for several hours but couldn't find a solution. 我挖了谷歌几个小时但找不到解决方案。

I had the same problem and found the solution: 我有同样的问题,并找到了解决方案:

Remember to ask for the needed permissions in your Android Manifest: 请记住在Android Manifest中要求获得所需的权限:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

Try importing crosswalk-webview-14.43.343.11-arm(or any updated library that you are using) as library project in eclipse or android studio. 尝试在eclipse或android studio中导入crosswalk-webview-14.43.343.11-arm(或您正在使用的任何更新的库)作为库项目。 That will resolve the issue. 这将解决问题。 Add it as a library in your Project. 将其添加为项目中的库。 In eclipse : Right Click on project->Properties->Add Library. 在eclipse中:右键单击项目 - >属性 - >添加库。

In Android Studio: Open module setting of your project->Press + button to import project->Add your crosswalk-webview-14.43.343.11-arm. 在Android Studio中:打开项目的模块设置 - >按+按钮导入项目 - >添加你的crosswalk-webview-14.43.343.11-arm。 After that in your project Add module dependency. 之后在您的项目中添加模块依赖项。

Simply referring jar wont work in some cases. 简单地说jar在某些情况下不会起作用。

对我来说,诀窍是下载Android Arm + x86版本 ,其他两个版本似乎不起作用。

Like Developer said, the jar file isn't enough, it's not a uber jar including everything 就像开发人员说的那样,jar文件还不够,它不是包含所有内容的超级jar

As modules: 作为模块:

  • Copy the sources files in your project folder 复制项目文件夹中的sources文件
  • Inlude the module : File->New->New Module 包括模块:File-> New-> New Module
  • Add the new module to your app module (right lick on app -> dependdencies -> + -> Module dependency 将新模块添加到您的应用程序模块(右键舔app - >依赖项 - > + - >模块依赖项

I had similar problem when embedding crosswalk to our gradle based project. 将crosswalk嵌入基于gradle的项目时遇到了类似的问题。 It was only happening in Release builds. 它只发生在发布版本中。 After trying to extends from XWalkActivity or using XWalkInitializer it was still failing, but I noticed that it fails in during reflection based method, when app is trying to init embeded library. 在尝试从XWalkActivity扩展或使用XWalkInitializer后,它仍然失败,但我发现它在基于反射的方法中失败,当应用程序尝试初始化嵌入库时。 Then I understood that it's caused by method obfuscation in proguard in our release build. 然后我明白它是由我们的发布版本中的proguard中的方法混淆引起的。 After added exceptions in proguard configuration according to Crosswalk FAQ , and then also adding another rule to proguard to keep JavasriptInterface methods used in our project to interact between webview and native client, the problem was fixed. 根据Crosswalk FAQ在proguard配置中添加异常,然后还为proguard添加另一个规则以保持我们项目中使用的JavasriptInterface方法在webview和本机客户端之间进行交互,问题得到了解决。 So I suggest to check your proguard rules if any. 所以我建议检查你的proguard规则,如果有的话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM