Search results for

All search results
Best daily deals

Affiliate links on Android Authority may earn us a commission. Learn more.

An introduction to Basic4Android - a simple tool for building powerful Android apps

Basic4Android is a lesser-known IDE for Android development that can help make writing apps quicker and easier. This post takes a look at the platform, its pros and cons and how to get started with it.
By

Published onMarch 10, 2016

20160306_175116

The key to getting lots done is to make sure you have the right tools for the job. And when it comes to mobile development, that means choosing the right IDE for the particular app you want to make. Android Studio is great if you want to create something in-keeping with the Android aesthetic, or if you want to go the most common route to ensure maximum support. Unity is perfect for making 3D games without having to hire an entire team of developers.

And to me, Basic4Android is one of the very best options for when you want to make an Android app quickly. I also think it’s a rather good tool for beginners and for creating cross-platform applications; so it’s a shame that a lot of people don’t know about it. Let’s take a closer look…

What is Basic4Android?

Before we go any further, note that Basic4Android is not a free piece of software. If you’re not interested in paid IDEs then you may want to look elsewhere. It’s very reasonable for what you get though – we’re talking a one-off $59 payment for the most basic package. There’s also a free trial on the website (www.b4x.com) and placing an order will also gain you access to the forum (which is filled with very helpful people).

Basic4Android is an IDE (integrated development environment) and ‘RAD’ tool (rapid application development). As that title suggests, the aim is to facilitate the fast and easy creation of apps. At the same time, it tries to do this without limiting you in any way as far as what your programs are capable of.

b4a empty

Basic4Android was created by Anywhere Software, which as far as I can tell is a one-man-show run by Erel Uziel. He explained to me in his own words what Basic4Android is all about:

“The first benefit is that B4A is a RAD (Rapid Application Development) tool. Our task is to allow developers with any skill level to quickly develop real world applications.
“You don’t need to learn too much to start. The IDE and framework will do their best to help you with getting your job done.
“Unlike many ‘wizards’, B4A is a tool for developers. It doesn’t limit you in any way. With the vast range of libraries your app can do everything that Android is capable of.”

That is to say, that this is not an ‘app builder’ aimed at people who don’t want to do any coding. You will have to code but it’s more accessible for beginners and there are a lot of neat features to make the process simpler. And you aren’t limited in any way as to what you can create.

There are scenarios where Basic4Android won’t be the best choice for your project. Like I said at the start, choosing the right tool for the job is part of the challenge. But as someone who can use multiple IDEs, I still find myself coming back to B4A for a number of different tasks thanks to how simple and straightforward it is.

Introducing BASIC

basic

Partly, this accessibility is achieved through the use of BASIC over Java. BASIC stands for ‘Beginners’ All Purpose Symbolic Instruction Code’ and is one of the first programming languages that many new coders will learn owing to its relative simplicity. That includes yours truly; I learned to program on a ZX Spectrum (and a Tatung Einstein!) and then carried this over to QBasic on my old 486 laptop.

Who remembers these? Oh, that's right, no one...
Who remembers these? Oh, that’s right, no one…

If you’re new to programming, you may find that BASIC is a little easier to pick up than Java. To look at, BASIC often reads a lot more like plain English and this is one feature that makes it so user-friendly.

To demonstrate, compare these two lines of code that do the same thing:

Code
IF level = 3 THEN titlebar.Text = "level 3"

VS

Code
if (level == 3){
    titlebar.setText("level 3");
}

The former is just a lot more intuitive than the latter and easier to understand intuitively if you’re new. (And there are no semi-colons to forget about!) Java is also much more object oriented than Basic4Android. This may be seen as a benefit by some and is useful for bigger projects. For a beginner though, it requires a little more work to get your head around.

b4a full

What’s more though, Basic4Android handles a lot of things behind the scenes for you. For instance, if that second line of code was going to work in Java/Android Studio, then you would also need to ‘import’ the relevant class. Likewise, creating global variables is much easier, so is writing strings, so is setting timers, using custom fonts…

In both cases, you would need to initialize the widget you were referencing but Basic4Android makes it much easier for you to do that just the once and then forget about it. Even setting up Basic4Android is considerably easier than setting up Android Studio, with far fewer steps (as you’ll see in a moment). The same goes for debugging and testing. You can use B4A Bridge (a free mobile app) to test apps on your device over Bluetooth and then debug them as they’re running. Pretty smart.

Can Basic4Android do everything you need?

