Android 上的 Codename One 中的 GeoFence 错误

问题描述 投票:0回答:1

你好,代号一队!

我已经实现了地理围栏功能。最近对 Codename One 的 Android 构建过程进行更改后,我遇到了一个专门针对 Android 设备的错误。在地理围栏区域内添加地理围栏时,应用程序会崩溃。 iOS 设备上不会出现此问题。

问题详情:

  • GeoFence 在 iOS 上完美运行。
  • 在 Android 上,如果我位于 GeoFence 位置之外,添加 GeoFence 不会出现问题。
  • 如果添加 GeoFence 时我位于 GeoFence 位置内,则应用程序会崩溃并显示一条消息:“此应用程序有错误。”
Geofence gf = new Geofence(fenceID, location, courtDiameter, -1);

try {
    LocationManager.getLocationManager().addGeoFencing(GeofenceWhoPlaysImpl.class, gf);
} catch (Exception eLoc) {
    UserInfo.setLogWP("Location! Add GeoFence error: " + eLoc.getMessage());
}

在 Android 上的 GeoFence 区域内添加 GeoFence 时,什么可能导致应用程序崩溃?如何调试并修复此问题,以便无论设备当前位置如何,地理围栏都能正常工作?

我非常感谢您提供的任何帮助。任何见解或建议将不胜感激!任何见解或建议将不胜感激!

最诚挚的问候, 奥斯卡

