Android Question Error when compiling generated java code

Milton FS Santos

New Member
Licensed User
Hello everyone,
I'm having a issue when I try compile and run my program. He was working before some changes, but I can't find the problem and don't find any similar thread here.
Apparently the function is receiving more arguments than should receive, but I don't know why either how fix it.
Here is my compiling error:
B4X:
B4A Version: 9.01.2
Java Version: 11
Parsing code.    (0.00s)
Building folders structure.    (0.03s)
Compiling code.    (0.05s)
Compiling layouts code.    (0.01s)
Organizing libraries.    (0.00s)
Generating R file.    (0.00s)
Compiling debugger engine code.    (0.00s)
Compiling generated Java code.    Error
src\b4a\example\conexao.java:349: error: method shouldDelegate in class Debug cannot be applied to given types;
if (Debug.shouldDelegate(mostCurrent.activityBA, "activity_create", false))
         ^
  required: BA,String
  found: BA,String,boolean
  reason: actual and formal argument lists differ in length
Note: src\b4a\example\starter.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

javac 11.0.1

And here my Main:
B4X:
 #Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private btnEnter As Button
    Private password As EditText
    Private username As EditText
    Private ListViewconfig As ListView
    Private btnwifi As Button
    Private Btnback As Button
    Private Lblconfig As Label
    Private Lblcamera As Label
    Private Lbldaninha As Label
    Private Lblmap As Label
    Private Lbltractor As Label
    Private Lbldata As Label
    Private Lblfalha As Label
    Dim bmpWifiOn, bmpWifiOff As BitmapDrawable
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("login")
    bmpWifiOn.Initialize(LoadBitmap(File.DirAssets, "icons8-wi-fi-green.png"))
    bmpWifiOff.Initialize(LoadBitmap(File.DirAssets, "icons8-wi-fi-red.png"))
End Sub

Sub Activity_Resume
    If conexao.Socket1.Connected Then
        btnwifi.Background = bmpWifiOn
    Else
        btnwifi.Background = bmpWifiOff
    End If
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub password_EnterPressed
    btnEnter_Click
End Sub

Sub btnEnter_Click
    If username.Text.Trim="" Or password.Text.Trim="" Then
        MsgboxAsync("Por favor, preencha usuário e senha","")
    Else If username.Text="admin" And password.Text="admin" Then
        Activity.RemoveAllViews
        Activity.LoadLayout("main")
    End If
End Sub

Sub ListViewconfig_ItemLongClick (Position As Int, Value As Object)
    
End Sub

Sub Lblwifi_Click
    Activity.RemoveAllViews
    Activity.LoadLayout("conexao")
End Sub

Sub Lbltractor_Click
    MsgboxAsync("","Trator Status")
End Sub

Sub Lblmap_Click
    Activity.RemoveAllViews
    Activity.LoadLayout("mapa")
End Sub

Sub Lblfalha_Click
    
End Sub

Sub Lbldata_Click
    
End Sub

Sub Lbldaninha_Click
    
End Sub

Sub Lblconfig_Click
    Activity.RemoveAllViews
    Activity.LoadLayout("config")
End Sub

Sub Lblcamera_Click
    MsgboxAsync("","Camera Status")
End Sub

Sub btnwifi_Click
    Activity.RemoveAllViews
    Activity.LoadLayout("conexao")
End Sub

Sub btntractor_Click
    MsgboxAsync("","Trator Status")
End Sub

Sub btnmap_Click
    Activity.RemoveAllViews
    Activity.LoadLayout("mapa")
End Sub

Sub btnfalha_Click
    
End Sub

Sub Btndata_Click
    
End Sub

Sub btndaninha_Click
    
End Sub

Sub btnconfig_Click
    Activity.RemoveAllViews
    Activity.LoadLayout("config")
End Sub

Sub btncamera_Click
    MsgboxAsync("","Camera Status")
End Sub

Sub Btnback_Click
    Activity.RemoveAllViews
    Activity.LoadLayout("main")
End Sub

Sub LblLogout_Click
    Activity.RemoveAllViews
    Activity.LoadLayout("login")
End Sub
 

agraham

Expert
Licensed User
Longtime User
This is a very strange error. I can't think of anything that could cause it. The Debug.shouldDelegate(BA, String, boolean) method is in the standard library, Debug.jar, and should take indeed take three parameters.

Try compiling a new empty project to see if the error is still present. It it is then I would uninstall and reinstall B4A.
 
Upvote 0

Milton FS Santos

New Member
Licensed User
I fixed that bug deleting a inactive module. I did not call this module in any part and the project was compiled before even with this part, but now gave error. o_O
B4X:
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=StaticCode
Version=9.01
@EndOfDesignText@
Type=StaticCode
'Code module
'Subs in this code module will be accessible from all modules.
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    
End Sub

Sub  LoadData  As List
    Dim dataArr As List
    dataArr.Initialize
    If File.Exists(File.DirInternal,"data") Then
        Return File.ReadList(File.DirInternal,"data")
    End If
 
    Return dataArr
End Sub


Sub SaveData(Arr As List)
    File.WriteList(File.DirInternal,"data",Arr)
End Sub

Sub AddData(Data As Map)
    Dim dataArr  As List = LoadData
    Dim json As JSONGenerator
    json.Initialize(Data)
    dataArr.Add(json.ToString)
    SaveData(dataArr)
End Sub
 
Upvote 0
Top