The question that a lot of people are likely to ask is: ‘can you really do anything in Basic4Android that you can do in Android Studio?’. The answer to this, on the whole, is yes.

Basic4Android allows any user to create and share their own libraries which are written in Java. Any code you can use with Android Studio, you can wrap into a library for B4A. And if you can’t, there’s probably someone on the forum who will do it for you.

People have made 3D games in Basic4Android and I’ve created a homescreen launcher. That homescreen launcher, by the way, is something that would have taken me much longer to create had I gone a more traditional route. The same goes for several of my other apps – some of which have been quite successful.

arkanoid-16x9
Just because it’s BASIC, your apps don’t all have to look like Arkanoid…

There’s no performance penalty as far as I can tell either – if it’s there, then it’s negligible and won’t be an issue for the vast majority of use cases. If you’re trying to squeeze every last bit of performance out of Android, you might want to dig a little deeper. Chances are you wouldn’t use B4A for that kind of project any way though. You can see showcases of some apps created with Basic4Android here. There’s also a ‘100k+ downloads club’.

There are more unique advantages of Basic4Android too. One is that it is part of a ‘B4x’ suite of tools, along with ‘B4J’ (Basic4Java) and ‘B4i’ (I’ll let you guess what that one is…).

“You can use B4J to easily implement the back-end and you can use B4i to develop the same solution for iOS. You can share [over] 80% of the code between the different platforms.”

In other words, because the syntax is largely the same for Basic4Android, Basic4Java and Basic4iOS, you can create a simple app on the PC and then swap out some libraries and platform-specific features in order to port it to both Android and iPhone.

You can also use B4J (which is free) to make simple little desktop apps for your own purposes, or to create apps that need to communicate with the computer (such as media controllers).

In the future, Erel plans to bring his platform to the ‘Internet Of Things’:

“The focus in the near future is on the Internet Of Things. It starts with connectivity features such as MQTT, web sockets, XBee and more.”

 

Is Basic4Android right for you?

If I’ve come across as overly praising, then I apologize. Ultimately though, that’s because I honestly rate this software highly and think I owe a fair amount of my success on Android to it.

To me, it just makes more business sense to take the ‘path of least resistance’. Why spend years developing something if there are tools out there to help you do it in months? Don’t let ego get in the way of downloads!

That said though, there are scenarios where I wouldn’t use Basic4Android and it’s certainly not perfect for everyone.

One downside is that B4A isn’t the ‘industry standard’. This isn’t a problem if you’re creating an app for yourself but if you ever hope to sell your creation to Google or an investor for $$$, then you might find this is something of an obstacle. Likewise, there is more support for Android Studio. The support for B4A is fantastic (Erel answers most queries on the forum in person) but the simple fact of the matter is that there are many more people using Android Studio and that means there are many more code snippets, tutorials and experts available to answer your questions.

#FirstWorldProblems
#FirstWorldProblems

Likewise, if you’re hoping to become a professional developer, then you should at least know how to create apps the conventional way. You’ll find it hard to get a job if all you know is Basic4Android. But on the other hand, B4A does offer a useful ‘gateway’ that can make understanding Android Studio easier. You’ll have to relearn the syntax and introduce yourself to some new concepts but you’ll find yourself saying things like ‘ah, so that’s the equivalent of that!’.

Finally, I find that creating apps in Android Studio better facilitates doing things ‘properly’ and making sure your creations look like they belong in the Android ecosystem. Things like color schemes are a little easier to implement in AS and the designer is a lot more polished. I find that when I create something in Android Studio, it all stays a lot more organized and structured. This is partly due to the more rigid IDE and partly due to the nature of object oriented programming vs procedural programming. Perhaps you’re a little more organized than I am though and this won’t be a problem for you…

B4A does offer a useful ‘gateway’ that can make understanding Android Studio easier.

Oh and Android Studio also looks a lot more professional and has a bit more polish generally when compared with B4A. That’s to be expected what with B4A being made by just one guy…

For me, when choosing the right IDE, the breakdown looks like this:

  • Relatively simple app that I want to look great and feel ‘Androidy’ (i.e. something like a note taking app, crossword or business app) – Android Studio
  • More challenging app with lots of dynamic elements and things I’m not sure how I’m going to do yet OR an app that would take too long to build in AS/I want to build quickly – Basic4Android
  • Computer game with graphical elements (platformer, 3D shooter etc.) – Unity3D

