Prerequisites

Note: If you don’t have a basic app created you can follow the Create a Project tutorial from Android Studio Website. After you create your basic app you are ready to follow this guide.

Note: Parse Android SDK works with Compile SDK Version = 27 and targetSdkVersion 27 or higher.

Step 1 - Install SDK

Android Studio uses Gradle (an advanced build toolkit) to automate and manage the build process while allowing you to define flexible custom build configurations. To install Parse SDK for Android you will have to make some set up in the Gradle of your Android Studio Project. To do so, follow the steps described below:

Be careful, there are two files named build.gradle. You want to modify the (Module:app) one.

Now, go right after the dependencies{} tag in the build.gradle (Module:app) file and copy the following code snippet:

1
2
3
4
5

repositories{mavenCentral()jcenter()maven{url'https://jitpack.io'}}

It’s also necessary to look in the android{} tag if your compileSdkVersion is 27 or higher and also if your targetSdkVersion is 27 or higher. If they aren’t, you must change these versions to 27 or higher, otherwise your Parse SDK for Android may not work properly. After checking this, your build.gradle (Module:app) should look like the one in the image below.

Now you are ready to install the Parse SDK. To do so, you need to add the following lines inside the dependencies{} tag.

1
2

// Don't forget to change the line below with the latest version of Parse SDK for Androidimplementation"com.github.parse-community.Parse-SDK-Android:parse:latest.version.here"

Remember to update the version of Parse SDK for Android to the latest one. You can find out which is the latest version at JitPack website, following these steps:

Step 2 - Connect your app to Back4App

To use the Parse SDK, your application need to have access to the internet network. To allow your app to have it, you need to grant permissions in the AndroidManifest.xml file. Also, you have to set up the app’s credentials to connect your app to Back4App. To do this, folow the steps below.

<stringname="back4app_server_url">https://parseapi.back4app.com/</string><!-- Change the following strings as required --><stringname="back4app_app_id">PASTE_YOUR_APPLICATION_ID_HERE</string><stringname="back4app_client_key">PASTE_YOUR_CLIENT_KEY_HERE</string>

Leave the string.xml opened and go to Back4App Website, log in and click on My Apps. Find your app and then click on SERVER SETTINGS.

Find the “Core Settings” block and click on Settings. The “Core Settings” block looks like this:

After that, you will see the details of your Parse app, such as your App Id and your Client Key. Copy these credentials and paste them in the appropriate place at the strings.xml file of your Android Studio Project.

Step 3 - Initialize your Parse App

Create a Java file called App that extends Application.

Import to your App.java file:

1

importcom.parse.Parse;

Inside App.java onCreate method, right after super.onCreate() call the following code:

1
2
3
4
5
6
7

Parse.initialize(newParse.Configuration.Builder(this).applicationId(getString(R.string.back4app_app_id))// if defined.clientKey(getString(R.string.back4app_client_key)).server(getString(R.string.back4app_server_url)).build());

Don’t forget to define this file in the AndroidManifest.xml. To do so, go to the AndroidManifest.xml file and add the following line of code inside the application tag:

1

android:name=".App"

If the name of the java file that extends Application that you created on the previous step isn’t “App”, don’t forget that the code above should have the correct name of the file (android:name=".name_of_the_file").

Step 4 - Test your connection

With Parse SDK every time a user download your app, it’s possible to register its installation by using the ParseInstallation.getCurrentInstallation() method of ParseInstallation class. The first time you save a ParseInstallation, Parse will add it to your Installation class on your Dashboard. To test your connection with Parse SDK, let’s save an installation in the main activity of your Android Studio Project, following the steps described below.

Go to your Android Studio Project and add the following code to your onCreate() method in order to save the installation of the application into your Dashboard.

1
2

// Save the current Installation to Back4AppParseInstallation.getCurrentInstallation().saveInBackground();

Launch your app and go to Back4App Website and click on My Apps. Find your app and then click on DASHBOARD.

Now click on Core > Browser > Installation. You should see an installation registered, as shown in the image below.

It’s done!

At this point, you have learned how to install the Parse SDK in your application.