简体   繁体   English

NullPointerExceptions仅在某些Samsung Galaxy设备上吗?

[英]NullPointerExceptions only on some Samsung Galaxy devices?

I'm using LibGDX. 我正在使用LibGDX。 When my app starts, it creates a Screen. 当我的应用启动时,它将创建一个屏幕。 When the Screen is loaded, it calls a static function Module.createStyles() . 加载Screen时,它将调用静态函数Module.createStyles()

This function creates a bunch of styles that will be used throughout the rest of the application (built-in LibGDX styles like WindowStyle, LabelStyle, TextButtonStyle - all of the types of things used to create the user-interface objects). 此函数创建了一系列样式,这些样式将在应用程序的其余部分中使用(内置的LibGDX样式,例如WindowStyle,LabelStyle,TextButtonStyle-用于创建用户界面对象的所有类型的东西)。

When the Screen is done, it calls Module.disposeStyles() . 完成屏幕后,它将调用Module.disposeStyles()

Anyway, according to my Google Analytics crash reports, I randomly get a NullPointerException when trying to, for example, create a Dialog with Module.dialogStyle : 无论如何,根据我的Google Analytics(分析)崩溃报告,例如,尝试使用Module.dialogStyle创建Dialog时,我会随机获得NullPointerException

ExitDialog exitDialog = new ExitDialog("Are you sure?", Module.dialogStyle);

Thread: GLThread 2089, Exception: java.lang.IllegalArgumentException: style cannot be null.
at package.Window.setStyle(Window.java:181)
at package.Window.<init>(Window.java:63)
at package.Dialog.<init>(Dialog.java:65)
at package.ExitDialog$1.<init>(ExitDialog.java:38)

There is absolutely no reason Module.dialogStyle should be null. 绝对没有理由Module.dialogStyle应该为null。 The only place I null this field is in Module.disposeStyles() and this function is only called in one specific place in the application (at the very end). 我将此字段Module.disposeStyles() null的唯一位置是在Module.disposeStyles()并且仅在应用程序的一个特定位置(最后)调用此函数。

I would assume this was a bug in my code somehow even though 95% of users never experience it. 我会假设这是我代码中的错误,即使95%的用户从未遇到过。 However, all 5% that do experience it seem to be Galaxy users and I'm not sure if that's a coincidence: 但是,所有5%确实经历过体验的人似乎都是Galaxy用户,而且我不确定这是否是巧合:

  • Galaxy S4 银河S4
  • Galaxy S III 银河S III
  • GALAXY Tab 3 lite GALAXY Tab 3 lite

Anyone have any ideas? 有人有想法么? Don't Galaxy devices have a built-in RAM manager? Galaxy设备没有内置的RAM管理器吗? Would that have something to do with this? 这与这有关吗?

I'm going to assume that: 我将假设:

Module.dialogStyle

is a reference to a static property on the Module class. 是对Module类的static属性的引用。

You are probably running into side-effects of how Android manages the life-cycle of JVMs. 您可能会遇到Android如何管理JVM生命周期的副作用。 There are scenarios (especially on bigger devices) where a JVM instance will be re-used that can cause problems (static initializers will have already been run, for example, and will not re-run). 在某些情况下(尤其是在较大的设备上),将重新使用JVM实例可能会导致问题(例如,静态初始化程序已经运行,并且不会重新运行)。 Alternatively, static pointers may live from a previous run of your application into the next, and may have invalid or incorrect state in them. 另外, static指针可能从您的应用程序的上一次运行到下一次运行,并且可能具有无效或不正确的状态。 It depends on the particulars of how your app is organized. 这取决于应用程序的组织方式。

If you include more of the code that shows how and when you initialize the static fields, we can probably figure it out. 如果您包含更多显示初始化静态字段的方式和时间的代码,我们很可能会弄清楚。

For more details on the different lifecycles and how to reproduce them locally, see: http://bitiotic.com/blog/2013/05/23/libgdx-and-android-application-lifecycle/ 有关不同生命周期以及如何在本地复制它们的更多详细信息,请参见: http : //bitiotic.com/blog/2013/05/23/libgdx-and-android-application-lifecycle/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 三星Galaxy设备的内存不足 - Out of Memory on Samsung Galaxy devices Android NDK库仅在运行时未加载三星galaxy 4.0.2手机 - Android NDK library is not loading on runtime for samsung galaxy 4.0.2 phones only 仅在具有OutOfMemoryException的三星Galaxy S7 Edge上应用程序运行缓慢 - App slow ONLY on Samsung Galaxy S7 Edge with OutOfMemoryException 仅来自Galaxy Samsung的java.lang.NullPointerException错误 - java.lang.NullPointerException error only from Galaxy samsung 如何制作需要相机支持的Android应用程序才能在Samsung Galaxy Mini和类似设备上运行? - How to make Android app requiring camera support to run on Samsung Galaxy Mini and similar devices? 突然间,谷歌登录在少数设备上不起作用,比如一加和三星 Galaxy - All of sudden Google Sign in is not working in few devices like One plus and Samsung Galaxy 服务器和客户端通过android devices.ex中的wifi聊天。三星Duos,Galaxy - server and client chat over wifi in android devices.ex Samsung Duos, Galaxy WebView 和前置摄像头在某些三星设备上不起作用 - WebView and front camera does not work on some Samsung devices Android java.lang.OutOfMemoryError仅在Samsung设备上 - Android java.lang.OutOfMemoryError only on Samsung devices VerifyError-仅在某些Android设备上 - VerifyError - only on some android devices
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM