Basic4android v2.00 is released!

Erel

B4X founder
Staff member
Licensed User
Longtime User
Basic4android v2.00 is now available. This upgrade is probably the most significant upgrade since v1.00.

The major new feature is support for class modules. With support for classes Basic4android now allows you to write both procedural code and object oriented code.
Object oriented code makes it easier to write and maintain large projects.

Basic4android v2.00 improvements:

- Classes

- Public and Private access modifiers

- Built-in documentation

- Better handling of tasks in the internal thread pool

- CallSubDelayed keywords - These keywords significantly simplify the interaction between services and activities.

- Building process improved and it now supports libraries with embedded resources (such as PayPal, Zooz, Samsung Pen and others).

- Bug fixes and other minor improvements.

Note that B4A.xml was modified in this version. The highlighting styles section was not modified.
The Reflection library was updated to support the new version internal changes.

V2.02 is now available. You should use the same link as the link to v2.00.
This version fixes several issues related to CallSub and CallSubDelayed keywords.
 

rayzrocket

Member
Licensed User
Longtime User
Ver1.70 is very code fault tolerant than Ver2.00

B4A Ver2.00, Bravo Erel!

This may help some of those struggling with debugging code after Ver2.00 update.

Ver1.7 sometimes(everytime in my cases) allows "CallSub" into paused activities.
2.0 will not tolerate this!, the app will run, but consistently break down, stop functioning, error, or crash the phone whenever a "CallSub" is made into a paused activity (this goes for both activities and service modules). It is very hard to debug via app runtime.
 
Upvote 0

kanaida

Active Member
Licensed User
Longtime User
Thanks guys!! I can't wait to try this tonight! can't believe I missed the original email and didn't see it till today :)

Writing stuff without classes felt like I was a pirate with a wooden leg and a missing eye lol It's not that you can't win a fight, but... it's just easier if you're a ninja with all your limbs and 2 swords :)
 
Upvote 0

PeakW

Member
Licensed User
Longtime User
For 2.0 was wrong

I was running the program normal, B4A upgraded to 2.0, appear below error, please advise :sign0085:
java.lang.NoSuchFieldError: anywheresoftware.b4a.BA.activityBA
at anywheresoftware.b4a.agraham.reflection.Reflection.GetActivity(Reflection.java:638)
at Sw.Tel.main._setshowwhenlocked(main.java:2589)
at Sw.Tel.main._activity_create(main.java:357)
at java.lang.reflect.Method.invokeNative(Native Method)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
About the CallSub issue. There is a bug in v2.00 where CallSub fails instead of doing nothing when the activity is paused. Previously it just did nothing. This is fixed in the next update which will soon be available. Note that it is much better to use CallSubDelayed when interacting with other modules.

@PeakW, you should download the latest Reflection library. It fixes this issue (see the first post here).
 
Upvote 0

trisium

Member
Licensed User
Longtime User
problems with existing projects after installing v2.00

After installing version 2.0 (updating version 1.9) I get problems with my existing projects (working fine on version 1.9).

Opening an project produces this message:

"An error occured.
Der Verzeichnisname ist ungültig."

I think this happens in the context with Java??? Compiling the project results in this message:

"Compiling code. 0.77
Compiling layouts code. 0.06
Generating R file. 0.02
Compiling generated Java code. Error
Der Verzeichnisname ist ungültig"

I use no additional libraries and I have no idea, which folder name is meant...

Reinstalling 1.9 solves the problems...

What could be the solution?
:sign0085:
Thanks!
 
Upvote 0

trisium

Member
Licensed User
Longtime User
Look in IDE menu Tools / Configure Paths and check that there are no spaces nor any other special character in the file names.

Best regards.

Thanks a lot Klaus,

but I see no problems at this place - the paths are:

D:\Java\jdk1.7.0\bin\javac.exe
D:\Android\android-sdk\platforms\android-14\android.jar

Both paths/files exist - and work fine with version 1.9.

I would be happy about other hints!!!
 
Upvote 0

trisium

Member
Licensed User
Longtime User
You could try perhaps menu Tools / Clean Project
Not sure if this will solve the problem.

Best regards.

Thanks again, Klaus,

unfortunately without effect :-(

The error occurs while "generating R file" - perhaps knowing more about this part of compiling procedure would help, but I'm not familiar with this... Additionally the message appears in German...

Any other ideas?

Best regards.
 
Upvote 0

kanaida

Active Member
Licensed User
Longtime User
Timers in classes

Hey Erel, just tried creating a simple project.

It's mostly just one class 'Car'.

It's got a timer inside, when the Car.StartEngine() is run, it changes the color of it's internal view every second. (it's just a box right now lol) I put the timer in there just to see if it could animate independently of what my activity was doing, so by changing an interval or variable like speed, the wheels would animate faster or slower. I got a nasty log message after the first tick though...

B4X:
[Common.java:153:Log()] ** Activity (main) Create, isFirst = true **
[Common.java:153:Log()] Mitsubishi
[Common.java:153:Log()] Eclipse
[Common.java:153:Log()] Engine started!!!
[Common.java:153:Log()] 0,0
[Common.java:153:Log()] ** Activity (main) Resume **
[BA.java:93:uncaughtException()] java.lang.NullPointerException
   at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:102)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:130)
   at android.app.ActivityThread.main(ActivityThread.java:3694)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:895)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:653)
   at dalvik.system.NativeStart.main(Native Method)
[Common.java:153:Log()] ** Activity (main) Resume **


Car Class:
B4X:
'Class module
Sub Class_Globals
Dim Make As String
Dim Model As String
Dim Position As pos : Position.Initialize(0,0)
Dim V As ImageView : V.Initialize("v") : V.Color = Colors.Red
Dim t As Timer 
Dim Frame As Int : Frame = 0
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(Make_ As String, Model_ As String)
   Make = Make_
   Model = Model_
End Sub

Public Sub StartEngine
   Log("Engine started!!!")
   Log(Position.x & "," & Position.y)
   t.Interval = 1000
   t.Enabled = True
End Sub

Public Sub v_ItemClick()
   Log("View Clicked!")
End Sub

Public Sub t_Tick
   If Frame > 3 Then
      Frame = 0
   End If
   
   Select Case Frame
   Case 0
      V.Color = Colors.green
   Case 1
      V.Color = Colors.yellow
   Case 2
      V.Color = Colors.Magenta
   Case 3
      V.Color = Colors.White
   End Select
End Sub

Pos (position) class:
B4X:
'Class module
Sub Class_Globals
   Dim x As Int
   Dim y As Int
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(x_ As Int,y_ As Int)
x = x_
y = y_
End Sub

Main:
B4X:
Dim c As Car : c.Initialize("Mitsubishi","Eclipse")
Log(c.Make)
Log(c.Model)
c.StartEngine
Activity.AddView(c.V,0,0,64,64)
 
Upvote 0

kanaida

Active Member
Licensed User
Longtime User
Nevermind..

My fault. :) forgot to initialize the timer first. It threw me off because the event looked as if it fired from looking at the log.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
Is there or is it in the works, a version above B4A 2.0? I have seen some comments and don't remember where that an update to 2.0 is coming that will fix some issues with HttpUtils. Is this correct?

I can't remember which thread it was in, but I think Erel mentioned 2.01 (to be considered a BETA) that is available at the previous download link provided when 2.0 came out. I think he also mentioned that 2.02(?) would be released soon.

Edit: See my other post here.
 
Last edited:
Upvote 0

eps

Expert
Licensed User
Longtime User
Tip top!

Have made the jump, but will look out for 2.0.2! :)

After an initial quick trial last night it seems good. The compiler checking is a little tighter, which is always a good thing!

:)
 
Upvote 0

newSteve

Member
Licensed User
Longtime User
Same situation

I finally upgraded to 2.0, tried my existing working project, and got the same thing. Did you ever get an answer?



Just downloaded and now find all my apps, have the following problem when I compile.

B4X:
Compiling code.                         0.48
Compiling layouts code.                 0.02
Generating R file.                      0.00
Compiling generated Java code.          Error
javac 1.6.0_29
src\anywheresoftware\b4a\popping\main.java:54: cannot find symbol
symbol  : variable sharedProcessBA
location: class anywheresoftware.b4a.BA
        processBA.sharedProcessBA.activityBA = null;
                 ^
1 error
 
Upvote 0
Top