2024-05-19 16:03:46.903  4970-4970  HoneySpace...lderFRView com.sec.android.app.launcher         I  updateCurrentPageOnLayout page=0
2024-05-19 16:03:49.704  2259-4617  SLocation               system_server                        W  GeopointGeofenceManager - refresh wifi to receive loc
2024-05-19 16:03:49.704  2259-4617  SLocation               system_server                        D  GeopointGeofenceManager - Location reported : fix method = 4 / 20.637
2024-05-19 16:03:55.954  2259-4617  SLocation               system_server                        W  GeopointGeofenceManager - refresh wifi to receive loc
2024-05-19 16:03:55.954  2259-4617  SLocation               system_server                        D  GeopointGeofenceManager - Location reported : fix method = 4 / 19.136
2024-05-19 16:03:58.048  2259-4381  ActivityManager         system_server                        D  Received SERVICE intent 0xbc5f472 Key{startService pkg=com.google.android.gms/geofencer_provider intent=act=com.google.android.location.internal.action.GEOFENCER_AR_RESULT pkg=com.google.android.gms cmp=com.google.android.gms/com.google.android.location.internal.PendingIntentCallbackService flags=0x2000000 u=0} requestCode=0 from uid 10237
2024-05-19 16:04:12.491  2259-6340  ActivityManager         system_server                        D  Received BROADCAST intent 0x31dc032 Key{broadcastIntent pkg=com.whosplays.app intent=act=com.codename1.location.backgroundlocationbroadcastreceiver.action.ACTION_RECEIVE_GEOFENCE dat=http://codenameone.com/... cmp=com.whosplays.app/com.codename1.location.BackgroundLocationBroadcastReceiver flags=0x4000000 u=0} requestCode=0 sent=0 from uid 10237
--------- beginning of crash
2024-05-19 16:04:12.499  5954-5954  AndroidRuntime          pid-5954                             E  FATAL EXCEPTION: main
                                                                                                    Process: com.whosplays.app, PID: 5954
                                                                                                    java.lang.RuntimeException: Unable to start receiver com.codename1.location.BackgroundLocationBroadcastReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.location.GeofencingEvent.hasError()' on a null object reference
                                                                                                        at android.app.ActivityThread.handleReceiver(ActivityThread.java:4905)
                                                                                                        at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0)
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2498)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:230)
                                                                                                        at android.os.Looper.loop(Looper.java:319)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8919)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
                                                                                                    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.location.GeofencingEvent.hasError()' on a null object reference
                                                                                                        at com.codename1.location.BackgroundLocationBroadcastReceiver.onReceive(BackgroundLocationBroadcastReceiver.java:134)
                                                                                                        at android.app.ActivityThread.handleReceiver(ActivityThread.java:4896)
                                                                                                        at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0) 
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2498) 
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:106) 
                                                                                                        at android.os.Looper.loopOnce(Looper.java:230) 
                                                                                                        at android.os.Looper.loop(Looper.java:319) 
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8919) 
                                                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578) 
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) 
2024-05-19 16:04:17.511  2259-8082  ActivityManager         system_server                        D  Received BROADCAST intent 0x31dc032 Key{broadcastIntent pkg=com.whosplays.app intent=act=com.codename1.location.backgroundlocationbroadcastreceiver.action.ACTION_RECEIVE_GEOFENCE dat=http://codenameone.com/... cmp=com.whosplays.app/com.codename1.location.BackgroundLocationBroadcastReceiver flags=0x4000000 u=0} requestCode=0 sent=0 from uid 10237
2024-05-19 16:04:17.665  6293-6293  AndroidRuntime          pid-6293                             E  FATAL EXCEPTION: main
                                                                                                    Process: com.whosplays.app, PID: 6293
                                                                                                    java.lang.RuntimeException: Unable to start receiver com.codename1.location.BackgroundLocationBroadcastReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.location.GeofencingEvent.hasError()' on a null object reference
                                                                                                        at android.app.ActivityThread.handleReceiver(ActivityThread.java:4905)
                                                                                                        at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0)
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2498)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:230)
                                                                                                        at android.os.Looper.loop(Looper.java:319)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8919)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
                                                                                                    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.location.GeofencingEvent.hasError()' on a null object reference
                                                                                                        at com.codename1.location.BackgroundLocationBroadcastReceiver.onReceive(BackgroundLocationBroadcastReceiver.java:134)
                                                                                                        at android.app.ActivityThread.handleReceiver(ActivityThread.java:4896)
                                                                                                        at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0) 
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2498) 
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:106) 
                                                                                                        at android.os.Looper.loopOnce(Looper.java:230) 
                                                                                                        at android.os.Looper.loop(Looper.java:319) 
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8919) 
                                                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578) 
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) 
2024-05-19 16:04:21.043  2259-2259  InputMetho...gerService system_server                        W  DexOnPCStateChangeObserver :  onChange(), keyboardState - 0 state 1
2024-05-19 16:04:30.688  2259-4617  SLocation               system_server                        W  GeopointGeofenceManager - refresh wifi to receive loc
2024-05-19 16:04:30.689  2259-4617  SLocation               system_server                        D  GeopointGeofenceManager - Location reported : fix method = 4 / 18.31
2024-05-19 16:04:36.220  2259-8082  ActivityManager         system_server                        D  Received BROADCAST intent 0x31dc032 Key{broadcastIntent pkg=com.whosplays.app intent=act=com.codename1.location.backgroundlocationbroadcastreceiver.action.ACTION_RECEIVE_GEOFENCE dat=http://codenameone.com/... cmp=com.whosplays.app/com.codename1.location.BackgroundLocationBroadcastReceiver flags=0x4000000 u=0} requestCode=0 sent=0 from uid 10237
2024-05-19 16:04:36.227  6504-6504  AndroidRuntime          com.whosplays.app                    E  FATAL EXCEPTION: main
                                                                                                    Process: com.whosplays.app, PID: 6504
                                                                                                    java.lang.RuntimeException: Unable to start receiver com.codename1.location.BackgroundLocationBroadcastReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.location.GeofencingEvent.hasError()' on a null object reference
                                                                                                        at android.app.ActivityThread.handleReceiver(ActivityThread.java:4905)
                                                                                                        at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0)
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2498)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:230)
                                                                                                        at android.os.Looper.loop(Looper.java:319)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8919)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
                                                                                                    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.location.GeofencingEvent.hasError()' on a null object reference
                                                                                                        at com.codename1.location.BackgroundLocationBroadcastReceiver.onReceive(BackgroundLocationBroadcastReceiver.java:134)
                                                                                                        at android.app.ActivityThread.handleReceiver(ActivityThread.java:4896)
                                                                                                        at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0) 
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2498) 
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:106) 
                                                                                                        at android.os.Looper.loopOnce(Looper.java:230) 
                                                                                                        at android.os.Looper.loop(Looper.java:319) 
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8919) 
                                                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578) 
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

 

android codenameone android-geofence geofence
1个回答
0
投票

我做了以下修复,应该可以在 2024 年 5 月 24 日发布的版本上使用。但是,我不确定它是否能解决问题,因为堆栈中的行号不正确。

© www.soinside.com 2019 - 2024. All rights reserved.