Android Question java.lang.NoSuchFieldException:

D

Deleted member 103

Guest
Hi,

the sub "GPS1_GpsStatus" in the starter service produces a crash, what could be the trigger?
java.lang.NoSuchFieldException:
at java.lang.Class.getField (Class.java:1104)
at anywheresoftware.b4a.keywords.Common.getComponentBA (Common.java:1176)
at anywheresoftware.b4a.keywords.Common.IsPaused (Common.java:1161)
at fg.cronomillemiglia_pro.starter._gps1_gpsstatus (starter.java:314)
at java.lang.reflect.Method.invoke (Native Method)
at java.lang.reflect.Method.invoke (Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:186)
at anywheresoftware.b4a.BA.raiseEvent (BA.java:166)
at anywheresoftware.b4a.gps.GPS$2.onGpsStatusChanged (GPS.java:99)
at android.location.LocationManager$GpsStatusListenerTransport$1.handleMessage (LocationManager.java:1527)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:145)
at android.app.ActivityThread.main (ActivityThread.java:6134)
at java.lang.reflect.Method.invoke (Native Method)
at java.lang.reflect.Method.invoke (Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1194)

starter.java:314:
B4X:
 //BA.debugLineNum = 338;BA.debugLine="If Not(IsPaused(Main)) Then";
if (anywheresoftware.b4a.keywords.Common.Not(anywheresoftware.b4a.keywords.Common.IsPaused(processBA,(Object)(mostCurrent._vvvvvvvvvvvvvvvvvvvvvvvvvv3.getObject())))) {
 //BA.debugLineNum = 339;BA.debugLine="CallSub2(Main, \"ShowGpsStatus\", Set)";
anywheresoftware.b4a.keywords.Common.CallSubNew2(processBA,(Object)(mostCurrent._vvvvvvvvvvvvvvvvvvvvvvvvvv3.getObject()),"ShowGpsStatus",(Object)(_set));
 }else if(anywheresoftware.b4a.keywords.Common.Not(anywheresoftware.b4a.keywords.Common.IsPaused(processBA,(Object)(mostCurrent._vvvvvvvvvvvvvvvvvvvvvvvvvvv3.getObject())))) {
 //BA.debugLineNum = 342;BA.debugLine="CallSub2(mSatellites, \"GpsStatus\", Satellites)";
anywheresoftware.b4a.keywords.Common.CallSubNew2(processBA,(Object)(mostCurrent._vvvvvvvvvvvvvvvvvvvvvvvvvvv3.getObject()),"GpsStatus",(Object)(_satellites));
 };


Starter:
B4X:
Sub GPS1_GpsStatus (Satellites As List)
    Dim Set As Int = 0
    If manager.GetString("lstClockSynchModus") = "GPS" Then
        For i = 0 To Satellites.Size -1
            Dim GPSSat As GPSSatellite
            GPSSat = Satellites.Get(i)       
            If GPSSat.UsedInFix Then Set = Set + 1
        Next
        
        If Not(IsPaused(Main)) Then
            CallSub2(Main, "ShowGpsStatus", Set)
        
        else if Not(IsPaused(mSatellites)) Then
            CallSub2(mSatellites, "GpsStatus", Satellites)
            
        End If
    End If
End Sub

Main:
B4X:
Public Sub ShowGpsStatus (Satellites As Int)
    If Starter.manager.GetString("lstClockSynchModus") = "GPS" Then
        imgGPSStatus.Visible = True
        If Satellites < 3 Then
            imgGPSStatus.Bitmap=LoadBitmap(File.DirAssets,"stat_sys_gps_off.png")
        Else if Satellites < 7 Then
            imgGPSStatus.Bitmap=LoadBitmap(File.DirAssets,"stat_sys_gps_on-50.png")
        Else
            imgGPSStatus.Bitmap=LoadBitmap(File.DirAssets,"stat_sys_gps_on-100.png")
        End If
        '        Log("ShowGpsStatus")
    End If
End Sub
 
D

Deleted member 103

Guest
Never load an image file more than once. Load them when your program starts in Service_Create.
Thanks, that's a good tip. :)

It doesn't look that your code was compiled with the latest version of B4A. Did you make an update to your app with B4A v8?
I compiled it with version 7.81, because version 8.0 did not exist at that time. :(
 
Upvote 0
Top