BuglyDevTeam / Bugly-Android-Demo

Bugly Android SDK 使用例子
Apache License 2.0
812 stars 307 forks source link

BetaUploadStrategy.a on a null object reference #238

Closed selway closed 4 years ago

selway commented 4 years ago

异常类型

app运行时异常。 bugly 内部类报错:Attempt to read from field 'com.tencent.bugly.proguard.bk com.tencent.bugly.beta.upgrade.BetaUploadStrategy.a' on a null object reference

手机系统版本

Android 7.1.2

版本

    implementation 'com.tencent.bugly:crashreport_upgrade:latest.release'  (1.4.5)
    implementation 'com.tencent.bugly:nativecrashreport:latest.release'  (3.7.1)

gradle版本

3.4.2

堆栈/日志

05-27 23:57:41.560  2935  2935 E CrashReport: java.lang.NullPointerException: Attempt to read from field 'com.tencent.bugly.proguard.bk com.tencent.bugly.beta.upgrade.BetaUploadStrategy.a' on a null object reference
05-27 23:57:41.560  2935  2935 E CrashReport:   at com.tencent.bugly.beta.upgrade.c.a(BUGLY:516)
05-27 23:57:41.560  2935  2935 E CrashReport:   at com.tencent.bugly.beta.Beta.a(BUGLY:231)
05-27 23:57:41.560  2935  2935 E CrashReport:   at com.tencent.bugly.beta.Beta.checkUpgrade(BUGLY:198)
05-27 23:57:41.560  2935  2935 E CrashReport:   at com.tencent.bugly.beta.Beta.checkUpgrade(BUGLY:189)
05-27 23:57:41.560  2935  2935 E CrashReport:   at com.mine.demo.activity.ViewActivity.onViewClicked(ViewActivity.java:246)
05-27 23:57:41.560  2935  2935 E CrashReport:   at com.mine.demo.activity.ViewActivity_ViewBinding$2.doClick(ViewActivity_ViewBinding.java:48)
05-27 23:57:41.560  2935  2935 E CrashReport:   at butterknife.internal.DebouncingOnClickListener.onClick(DebouncingOnClickListener.java:18)
05-27 23:57:41.560  2935  2935 E CrashReport:   at android.view.View.performClick(View.java:5637)
05-27 23:57:41.560  2935  2935 E CrashReport:   at android.view.View$PerformClick.run(View.java:22445)
05-27 23:57:41.560  2935  2935 E CrashReport:   at android.os.Handler.handleCallback(Handler.java:755)
05-27 23:57:41.560  2935  2935 E CrashReport:   at android.os.Handler.dispatchMessage(Handler.java:95)
05-27 23:57:41.560  2935  2935 E CrashReport:   at android.os.Looper.loop(Looper.java:154)
05-27 23:57:41.560  2935  2935 E CrashReport:   at android.app.ActivityThread.main(ActivityThread.java:6141)
05-27 23:57:41.560  2935  2935 E CrashReport:   at java.lang.reflect.Method.invoke(Native Method)
05-27 23:57:41.560  2935  2935 E CrashReport:   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
05-27 23:57:41.560  2935  2935 E CrashReport:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
05-27 23:57:41.561  2935  2935 D BaseApp : upgradeStateListener upgrading
05-27 23:57:41.561   225   283 E AudioFlinger: no wake lock to update, but system ready!
05-27 23:57:41.800   225   283 E AudioFlinger: no wake lock to update, but system ready!
05-27 23:57:43.842  1482  1482 D IlinkService: [, , 0]:Receive broadcast mypkgname:com.tencent.wxpayface, sender:com.tencent.wxpayface, sender process:null
05-27 23:57:43.843  1482  1482 D IlinkService: [, , 0]:Alive msg send by ourself not need to handle!
05-27 23:57:43.845  1482  1511 D IlinkService: [, , 0]:It is a timer alive task:94
05-27 23:57:47.562  2935  2935 I CrashReport: upload err:[804] [sended 0] [recevied 0]
05-27 23:57:47.564  2935  2935 I CrashReport: request is not finished
05-27 23:57:47.571  2935  2935 E CrashReport: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
05-27 23:57:47.571  2935  2935 E CrashReport:   at android.widget.Toast.<init>(Toast.java:103)
05-27 23:57:47.571  2935  2935 E CrashReport:   at android.widget.Toast.makeText(Toast.java:256)
05-27 23:57:47.571  2935  2935 E CrashReport:   at com.tencent.bugly.beta.utils.f.a(BUGLY:29)
05-27 23:57:47.571  2935  2935 E CrashReport:   at com.tencent.bugly.beta.global.d.run(BUGLY:252)
05-27 23:57:47.571  2935  2935 E CrashReport:   at android.os.Handler.handleCallback(Handler.java:755)
05-27 23:57:47.571  2935  2935 E CrashReport:   at android.os.Handler.dispatchMessage(Handler.java:95)
05-27 23:57:47.571  2935  2935 E CrashReport:   at android.os.Looper.loop(Looper.java:154)
05-27 23:57:47.571  2935  2935 E CrashReport:   at android.app.ActivityThread.main(ActivityThread.java:6141)
05-27 23:57:47.571  2935  2935 E CrashReport:   at java.lang.reflect.Method.invoke(Native Method)
05-27 23:57:47.571  2935  2935 E CrashReport:   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
05-27 23:57:47.571  2935  2935 E CrashReport:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)

