Android Question Error on compile, not clear what is the issue from what is shown?

anasazi

Member
I am trying to build an android app and had a compile ok shell of the basics. Now I'm adding example
code for a xchartlite which works and the BLE2 scan/connect demo example project. This is where I
got into confusion/trouble bringing in the BLE2 stuff. I think it's close but this error is halting going
forward right now:

Here is the build dialog output at the Linking and Debugger engine code point as it shows:
Linking resources (0.32s)
Compiling debugger engine code. Error
B4A line: 27
End Sub
shell\src\FW6APP\v10\main_subs_0.java:145: error: method _process_globals in class b4xmainpage_subs_0 cannot be applied to given types;
b4xmainpage_subs_0._process_globals();
^
required: RemoteObject
found: no arguments
reason: actual and formal argument lists differ in length
1 error

And the code file (main) it brings up for line 27 is this (an excerpt):
( Note: "main" appears to be inside of file FW6_App.b4a )

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

'#BridgeLogger: True

Sub Process_Globals
' Public ActionBarHomeClicked As Boolean
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
' Type Device(Name As String, Id As String)
' Type Characteristic(ServiceId As String, CharacteristicId, Value As String)
End Sub

Sub Globals

End Sub <=== edit note, this is line 27 in the source

Sub Activity_Create(FirstTime As Boolean)
Dim pm As B4XPagesManager
pm.Initialize(Activity)
End Sub

I can wrap this all up in a zip file and send to someone who can parse out what
I have either not done or done wrong that might cause this hang up.

Thanks in advance, cheers!
 
Last edited:

PaulMeuris

Active Member
Licensed User
' Type Characteristic(ServiceId As String, CharacteristicId, Value As String)
This type declaration is missing a type definition for Characteristicid. But you put in a comment line. Was the line commented out when the error occured?
You can use the code button (the first one) to post any B4X code.
Maybe its best to send a zip-file so we can check the library settings and such.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
It seems that you are using a B4XPages project.
1. Uncomment this line in the Main module in Sub Process_Globals, it is part of the B4XPages default code.
Public ActionBarHomeClicked As Boolean
2. You should not add any code in the Main module.
You should declare the variables in the Class_Globals in the B4xMainPage module.

Or as already suggested post your project.
 
Upvote 0

anasazi

Member
You can use the code button (the first one) to post any B4X code.
Maybe its best to send a zip-file so we can check the library settings and such.
 

Attachments

  • FW6_App.zip
    453.8 KB · Views: 80
  • Screenshot 2022-08-08 085643.png
    Screenshot 2022-08-08 085643.png
    115.4 KB · Views: 86
  • Screenshot 2022-08-08 085826.png
    Screenshot 2022-08-08 085826.png
    139.8 KB · Views: 84
Upvote 0

anasazi

Member
It seems that you are using a B4XPages project.
1. Uncomment this line in the Main module in Sub Process_Globals, it is part of the B4XPages default code.
Public ActionBarHomeClicked As Boolean
2. You should not add any code in the Main module.
You should declare the variables in the Class_Globals in the B4xMainPage module.

Or as already suggested post your project.
Hi, I zip'd up the project and uploaded. Also two screen shots, one showing all the libraries, the other
showing the compile error halt dialog box, pointing to line 27 in the 'main' file. Would this be easier if
I didn't use a "pages" project? I do have to run this on iPhones and Androids eventually, so will be buying
the "B4I" version to do this, etc...
Thanks, Marc
 
Upvote 0

anasazi

Member
Forgot to mention my B4X is the latest version 11.80 on Windoze 10.
This is my first use of B4X and it is a great tool. Keeps me out of the Android SDK.
Still learning how to organize a program with it. Some confusion on the various
'globals' declarations and using several source files vs. 'all in one file' approach.
Cheers
 
Upvote 0

PaulMeuris

Active Member
Licensed User
The Main tab page of the IDE contains contains the correct subroutines Process_Globals and Globals.
In most cases you shouldn't put any code in there. The comment at the bottom of the page says:
'Program code should go into B4XMainPage and other pages.
The B4XMainPage contains only the subroutine Class_Globals. The subroutine titles (Process_Globals, Globals) do not belong in this page.
Remove them and make sure you have in the Library Manager pane the xChartLite library checked.
Then you should be good to compile without an error.
chart.png
 
Upvote 0

anasazi

Member
Message # 7 ???
That was the issue. Removed Process_Globals and Globals and it compiles and runs now.
In merging code from the two example demo's I pulled in (or am trying to at least) It wasn't
clear to me where their Process_Globals and Globals would go in the B4XMainPage file. So
I just left those there but had no clue they wrere causing the compile error since the error
statement pointed to the 'main' source file like it was doing. I guess it was saying there are
two or more declarations for Process_Globals and Globals subs.
Thanks again, I have to merge more from yesterday's edits to an older version.
Cheers
 
Upvote 0

anasazi

Member
Maybe you overlooked it, on thread #4...
I did miss that, I saw it but along with all the other stuff that's in the template I didn't
at the time know what that would do. So I used an external zip'er for the project. It
initially made to big of a file and I had to pare down, but this link you point out only
takes what is needed to xfer. the project to another user and is smaller/cleaner.
Thanks for the tip!
 
Upvote 0

anasazi

Member
You have the following Subs in your B4XMainPage class. Classes do not support these Subs. Remove them and it compiles OK.
B4XMainPage:
Sub Process_Globals

End Sub

Sub Globals

End Sub
Spot on tip! Being a newbie to B4X it isn't /wasn't clear to me where various things should go. and pulling in
source code from two other examples that were not "pages" type projects I just dumped those two Subs
in my combined header, merging them. But I guess that conflicts with similar Sub's in main .
Old at programming (C,C++) new to B4X, don't know what I don't know, yet! Glad this one was easy for the
more experienced out there to spot and repair...
Regards!
 
Upvote 0

anasazi

Member
Final follow up, like any 'new language' one is to pick up and use like this learning the structure
of things is where most frustration occurs for me. After trying to make this work and getting help
from the community I decided to re-watch most of the pertinent Erel "Teaches Progamming" videos
and they make a lot more sense now. Just like reading a manual front to back with out actually trying
anything at the computer, it goes in the eyes and out the ears. I should be good to go now!
Thanks all!
Marc
 
Upvote 0
Top