其他细节:
- 授权弹窗可以拉起
- 用户端取消授权不闪退
- 其他wx底层实现:开发者工具、PC端、IOS端都正常
- btw,之前此逻辑一直没有问题,最近突然出现
- 尝试以下三个方法,无法修复此问题:切换调试基础库(between 2.xx 3.xx)、更换手机、清除缓存
游戏引擎:Unity转微信小游戏
Unity转换插件版本:202312131914
前端代码调用:
// 之前调用wx.Login并且成功返回。
var vbtn = WX.CreateUserInfoButton(
(int)rect.xMin, (int)rect.yMin,
(int)rect.width, (int)rect.height,
"zh_CN", true);
Debug.Log($"rect {rect}"); // rect 大小位置正常
vbtn .OnTap(res =>
{ // 此处用户同意授权必闪退
Debug.Log(res.errCode);
Debug.Log(res.errMsg);
});
后台错误日志:
12-25 15:55:13.949 10071 10071 D AndroidRuntime: Shutting down VM
12-25 15:55:13.949 10071 10071 E AndroidRuntime: FATAL EXCEPTION: main
12-25 15:55:13.949 10071 10071 E AndroidRuntime: Process: com.tencent.mm:appbrand2, PID: 10071
12-25 15:55:13.949 10071 10071 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at com.tencent.mm.plugin.appbrand.b5.a(SourceFile:89)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at com.tencent.mm.plugin.appbrand.AppBrandRuntime.c(SourceFile:32)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at tv0.h$a.a(Unknown Source:12)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at ey0.g.o(SourceFile:11)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at com.tencent.mm.plugin.appbrand.jsapi.auth.JsApiOperateWXData$OperateWXDataTask$b.run(SourceFile:419)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at com.tencent.mm.plugin.appbrand.AppBrandRuntime.b1(SourceFile:50)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at com.tencent.mm.plugin.appbrand.AppBrandRuntime.a1(Unknown Source:2)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at com.tencent.mm.plugin.appbrand.jsapi.m.v(SourceFile:10)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at com.tencent.mm.plugin.appbrand.jsapi.auth.JsApiOperateWXData$OperateWXDataTask.g(SourceFile:412)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at com.tencent.mm.plugin.appbrand.ipc.k.run(SourceFile:35)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:463)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:264)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at qd4.k.run(SourceFile:247)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:942)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at pd4.f$b$a.dispatchMessage(SourceFile:28)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:240)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at android.os.Looper.loop(Looper.java:351)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8422)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
12-25 15:55:13.949 10071 10071 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
----------------------------------------更新分割线------------------------------------------------------
简化了复现方式。使用如下game.js代码,结果表现一样:
// game.js
;(async()=>{
var settings = await wx.getSetting();
if(settings.authSetting['scope.userInfo']){
console.log(await wx.getUserInfo());
}else{
var vbtn = wx.createUserInfoButton({
type:"text",
style:{
left : 100,
top : 100,
width:200,
height:64,
}
});
vbtn.onTap(console.log) // 也是同意后闪退
}
})();
使用官方API示例同样闪退
let button = wx.createUserInfoButton({ type: 'text', text: '获取用户信息', style: { left: 10, top: 76, width: 200, height: 40, lineHeight: 40, backgroundColor: '#ff0000', color: '#ffffff', textAlign: 'center', fontSize: 16, borderRadius: 4 } }) button.onTap((res) => { console.log(res) })
如此基础的模块失效,影响严重。希望官方尽快解决
1. 修改调试基础库版本,推到出问题的开发者手机上
2. 清空app缓存
3. 重试,不闪退