This Backendless tutorial demonstrates how to set up a development environment for building a powerful Android mobile application with Backendless Platform.
In this tutorial we will learn how to configure an Android Development environment . The video below demonstrates the following issues:
- How to retrieve a project (an app) from its github repository.
- How to run the application emulator.
- How to create a Backendless account.
- How to import application data to your backend in Backendless.
- How to configure the project properly to use your backend successfully.
Beneath the video on this page you can find a premise step-by-step guide with screenshots which describes the configuration of Backendless Android development environment in details.
Backendless first Android tutorial shows how to set up a development environment for building an Android application with Backendless. In our case we’ll be working on the Restaurant-to-Go app – a sample app which we’ve built for our Android tutorials to review the process of building an app using Backendless Platform as well as various Backendless APIs.
You will need for your Backendless development environment the following:
- An installation of Android studio.
- A Backendless account.
Android studio is very easy to obtain:
- Google “Android studio”.
- Follow the “Download Android Studio” link.
- Follow the instructions to install Android Studio. Once you obtain Android studio, the next step is to check the Restaurant-to-go app from Version Control system. Restaurant-to-Go is checked into our Backendless github repository (https://github.com/Backendless/RestaurantToGo).
Select GIT from drop-down menu and enter the address of the Restaurant-to-go repository.To find the address of repository:
- In the Parent directory there must be the a folder that will contain your project – locator folder on your hard drive that will be containing the Restaurant-to-Go application. Click “Clone” after checking the boxes are completed properly.
- Click “Yes” when prompted to open the project.
- Now you’re done – your project is fully available in Android Studio.
- Before you go any further you should verify that you can actually run the application and everything is working as expected out of the box.To do this in Android Studio there is a drop-down that shows a list of debug configurations. From here you should select “order_success”.
- The entire project is split into modules and the “order_success” is the final one which includes all the functionality of this application. The reason we are selecting it now is just to make sure that we can run the entire app. Right next to this configuration there is a play button.Click it.
- You will see that the Android studio is building a project. You will be prompted to launch a project in an emulator. If you have an Android device you can chose that as well. If not – chose the “Launch in emulator” option like you see in the screenshot below.
- The emulator is now running. We can unlock it and then the application is launched. This is the very first screen of your app.
- We do not recommend to do anything with the app at this stage for the reason that out of the box it is configured to work with backend that we used during the development. And that backend – even though it is Backendless – would not be your backend. In order to get this app running with your backend what you would need to do is to create an account in Backendless. And this is exactly what we are going to do next.
To register with Backendless I just open a browser and go to http://develop.backendless.com. Here you will see the login screen. You can login with your facebook account or twitter (assuming that you do not yet have a Backendless account).
- You can also click the “Register” button and create an account.
- Once you create a Backendless account Backendless will send you a confirmation e-mail with a link to confirm your e-mail address. Click that link and you will be able to login into your Backendless backend.
- Let’s create a new app clicking the “Create App” button. Input a name “RestaurantTo Go” in the box for our app name and click “Save”.
- The app is now created
- The next step is connecting the project you downloaded from github with the created backend. In order to do this the project code needs to be updated with the Application ID generated by the backend. The Application ID is very important because it is used by Backendless to identify your specific backend.
How to obtain Application ID?
- In Backendless Console click the “Manage” icon. The screen that appears contains all the application settings. At the very top you will see various IDs. The first one is the application ID. If you click the copy button it will be copied to the clipboard.
- Switch back to Android Studio and open up the “order_success” module. Locate the “BackendSettings” class. The code already have Application ID and Secret key for the app that we used during the development and as a result it points to our backend. Select the Application ID value and paste the value you’ve obtained from the Backendless Console.
- You will need to repeat the same steps for Secret Key.
- At this point if you were to re-run the application it will be communicating with your Backendless backend. The next thing that will need to be done is to import all the data with all the restaurants, locations and menus to your backend. Go to Android Studio and choose Android ->Project from the drop-down menu.
- In the “Project” section you will see a folder called “Data” that will contain a zip file. That zip file includes all the data that can be imported into Backendless. In fact, this zip file was created by an export procedure in Backendless. So we exported data from our backend and put it into github. And now you can import it to your own backend.
- In order to do that switch back to Backendless Console and navigate to the “Manage” > “Import” section. Click the “single zip-file” link. You can also import individual files for your data tables, geopoints and so on, but we will not focus on that now. Right now we are going to import just a zip-file.
- Browse to the zip file and click “Open”. The data from the pointed file start to be imported to your Backendless backend.
- Once the import process is done – it literally should take just a few seconds – you’ll receive an email with the confirmation that the import process is complete. You can check that the process has fully completed if you go to the “Data” section of the Backendless Console. You will see that all the data that is included into zip-file is now imported with all the links and all the relations between the tables.
- Switch back to Android Studio and re-run the project. Make sure you run the configuration for the order_success module – this one includes the backend settings.
- Now when the app runs, it is connecting to your own backend and we are going to register an app account clicking “Register”.
Once an account is created you are able to login. After logging in, you can see all your data is now populated from your own backend and your app is fully functional.
Enjoy and Happy coding!