uni-app WX_RENDER_ERR_JS_CREATE_INSTANCE_CONTEXT exception white screen

uni-app WX_RENDER_ERR_JS_CREATE_INSTANCE_CONTEXT exception white screen

操作步骤:

  1. 新建uniapp程序,可以不修改程序的任何内容
  2. 生成本地打包app资源,然后把资源拷贝到原生插件开发demo:“UniPlugin-Hello-AS”中的UniPlugin-Hello-AS\app\src\main\assets\apps的根目录下
  3. 把原生插件,解压放到UniPlugin-Hello-AS根目录下
  4. 配置data/dcloud_control.xml,配置dcloud_uniplugins.json,配置build.gradle引用原生插件
  5. 编译运行程序,查看结果。当程序运行起来后,重启手机查看程序是否能够正常运行(有时候能自动重启,有时候重启就是白屏)

预期结果:

设备重启,app能够正常启动。

实际结果:

设备有时候能正常启动,有时候启动白屏,并且报下方的错误。(测试过uniapp中没写任何js也会报这个错误)

2021-12-09 10:52:56.666 1279-1302/com.android.UniPlugin E/weex: reportJSException >>> instanceId:1, exception function:createInstanceContext, exception:Uncaught SyntaxError: Invalid or unexpected token  
2021-12-09 10:52:56.668 1279-1302/com.android.UniPlugin E/weex: onJSException -9700,Uncaught SyntaxError: Invalid or unexpected token  
2021-12-09 10:52:56.669 1279-1302/com.android.UniPlugin E/weex: commitCriticalExceptionRT :WX_RENDER_ERR_JS_CREATE_INSTANCE_CONTEXTexceptionwhite screen cause create instanceContext failed,check js stack ->Uncaught SyntaxError: Invalid or unexpected token

### bug描述:
自主开发android平台开机自动app原生插件。插件开发完成测试发现有时候能够正常开机启动,有时候开机启动就白屏。报警代码如下:

2021-12-09 10:52:56.666 1279-1302/com.android.UniPlugin E/weex: reportJSException >>> instanceId:1, exception function:createInstanceContext, exception:Uncaught SyntaxError: Invalid or unexpected token
2021-12-09 10:52:56.668 1279-1302/com.android.UniPlugin E/weex: onJSException -9700,Uncaught SyntaxError: Invalid or unexpected token
2021-12-09 10:52:56.669 1279-1302/com.android.UniPlugin E/weex: commitCriticalExceptionRT :WX_RENDER_ERR_JS_CREATE_INSTANCE_CONTEXTexceptionwhite screen cause create instanceContext failed,check js stack ->Uncaught SyntaxError: Invalid or unexpected token
当开机白屏时,则需要卸载手机端的程序,然后重新编译安装程序,有时候编译安装一次能解决,有时候需要多次卸载并安装才能解决。
我目前做测试使用的uniapp,已经把所有的js删掉了,还是会有同样的问题出现。


### 图片
![Image 1](https://www.itying.com/uniimg.php?url=https://img-cdn-tc.dcloud.net.cn/uploads/questions/20211209/8a63ece7cf2ba344e3a4766226a90fe4.png)
![Image 2](https://www.itying.com/uniimg.php?url=https://img-cdn-tc.dcloud.net.cn/uploads/questions/20211209/28959bd8af0b60ff49c67d446e42a6d6.png)

### 附件
- [原生插件源码.zip](//ask.dcloud.net.cn/file/download/file_name-5Y6f55Sf5o+S5Lu25rqQ56CBLnppcA==__url-Ly9pbWctY2RuLXRjLmRjbG91ZC5uZXQuY24vdXBsb2Fkcy9xdWVzdGlvbnMvMjAyMTEyMDkvNjhkYzkwMGE2Y2RjYTAwMjRmOTMzMDEwZWYyMzQ3OGQ=)

### 表格
| 信息类别   | 详细信息         |
|------------|------------------|
| 产品分类   | uniapp/App       |
| PC开发环境操作系统 | Windows          |
| PC开发环境操作系统版本号 | Windows 10 专业版 |
| HBuilderX类型 | 正式             |
| HBuilderX版本号 | 3.2.16           |
| 手机系统    | Android          |
| 手机系统版本号 | Android 7.1.1    |
| 手机厂商    | 安卓一体机        |
| 手机机型    | k7G20            |
| 页面类型   | vue              |
| vue版本    | vue2             |
| 打包方式   | 离线             |
| 项目创建方式 | HBuilderX        |

更多关于uni-app WX_RENDER_ERR_JS_CREATE_INSTANCE_CONTEXT exception white screen的实战教程也可以访问 https://www.itying.com/category-93-b0.html

回到顶部