android crosswalk webview 集成,How to add crosswalk webview in my own android library module?

I create a new app from the webview to XWalkView to render the three.js stl loader demo, which is not support by the webview no matter WebGlRenderer or CanvasRenderer.

Here is the process how to use the crosswalk module:

Step 1:File->New->Import Module

3bc914013280ce4e4899a103658e6794.png

step 2 select the module and rename if you need

06893da79125ca652bacff56c0ed5497.png

step 3 choose all the option

6e27ac1d9dcb8c4647192417d1d051cb.png

here android studio may ask you to update, update it

d1uuz.png

step 4 process the module dependency

2a4d7866ce6057fd97cca1bff582fd91.png

2d8c5df432db5da40b1e40eafff1a2d9.png

226fe120bfa87346a697736118f977f6.png

After this ,the Gradle Build Running automatically

Here We have finished the crosswalk inport.

step 5 use the XWalkView

add this priviledges to AndroidManifest.xml

add hardware acceleration on to application node of AndroidManifest.xml

android:hardwareAccelerated="true"

add this to layout file

android:id="@+id/xWalkView"

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent">

add this to activity

XWalkView mXWalkView = (XWalkView) findViewById(R.id.xWalkView);

mXWalkView.load("http://192.168.1.42/test", null);

Here we finished

this is the result I use webview and XWalkView to render three.js STL loader.

webview not support

e0ee323153c3fc53708e5e713f64c780.png

XWalkView supports well

7ad6060e28a291c091b8805473710364.png

Haha it works.

Follow is the another old implementation , and you can also refer to this good [post] or doc11.

here is the source code.

Download proper Crosswalk Android webview package and unpackage it from https://crosswalk-project.org/documentation/downloads.html

Copy xwalk_core_library_java.jar from crosswalk libs to app/libs/ in the android studio project, and write click on the file, select the "Adds As Library"

Copy other contents under crosswalk libs to app/src/main/jniLibs/

Make an Android Resource dir res2, and copy files in crosswalk res dir to this dir.

Add this to AndroidMenifest.xml

and add android:hardwareAccelerated="true" to application node.to use hardware acceleration which is needed by crosswalk webview

add this to layout

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

>

add this to Activity

XWalkView mXWalkView = (XWalkView) findViewById(R.id.webview);

mXWalkView.load("http://xxxxxx.com", null);

if you want to debug romote add this.

XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值