如何在我自己的android库模块中添加人行横道的webview? [英] How to add crosswalk webview in my own android library module?

查看:90
本文介绍了如何在我自己的android库模块中添加人行横道的webview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发必须包含Crosswalk Webview的Android库模块.我使用Github Sonatype( https://github.com/sonatype/)创建该库.没有Crosswalk Webview,它可以正常工作.我尝试了以下3种方法来添加Crosswalk.

I am in the development of an Android library module which has to include Crosswalk Webview. I create the library using Github Sonatype (https://github.com/sonatype/). It works fine without Crosswalk Webview. I tried the following 3 methods to include Crosswalk.

方法1:

  • 在我的图书馆项目应用gradle中添加Crosswalk Webview图书馆

  • Add Crosswalk Webview library in my library project app gradle

错误:(编译错误)

无法解决:org.xwalk:xwalk_core_library:18.48.477.13

Failed to resolve: org.xwalk:xwalk_core_library:18.48.477.13

方法2:

  • 在我的图书馆项目中添加人行横道aar文件

  • Add crosswalk aar file in my library project

添加aar文件的参考链接

Reference link for adding aar file How to import a .aar file into Android Studio 1.1.0 and use it in my code

我已经从下载了Crosswalk Webview https://download.01.org/crosswalk/releases/crosswalk/android/stable/18.48.477.13/

I have downloaded Crosswalk Webview from https://download.01.org/crosswalk/releases/crosswalk/android/stable/18.48.477.13/

错误:(编译错误)

无法解决:MyLIBApplication:xwalk_core_library_java:unspecified

Failed to resolve: MyLIBApplication:xwalk_core_library_java:unspecified

方法3:

  • 在我的图书馆项目中添加人行横道jar文件

  • Add crosswalk jar file in my library project

下载链接 https://download.01.org/crosswalk/releases/crosswalk/android/stable/18.48.477.13/

错误:此方法没有编译错误,但它给出的运行时错误为 java.lang.NoClassDefFoundError:org.xwalk.core.R $ string

Error : This method no compilation error but it give run time error that was java.lang.NoClassDefFoundError: org.xwalk.core.R$string

注意:我尝试了两个jar(普通,共享模式)文件

Note: I tried both jar (ordinary, share mode) files

推荐答案

我创建了一个从Web视图到XWalkView的新应用,以渲染three.js stl加载程序演示,无论WebGlRenderer还是CanvasRenderer,Web视图均不支持该演示. 这是使用人行横道模块的过程:

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:

第1步:文件->新建->导入模块

Step 1:File->New->Import Module

第2步选择模块并根据需要重命名

step 2 select the module and rename if you need

第3步选择所有选项

在这里android studio可能会要求您更新,更新

here android studio may ask you to update, update it

第4步处理模块依赖性

此后,Gradle Build自动运行 在这里,我们已经完成了人行横道的进口.

After this ,the Gradle Build Running automatically Here We have finished the crosswalk inport.

第5步使用XWalkView

step 5 use the XWalkView

将此特权添加到AndroidManifest.xml

add this priviledges to AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

在AndroidManifest.xml的应用程序节点上添加硬件加速

add hardware acceleration on to application node of AndroidManifest.xml

android:hardwareAccelerated="true"

将此添加到布局文件

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

将此添加到活动中

XWalkView mXWalkView = (XWalkView) findViewById(R.id.xWalkView);
mXWalkView.load("http://192.168.1.42/test", null);

我们到此结束 这是我使用webview和XWalkView渲染three.js STL加载程序的结果.

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

不支持Webview

webview not support

XWalkView很好支持

XWalkView supports well

哈哈,行得通.

关注是另一个旧的实现,您还可以参考此很好的[post]或 11 .

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

这是源代码.

下载适当的Crosswalk Android Webview软件包,然后从 https://crosswalk-project.org进行解压缩/documentation/downloads.html

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

从人行横道库中将xwalk_core_library_java.jar复制到android studio项目中的app/libs/中,然后单击文件,选择添加为库"

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"

将人行横道库下的其他内容复制到app/src/main/jniLibs/

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

制作一个Android资源目录res2,并将crosswalk res目录中的文件复制到该目录.

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

将此添加到AndroidMenifest.xml

Add this to AndroidMenifest.xml

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


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

将此添加到布局

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

将此添加到活动

XWalkView mXWalkView = (XWalkView) findViewById(R.id.webview);
    mXWalkView.load("http://xxxxxx.com", null);

如果要调试romote,请添加.

if you want to debug romote add this.

XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);

这篇关于如何在我自己的android库模块中添加人行横道的webview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