crosswalk使用-maven和本地jar、so

一.maven

修改模块中的build.gradle,添加引用

//build.gradle
repositories {
    maven {
        url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
    }
}
dependencies {
    //...
    implementation 'org.xwalk:xwalk_core_library:23.53.589.4'
}

同步后就可以是用xWalkview了,编译出来的apk多了50多M。

 

二.jar、so引用---crosswalk同时还需要导入资源文件才能正常使用

1.下载jar、so文件 https://download.01.org/crosswalk/releases/crosswalk/android/stable/latest/crosswalk-23.53.589.4.zip
2.创建目录,拷贝文件

 

3.修改build.gradle文件

 需要将 libs/so 修改为 libs

android {
    ...
    sourceSets {
        main {
            // 添加libs/so中的so文件
            jniLibs.srcDirs = ['libs/so']
        }
    }
}
dependencies {
//    implementation fileTree(include: ['*.jar'], dir: 'libs') //添加所有的libs下的jar文件
    implementation files('libs/xwalk_core_library.jar') //单独添加一个crosswalk用到的jar文件
}

//修改为,不然,没有把so包含到apk中去。
	sourceSets {
		main {
			// 添加libs/so中的so文件
			jniLibs.srcDirs = ['libs']
		}
	}

  

3.填加好后同步,可引用jar中的函数

 

4.编译,烧写时错误
INSTALL_FAILED_NO_MATCHING_ABIS
//这个错误提示, 是由于使用了native libraries 。该native libraries 不支持当前的cpu的体系结构。

  

 5.修改目录名称,

为crosswalk的原始名称

 

 

6.运行报错

