Set up and run the Office 365 Android SDK Samples in Android Studio

How do you set up and run the samples in the Office 365 API Android SDK? This post provides a detailed step-by-step walkthrough. You can either read the post or watch the video, both of which cover the same content:

First, download the Office 365 SDK for Android from the GitHub repository. You can click on "Download Zip" on the page to download the SDK, or you can just press "Clone"

Open Android Studio, then go to File > Import Project. Look for the location you downloaded the SDK to, and go to the samples folder within that. Next, go into the folder "outlook" - I'm going to show you how to set up the "outlook" sample. Select build.gradle in this folder, and click OK.

At this point, Android Studio might prompt you "Language level changes will take effect on project reload. Would you like to reload project "outlook" now? Just click yes.

Your project structure should looks like this:

Press the Run button and run it on either your connected device or an emulator. You'll see that the app compiles and runs successfully, but it doesn't do anything.

What's wrong here? Well, we haven't yet registered this app with Azure Active Directory. Let's go do that now.

Go to, and click on Portal at the top. Enter your login for Azure, and select your Active Directory that you want this app to be registered to. Let's say we want to test it on my Office 365 tenant, so in this case, I select that tenant. You'll be able to select your own tenant here based on what you created previously.

Once you've select your Active Directory, click on "Applications" as shown below:

At the bottom, press "Add"

Select "Add an application my organization is developing" and on the next page, enter any name for your application. In this case, I'm using "Android-Outlook-Sample". Select "Native Client Application" since it's going to run on a mobile device.

On the next page, type anything you want into the Redirect URI box. I chose "" as my redirect URI.

Press OK. Go to "Configure" and you'll see the following:

First we want to press the green "Add application" button below and select "Office 365 Exchange Online." Press OK, and select the following permission:

We just told Azure AD that we want this app to have some mail-specific permissions. So that means the app will be able to read and write a user's mail, and send mail as the user. Don't forget to click on "Save" at the bottom of the screen to save this change!

