[英]How to add crosswalk webview in my own android library module?
I am in the development of an Android library module which has to include Crosswalk Webview. 我正在开发一个Android库模块,其中必须包含Crosswalk Webview。 I create the library using Github Sonatype ( https://github.com/sonatype/ ). 我使用Github Sonatype( https://github.com/sonatype/ )创建库。 It works fine without Crosswalk Webview. 没有Crosswalk Webview,它可以正常工作。 I tried the following 3 methods to include Crosswalk. 我尝试了以下3种方法来包含Crosswalk。
Method 1: 方法1:
Add Crosswalk Webview library in my library project app gradle 在我的库项目应用程序gradle中添加Crosswalk Webview库
Error : (Compile error) 错误:(编译错误)
Failed to resolve: org.xwalk:xwalk_core_library:18.48.477.13 无法解决:org.xwalk:xwalk_core_library:18.48.477.13
Method 2: 方法2:
Add crosswalk aar file in my library project 在我的库项目中添加crosswalk 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 添加aar文件的参考链接如何将.aar文件导入Android Studio 1.1.0并在我的代码中使用它
I have downloaded Crosswalk Webview from https://download.01.org/crosswalk/releases/crosswalk/android/stable/18.48.477.13/ 我从https://download.01.org/crosswalk/releases/crosswalk/android/stable/18.48.477.13/下载了Crosswalk Webview
Error: (Compile error) 错误:(编译错误)
Failed to resolve: MyLIBApplication:xwalk_core_library_java:unspecified 无法解决:MyLIBApplication:xwalk_core_library_java:未指定
Method 3: 方法3:
Add crosswalk jar file in my library project 在我的库项目中添加crosswalk jar文件
Download Link https://download.01.org/crosswalk/releases/crosswalk/android/stable/18.48.477.13/ 下载链接https://download.01.org/crosswalk/releases/crosswalk/android/stable/18.48.477.13/
Error : This method no compilation error but it give run time error that was java.lang.NoClassDefFoundError: org.xwalk.core.R$string 错误:此方法没有编译错误,但它给出了运行时错误,即java.lang.NoClassDefFoundError:org.xwalk.core.R $ string
Note: I tried both jar (ordinary, share mode) files 注意:我尝试了两种jar(普通,共享模式)文件
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. 我从webview创建一个新的应用程序到XWalkView来呈现three.js stl加载器演示,无论WebGlRenderer还是CanvasRenderer都不支持webview。 Here is the process how to use the crosswalk module: 以下是如何使用人行横道模块的过程:
Step 1:File->New->Import Module 第1步:文件 - >新建 - >导入模块
step 2 select the module and rename if you need 步骤2选择模块并根据需要重命名
step 3 choose all the option 第3步选择所有选项
here android studio may ask you to update, update it 这里的android studio可能会要求你更新,更新它
step 4 process the module dependency 第4步处理模块依赖
After this ,the Gradle Build Running automatically Here We have finished the crosswalk inport. 在此之后,Gradle Build自动运行在这里我们完成了人行横道入口。
step 5 use the XWalkView 第5步使用XWalkView
add this priviledges to AndroidManifest.xml 将此权限添加到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" />
add hardware acceleration on to application node of AndroidManifest.xml 将硬件加速添加到AndroidManifest.xml的应用程序节点上
android:hardwareAccelerated="true"
add this to layout file 将其添加到布局文件中
<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>
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和XWalkView来渲染three.js STL加载器。
webview not support webview不支持
XWalkView supports well XWalkView支持得很好
Haha it works. 哈哈,它的工作原理。
Follow is the another old implementation , and you can also refer to this good [post] or doc 11 . Follow是另一个旧的实现,你也可以参考这个好[post]或doc 11 。
here is the source code . 这是源代码 。
Download proper Crosswalk Android webview package and unpackage it from https://crosswalk-project.org/documentation/downloads.html 下载正确的Crosswalk Android webview包并从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" 将xwalk_core_library_java.jar从crosswalk libs复制到android studio项目中的app / libs /,然后单击该文件,选择“Adds As Library”
Copy other contents under crosswalk libs to app/src/main/jniLibs/ 将crosswalk libs下的其他内容复制到app / src / main / jniLibs /
Make an Android Resource dir res2, and copy files in crosswalk res dir to this dir. 创建一个Android资源目录res2,并将人行横道res目录中的文件复制到此目录。
Add this to AndroidMenifest.xml 将其添加到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
add this to layout 将此添加到布局
<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>
add this to Activity 将此添加到Activity
XWalkView mXWalkView = (XWalkView) findViewById(R.id.webview);
mXWalkView.load("http://xxxxxx.com", null);
if you want to debug romote add this. 如果你想调试romote添加这个。
XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.