root@ponkan:/ # am start -n com.example.lyj.crosswalk/.MainActivity
01-01 08:02:20.351  3175  3175 E dhcpcd  : option60 no in offer/ack packet, could not use this ip
01-01 08:02:20.730  3211  3214 E cutils-trace: Error opening trace file: No such file or directory (2)
Starting: Intent { cmp=com.example.lyj.crosswalk/.MainActivity }
01-01 08:02:20.858  3224  3224 E Zygote  : Zygote:  error closing descriptor
01-01 08:02:20.858  3224  3224 E Zygote  : android.system.ErrnoException: close failed: EBADF (Bad file number)
01-01 08:02:20.858  3224  3224 E Zygote  : 	at libcore.io.Posix.close(Native Method)
01-01 08:02:20.858  3224  3224 E Zygote  : 	at libcore.io.BlockGuardOs.close(BlockGuardOs.java:101)
01-01 08:02:20.858  3224  3224 E Zygote  : 	at android.system.Os.close(Os.java:70)
01-01 08:02:20.858  3224  3224 E Zygote  : 	at com.android.internal.os.ZygoteInit.closeServerSocket(ZygoteInit.java:209)
01-01 08:02:20.858  3224  3224 E Zygote  : 	at com.android.internal.os.ZygoteConnection.handleChildProc(ZygoteConnection.java:885)
01-01 08:02:20.858  3224  3224 E Zygote  : 	at com.android.internal.os.ZygoteConnection.runOnce(ZygoteConnection.java:267)
01-01 08:02:20.858  3224  3224 E Zygote  : 	at com.android.internal.os.ZygoteInit.runSelectLoop(ZygoteInit.java:791)
01-01 08:02:20.858  3224  3224 E Zygote  : 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)
[dvfs_boost] this client is not running
root@ponkan:/ # 
root@ponkan:/ # --------- beginning of crash
01-01 08:02:21.109  3224  3249 E AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
01-01 08:02:21.109  3224  3249 E AndroidRuntime: Process: com.example.lyj.crosswalk, PID: 3224
01-01 08:02:21.109  3224  3249 E AndroidRuntime: java.lang.RuntimeException: An error occured while executing doInBackground()
01-01 08:02:21.109  3224  3249 E AndroidRuntime: 	at android.os.AsyncTask$3.done(AsyncTask.java:304)
01-01 08:02:21.109  3224  3249 E AndroidRuntime: 	at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
01-01 08:02:21.109  3224  3249 E AndroidRuntime: 	at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
01-01 08:02:21.109  3224  3249 E AndroidRuntime: 	at java.util.concurrent.FutureTask.run(FutureTask.java:242)
01-01 08:02:21.109  3224  3249 E AndroidRuntime: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
01-01 08:02:21.109  3224  3249 E AndroidRuntime: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
01-01 08:02:21.109  3224  3249 E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:818)
01-01 08:02:21.109  3224  3249 E AndroidRuntime: Caused by: java.lang.RuntimeException: R.raw.xwalk_100_percent can't be found.
01-01 08:02:21.109  3224  3249 E AndroidRuntime: 	at org.xwalk.core.internal.XWalkViewDelegate$2.openRawResource(XWalkViewDelegate.java:295)
01-01 08:02:21.109  3224  3249 E AndroidRuntime: 	at org.chromium.base.ResourceExtractor$ExtractTask.doInBackgroundImpl(ResourceExtractor.java:144[dvfs_boost] this client is not running
)
01-01 08:02:21.109  3224  3249 E AndroidRuntime: 	at org.chromium.base.ResourceExtractor$ExtractTask.doInBackground(ResourceExtractor.java:175)
01-01 08:02:21.109  3224  3249 E AndroidRuntime: 	at org.chromium.base.ResourceExtractor$ExtractTask.doInBackground(ResourceExtractor.java:72)
01-01 08:02:21.109  3224  3249 E AndroidRuntime: 	at android.os.AsyncTask$2.call(AsyncTask.java:292)
01-01 08:02:21.109  3224  3249 E AndroidRuntime: 	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
01-01 08:02:21.109  3224  3249 E AndroidRuntime: 	... 3 more
01-01 08:02:21.172  1611  1643 E WindowState: getStack: Window{2752549c u0 Starting com.example.lyj.crosswalk} couldn't find taskId=3 Callers=com.android.server.wm.WindowState.getDisplayContent:785 com.android.server.wm.WindowState.getWindowList:1357 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2784 com.android.server.wm.WindowManagerService.removeWindowLocked:2685 
01-01 08:02:21.173  1611  1643 E WindowState: getStack: Window{2752549c u0 Starting com.example.lyj.crosswalk} couldn't find taskId=3 Callers=com.android.server.wm.WindowState.getDisplayContent:785 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2789 com.android.server.wm.WindowManagerService.removeWindowLocked:2685 com.android.server.wm.WindowManagerService.removeWindow:2607 
01-01 08:02:21.214  2242  2242 E chromium: [ERROR:layer_tree_host_impl.cc(2206)] Forcing zero-copy tile initialization as worker context is missing
01-01 08:02:24.318  3175  3175 E dhcpcd  : option60 no in offer/ack packet, could not use this ip

  

  

  仅打印error级错误

 

7.对比正常运行maven代码打印