Now, go back to Android Studio and go to app > java > > samples.outlook > in the project navigator view. Fill in the REDIRECT_URL and CLIENT_ID fields with the values in Azure AD (if you're not sure where to get these values, refer to the second-last image before this paragraph, that shows you where the redirect URL and client ID are). This is what you should have:

Screen Shot 2015-01-08 at 10.00.37 PM.png

Now, run the app again. Immediately you see that you are presented with a login screen. Sign in to Office 365 with your credentials.

Click on "Play with Email"

You don't see anything yet. Tap on the three dots at the top right to bring up the menu, which contains of only one item, Settings. Tap on that and enter your email address. It should be the email address of the same user that you previously logged in to:

Press Enter, and then press "Update". If your mail doesn't show up, you might want to just tap on the Back Button to go back to the screen with the Mail & Calendar buttons, and tap on Mail again, and then hit update. It might take a while.

You should see your emails in your inbox show up!

Of course, you can also use the Calendar functionality in this sample, but you'll want to go into Azure AD first and add the relevant Calendar permissions. If you've any questions, post them in the Comments below.

Set up and run the Mail Sample Android Project for Office 365 PREVIEW SDK

Note: This post is outdated, as it uses the SDK from when the Office 365 APIs were in Preview. Now that the APIs are generally available, please refer to this other article I wrote more recently on how to set up the sample in Android Studio.

My previous post covered setting up the Office 365 Android SDK and configuring it within Eclipse/ADT. I also wrote about the import errors that you may see, and how to fix those. 

Now let's actually run the sample projects to see what the new Office 365 APIs can do!

Note: As of writing, the APIs are still in Preview. They shouldn't be used in production as we may make breaking changes before they are released. Expect irregularities, and teething problems as we work hard to make them ready for use in your production code. Send feedback to the team through our page on UserVoice.

Which sample do you run? Well, the Office 365 Android SDK Github repository contains 7 Android projects (excluding the Tests, which shouldn't matter to you much):

  • office365-base-sdk
  • office365-files-sdk
  • office365-lists-sdk
  • discovery-files-sample
  • exchange-sample
  • read-sp-list-sample
  • read-write-sp-list-sample

The intention of having 3 different SDK projects is so that you don't have to pick between all, or nothing. You can just bundle whichever is appropriate for your project, and cut out the other functionality you won't be using, thus keeping your app as lightweight as possible.

The intention of having 4 samples is that each one focuses on a different end-to-end scenario which might be useful to you. If you're writing a mail app, for example, you probably wouldn't want to worry too much about OneDrive for Business files.

Let's just scope our attention to the Mail sample project (i.e. exchange-sample) for this blog post.

All the import errors should have been solved if you've followed my previous post.

1. Register the app in Azure.

2. Go to the Constants class. Change the value of the CLIENT_ID string to your app's client ID in Azure. (Coming soon: A post on how to register your app on Azure). It should look something like this:

3. Run it on either the emulator or your device.


If so, it's because the SDK hasn't been updated yet to reflect the new naming structure of the updated Azure Active Directory Library for Android. Remember how we added .aad in the import statements for all the classes that use the ADAL? We also need to update AndroidManifest.xml. Make sure the reference to the AuthenticationActivity in adal looks like this:

4. Try running it again. The app should launch, and you'll see this:

Sign in with your organization ID, e.g., or You cannot sign in with a Microsoft Account (MSA). An MSA would look something like or

After signing in, you'll see a view asking you to approve granting certain permissions to the app:

Note: Don't be unduly worried by the long list of permissions you see above. That's because in my Azure Active Directory, I registered the app and gave it all the available permissions in the drop-down. You don't have to do that; you can probably get away with just giving the app a limited subset of permissions.

After you approve those permissions, you'll see your inbox:

Ta-da! The app pulls in email from the Exchange server and displays them to you. You can click on each email to see the entirety of the message.

Getting Started with the Dropbox Core API for Android

Dropbox has several APIs listed on their developer portal, and that can be a little confusing at first. Take your time to poke through each one, and see which one works best for your own specific needs.

I wanted to learn how to integrate Dropbox functionality into my Android app, so I did a Google search for "dropbox android sdk". The first result led me to the download page for the Android SDK for the Core API, and at that point not knowing that there were multiple SDKs for the different APIs, I decided to start with that.

This article will focus specifically on getting the starter project for the Core API set up in Eclipse/ADT. You can also watch the YouTube video I made.

1. Download the Android SDK for Core API. Click on the download link on the download page.

2. Unzip the downloaded SDK, then import the sample project.

3. If you try running the project now, you see this:

So go to the site and register your app to obtain the app key and app secret. Just go to and click on "App Console" on the left hand navigation pane.

Sign into your Dropbox account to continue, and you'll see this: 

Click on the Create app button on the top left corner of the page as shown in the screenshot above. You'll get a form and you'll have to also verify your email address when you create the app if you haven't done so already. Select Dropbox API app as shown below:

Fill out the rest of the form:

As you see in the screenshot above, you can't use the word "Dropbox" in the app name - the branding guidelines tell you that you can't do that. Once you successfully create an app, you get a dashboard similar to the one below. Find the app key and app secret, and copy and paste it into the right file in Eclipse.

4. Next, try running the project again. You see this:

It means we also need to change the manifest file of the app to include the app key. As you can see in the following screenshot, you replace "CHANGE_ME" with your app key in the line highlighted:

5. Run the project now. It should work! You'll see this:

Clicking on "Link with Dropbox" as seen in the screenshot above would prompt you (and anyone who uses this app) to sign in with Dropbox:

After going through the sign-in flow and granting permission for the app to access the files and folders in your Dropbox, the app brings you back to the main view. You can click on "New Photo" to upload a photo, and see a progress bar of it uploading. Clicking on "Roulette" will display a photo that was uploaded onto Dropbox.

That's it! It was super painless and easy to set up the starter project for the Dropbox Core API Android SDK.