Android Tutorials

Quickstart Introduction

latest update Sep 21, 2017


Here you will learn how to get our SDK up and running in your Android project to explore Parse Server core features and Back4App add-ons.

For more detailed information about the SDK, check out our API Reference.


Prerequisites

In this tutorial we use a basic app created in Android Studio 2.3.3 with Compile SDK Version = 26 and Min SDK Version = 16.

To complete this tutorial, you will need:

Note: Parse Server works with Android 2.3 or higher.


Step 1 - Installing SDK

Follow this step if you haven’t installed our SDK yet.

Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process while allowing you to define flexible custom build configurations. You can refer to Android Studio’s Build Guide to learn more about it.
To install de Parse SDK for Android, in your Android Studio project, open your app/build.gradle file:

build.gradle file from module app

Be careful, there are two files with build.gradle name.

The Google HTTP Client Library for Java is in the central Maven repository. In a nutshell, Maven is an attempt to apply patterns to a project’s build infrastructure in order to promote comprehension and productivity by providing a clear path in the use of best practices.

You can read more about at Maven Getting Started guide and Android Studio Build Dependencies guide.

To add Maven repository, go to your build.gradle file, and before dependencies{} block copy and paste the following code snippet:


build.gradle

1
2
3
repositories {
    mavenCentral()
}

Adding Maven repository

Now, to install the SDK, you need to add the following lines inside dependencies{} block. Remember to update the version of Parse SDK for Android to the latest one. You can find it at Parse Community GitHub repository.


build.gradle

1
compile 'com.parse:parse-android:1.16.2' //update version to the latest one


Sync your build.gradle and we are ready to go.

Synchronizing build.gradle file

Troubleshooting:

If you got some error message related to support library, like the image below:

Error with support repository

You can solve it by adding the repositories maven {url "https://maven.google.com"} and jcenter().

At the end your repositories{} section should look like this:

build.gradle

1
2
3
4
5
6
7
repositories {
    mavenCentral()
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}


Click on Try Again to sync your build.gradle and we are ready to go.

Synchronizing build.gradle file again

If you want to read more about adding support libraries, please refer to the Android Studio’s Support Library Setup page.


Step 2 - Configuring App Permissions and Libs

Granting Permissions

Back4app is a Backend as a Service (BaaS) built on the top of in Parse Server open source framework.

It provides you with an application development platform in the cloud. Therefore, it requires you to grant internet permission to work.

You can do that by adding the following code snippet to your AndroidManifest.xml file to grant this permission to your Android project:

AndroidManifest.xml

1
2
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>


You should have something like this:

AndroidManifest.xml file

Adding Libs

To call all Parse provided functions you will need to import libs to your code.
Choose the activity which will implement parse function and import the following libs:

.java

1
2
3
import com.parse.Parse;
import com.parse.ParseObject;
import com.parse.ParseUser;


In this example, we choose to import inside MainActivity. At the end you should have something like these:

MainActivity file


Step 3 - Connecting your Parse App

If you already have a parse app please refer to the step: Initialize your Parse app.

Create new Parse app

  1. Go to Back4App website

  2. Fill out your information and click on Sign up for Back4App

    Sign up page

  3. Inside your Back4App dashboard click on Build new Parse app

    Building new app page

  4. Fill out the details about your new app and click on Create

    Create new app

    If you choose to set the API as Open Source, its AppID, REST Key and classes will stay public. If you don’t want to share them or don’t know what to do, just leave this block unchecked.

  5. You will see a congratulations page showing all our features available. Go to Core Settings block and click on Server

    New app created

  6. Here you can found all details about your Parse App, including your App ID, Client Key, Master Key and others

    Your parse app details

Initialize your Parse app

To connect your App and Back4App, we will use Parse.Initialize function to build a bridge between them.

Inside your activity onCreate, add the code below.

.java

1
2
3
4
5
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId("YOUR_APP_ID") //PASTE YOUR Back4App APPLICATION ID
.clientKey("YOUR_CLIENT_KEY") //PASTE YOUR CLIENT KEY
.server("https://parseapi.back4app.com/").build()
);

Now, go to your App Dashboard at Back4App website, to find your Application ID and your Client Key.

Navigate to your app, click on Features > Core Settings block > Server.

Go back to your Parse.Initialize function and paste your applicationId and clientKey.

You need to point the server url to Back4App. If you use Parse.initialize{this, appID, clientkey}, it will not point to your back4app Application.


Next Steps

At this point, you have a solid foundation of how to get started with Android apps to explore Parse Server core features and Back4App add-ons.


If you are not sure what you want to do with your app, check out the next tutorial in this series to explore the Back4App functionalities for Android apps. It covers things like basic user registration, push notifications, and live queries.

If you just want to explore, take a look at Docs main page to find more tutorials. Some popular ideas are Command Line Interface (CLI), which will allow you to create new Parse apps, deploy Cloud Code to an app, view all releases, and more.


Feel free to reach out to us through our website chat if you have any questions.