其它相关信息

初始化时传的Context不为null。 image

selway commented 4 years ago

我解决了,但是目前还不知道为什么会这样 原来写的是: Bugly.init(getApplicationContext(), APP_ID, BuildConfig.DEBUG); 死活都报错。

解决方法 别用BuildConfig.DEBUG,直接truefalse或者定义的常量都行, Bugly.init(getApplicationContext(), APP_ID, false); 这样就不报错了,OMG太坑了,浪费了好长时间。 希望可以帮到后面的同仁们。

guoq1 commented 4 years ago

我也是这个错误, 按你的改完仍然报这个错

W/BuglyThread-2: type=1400 audit(0.0:140): avc: denied { search } for name="power_supply" dev="sysfs" ino=11518 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:sysfs_batteryinfo:s0 tclass=dir permissive=0

W/System.err: java.lang.NullPointerException: Attempt to read from field 'com.tencent.bugly.proguard.bk com.tencent.bugly.beta.upgrade.BetaUploadStrategy.a' on a null object reference

W/System.err: at com.tencent.bugly.beta.upgrade.c.a(BUGLY:516)

xue12311 commented 3 years ago

好像是这个要设置为 true Beta.autoInit = true

MikeVoy commented 3 years ago

我也是这个错误, 按你的改完仍然报这个错

W/BuglyThread-2: type=1400 audit(0.0:140): avc: denied { search } for name="power_supply" dev="sysfs" ino=11518 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:sysfs_batteryinfo:s0 tclass=dir permissive=0

W/System.err: java.lang.NullPointerException: Attempt to read from field 'com.tencent.bugly.proguard.bk com.tencent.bugly.beta.upgrade.BetaUploadStrategy.a' on a null object reference

W/System.err: at com.tencent.bugly.beta.upgrade.c.a(BUGLY:516)

我也是这个错误, 按你的改完仍然报这个错

W/BuglyThread-2: type=1400 audit(0.0:140): avc: denied { search } for name="power_supply" dev="sysfs" ino=11518 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:sysfs_batteryinfo:s0 tclass=dir permissive=0

W/System.err: java.lang.NullPointerException: Attempt to read from field 'com.tencent.bugly.proguard.bk com.tencent.bugly.beta.upgrade.BetaUploadStrategy.a' on a null object reference

W/System.err: at com.tencent.bugly.beta.upgrade.c.a(BUGLY:516)

老哥你这边解决了吗 我试了几个方法都没有用

xiaoyaomeng commented 3 years ago

我也遇到了,可惜这个sdk真的资料太少。还混淆了,不好看

zhul123 commented 3 years ago

好像是这个要设置为 true Beta.autoInit = true

按照你的这个写,对了,在初始化后面就加上。MD浪费我一下午。也没找到问题

budaowengd commented 2 years ago

Beta.autoInit = true 加上也报错, 1年了, 还没解决这个bug吗?

guoq1 commented 2 years ago

您好:        您的邮件已收到,会尽快给您回复!           郭琦   (自动回复邮件)  

wuguangxin commented 2 years ago

我18年写的项目,非kotlin,正常检测更新,同样的代码搬到kotlin项目,同一个手机,也报这个空指针异常,以上方式都不能解决,我怀疑跟项目的编译和运行环境有关,暂时没找到证据

guoq1 commented 2 years ago

您好:        您的邮件已收到,会尽快给您回复!           郭琦   (自动回复邮件)