There are more options for each of these scenarios too of course, it’s just a matter of finding a set-up that works for you.

My preferred set-up. Staged? How dare you!
My preferred set-up. Staged? How dare you!

For beginners, I would probably recommend trying to go the Android Studio/Java route if you want to become a professional developer. If you struggle with that though, maybe try B4A first to ease yourself in. Alternatively, if you’re someone who just has a great idea that you want to implement quickly for your own ends, then B4A is a great way to minimize your frustration (though you’ll need to be willing to part with a bit of cash up front).

Ultimately, it’s up to you. I honestly do not mind. So go crazy.

Just consider B4A as an option – as it often gets missed out when people are listing IDEs and it’s super good.

Getting started

That’s my two cents on Basic4Android and at this point you’ve probably made your mind up one way or another as to whether it’s for you.

But if you have decided that you do want to go ahead, then you can follow these tips to get set-up:

#1 Install the Java JDK

That would be the ‘Java Development Kit’. You’ll need it for any kind of Android coding. You can get this from here.

#2 Download the Android SDK

This is the Android ‘Software Development Kit’ and is what allows B4A to access the features of Android/package your apps as an APK.

#3 Install the Necessary Android Elements

Now you need to install the necessary parts of the SDK. You need the platform tools, build-tools and a recent platform image. This is again something you need to do whether you’re using Android Studio, Eclipse, Basic4Android or anything else. You’ll do this by running the Android SDK Manager and then ticking the options you want to install. Choose a recent version of Android and then tick the boxes next to those parts and click ‘install’.

sdk manager-16x9-720p

#4 Download and Install Basic4Android

It’s pretty simple and straightforward to go through the installation process, so just follow the instructions.

#5 Configure B4A

Finally, you need to tell B4A where to find the JDK and Android SDK. Navigate to Tools > Configure Paths. Then go just locate the paths for ‘javac.exe’ and ‘android.jar’.

b4a configure paths

And that’s it! B4A is now ready for you to start playing around with…

“Hello World” in Basic4Android

Let’s end with a nice simple ‘Hello World’ in Basic4Android. Click ‘new’ and then save your project somewhere you’ll be able to find it again.

To start with, we’re going to create a label. We could do that using the designer but I actually prefer to handle everything programmatically when I’m coding in B4A. It’s quick and easy and it helps you to keep everything responsive.

First we define our label in ‘Globals’. Just add the line:

Code
Sub Globals
Dim label1 As Label
End Sub

To that sub (a sub is like a method). Now you’ll be able to reference ‘label1’ from anywhere in the code.

‘Activity_Create’ is the sub that runs first when the activity is launched. In here then, we’re going to ‘initialize’ label1 and say what we want it to look like. Use this code:

Code
label1.Initialize("Label1")
Activity.AddView(label1, 0%x, 0%y, 100%x, 100%y)

We’ve that way created the label and then added it to the activity (the part of the app that’s running) while also setting its location and size. The location is ‘0%x, 0%y’ meaning that it’s in the top left corner of the screen. The width and height are ‘0%x, 0%y’ meaning that it will take up 100% of the width and 100% of the height. Our label is now the exact same size as the screen, though it’s invisible. Because we’re using percentages, the size of the label will change to match the size of the display it’s running on.

These lines will add our hello message and ensure it floats in the center of the label:

Code
label1.Gravity = Gravity.CENTER
label1.Text = "Hello World!"

We could also add:

Code
label1.Color = Colors.White
label1.TextColor = Colors.black
label1.TextSize = 40

Just to make it a little prettier.

That’s the ‘hello world’ done with but to make things more interactive we can create another sub:

Code
Sub label1_click ()
label1.Text = "Bye bye!"
End Sub

If you did it right, it will look something like this. Or exactly like this:

b4a hello world

Now the app says ‘Bye bye!’ when you click anywhere on the screen. You could just as easily get it to do anything else you liked by putting different bits of code in here.

Screenshot_2016-03-08-11-56-40

Closing comments

So this was a very simple app but even here you can get a taste of how quick and easy development is using Basic4Android. Using little more than those few lines of code, you could potentially create a quiz, an informational app or even a basic game (you can change the position of labels by using ‘Label1.setLayout’).

It’s not going to be the best tool for the job in every single situation but for a surprisingly large number of use-case scenarios, it can be the quickest way to get that app up and running. That means you can spend less time browsing forums to find out while your creation won’t compile and more time iterating and having fun.

I like it anyway…

You might like