root@ponkan:/ # am start -n com.example.lyj.crosswalk/.MainActivity
01-01 09:28:55.111 12279 12281 E cutils-trace: Error opening trace file: No such file or directory (2)
Starting: Intent { cmp=com.example.lyj.crosswalk/.MainActivity }
01-01 09:28:55.259 12291 12291 E Zygote  : Zygote:  error closing descriptor
01-01 09:28:55.259 12291 12291 E Zygote  : android.system.ErrnoException: close failed: EBADF (Bad file number)
01-01 09:28:55.259 12291 12291 E Zygote  : 	at libcore.io.Posix.close(Native Method)
01-01 09:28:55.259 12291 12291 E Zygote  : 	at libcore.io.BlockGuardOs.close(BlockGuardOs.java:101)
01-01 09:28:55.259 12291 12291 E Zygote  : 	at android.system.Os.close(Os.java:70)
01-01 09:28:55.259 12291 12291 E Zygote  : 	at com.android.internal.os.ZygoteInit.closeServerSocket(ZygoteInit.java:209)
01-01 09:28:55.259 12291 12291 E Zygote  : 	at com.android.internal.os.ZygoteConnection.handleChildProc(ZygoteConnection.java:885)
01-01 09:28:55.259 12291 12291 E Zygote  : 	at com.android.internal.os.ZygoteConnection.runOnce(ZygoteConnection.java:267)
01-01 09:28:55.259 12291 12291 E Zygote  : 	at com.android.internal.os.ZygoteInit.runSelectLoop(ZygoteInit.java:791)
01-01 09:28:55.259 12291 12291 E Zygote  : 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)
[dvfs_boost] this client is not running
root@ponkan:/ # 
root@ponkan:/ # 01-01 09:28:55.702 12291 12291 E chromium: [ERROR:xwalk_platform_notification_service.cc(143)] Not implemented reached in virtual bool xwalk::XWalkPlatformNotificationService::GetDisplayedPersistentNotifications(content::BrowserContext*, std::__1::set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >*)
01-01 09:28:55.707 12291 12291 E chromium: [ERROR:xwalk_browser_context.cc(88)] Failed to read preference, error num: 0
01-01 09:28:55.818 12291 12346 E libEGL  : validate_display:255 error 3008 (EGL_BAD_DISPLAY)
01-01 09:28:56.398 12291 12354 E cr_MediaResource: Refusing to read from unsafe file location.
01-01 09:28:56.398 12291 12354 E cr_MediaResource: Unable to configure metadata extractor
01-01 09:28:56.405 12291 12291 E MediaPlayer-JNI: [Warning] Native MediaPlayer has already been released, get current position return 0
01-01 09:28:56.416 12291 12359 E MediaPlayer-JNI: [Warning] Native MediaPlayer has already been released, get current position return 0
01-01 09:28:56.430  1146 12358 E GenericSource: Failed to init from data source!
01-01 09:28:56.430 12291 12308 E MediaPlayer: error (1, -2147483648)
01-01 09:28:56.430 12291 12291 E MediaPlayer: Error (1,-2147483648)
01-01 09:28:56.447 12291 12291 E MediaPlayer: Should have subtitle controller already set
01-01 09:28:56.448 12291 12359 E MediaPlayer: Should have subtitle controller already set

  仅打印error级错误

 

8.res中的资源文件导入后,正常

 


9.点击执行

prompt弹出窗口是异常,闪退

使用maven时是能正常弹出的

 

 

binder: 16709: binder_alloc_buf failed to map pages in userspace, no vma
binder: 1611:16827 transaction failed 29201, size 104-4
01-01 10:09:53.362  1611 16827 E JavaBinder: !!! FAILED BINDER TRANSACTION !!!
01-01 10:09:53.368  1137  1137 E lowmemorykiller: Error writing /proc/16709/oom_score_adj; errno=22
binder: 16709: binder_alloc_buf, no vma
binder: 1611:1643 transaction failed 29201, size 60-0
01-01 10:09:53.392  1611  1643 E JavaBinder: !!! FAILED BINDER TRANSACTION !!!
01-01 10:09:53.441  1611  1742 E InputDispatcher: channel '625d759 com.example.lyj.crosswalk/com.example.lyj.crosswalk.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
[dvfs_boost] this client is not running
binder: 16173:16329 transaction failed 29189, size 84-0
01-01 10:09:53.557  2242  2242 E chromium: [ERROR:layer_tree_host_impl.cc(2206)] Forcing zero-copy tile initialization as worker context is missing

 

10.重写函数可以解决问题。但弹窗需自己定义。图片中的代码不会弹出窗口。

 

 

11.修改导入的包后正常

AlertDialog.Builder

 

posted @ 2018-09-13 16:36  liuyj_vv  阅读(1230)  评论(0编辑  收藏  举报