Skip to content
Rex St. John

Get in touch

Using The Android BOX SDK With Android Studio

This is a guide on how to use Box’s Android SDK in Android Studio. Parts of this guide are derived from ReadMe files provided by Box, the rest is provided to fill in the blanks about how to actually do this.

Originally published on the rexstjohn.com blog

Tags
  • android

Originally published at rexstjohn.com on December 1, 2013. Recovered from the Internet Archive.

This is a guide on how to use Box’s Android SDK in Android Studio. Parts of this guide are derived from ReadMe files provided by Box, the rest is provided to fill in the blanks about how to actually do this.

Step 1: Install Gradle (OSX Mavericks)

We will need Gradle installed to build and install some key dependencies.

  • Download the Gradle 1.6 (NOT THE LATEST GRADLE, IT MUST BE 1.6 ONLY): http://www.gradle.org/downloads
  • Unzip the full directory
  • Move the contents of this directory to: /Users/*****(yourname)/Developer/gradle (or your desired directory)
  • Now run “vi .bashrc”
  • Add the following lines to your .bashrc:
GRADLE_HOME=/Users/*****/Development/gradle
export GRADLE_HOME
export PATH=$PATH:$GRADLE_HOME/bin

Step 2: Download & Build The Box Java SDK

Before you can use the Box Android SDK in Android Studio you must install the Box Java SDK V2.

Step 3: Install Maven

We must also install the Android Support Library for this to work. To do that, we must also install Maven.

  • Simply use Homebrew to get Maven: “brew install maven”
  • “mvn -v” to see if Maven is installed in the Terminal

Step 4: Install The Android Support Library

Next, time to install Android Support Library using Maven.

In my case, I use “~/Applications/Android Studio.app/sdk” because this is where Android Studio installs it’s SDK by default. Here is the Maven command that worked for me (note you must wrap the path in “‘s).

Additional Note: On OSX you have two application’s directories, one at the very root path and the other under your Users folder. The below command must target the appropriate directory where you have Android Studio installed.

mvn install:install-file \
-Dfile="/Applications/Android Studio.app/sdk/extras/android/support/v4/android-support-v4.jar" \
-DgroupId=com.google.android \
-DartifactId=support-v4 \
-Dversion=r13 \
-Dpackaging=jar

This should yield the following message or something like it:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing /Applications/Android Studio.app/sdk/extras/android/support/v4/android-support-v4.jar to /Users/rexstjohn/.m2/repository/com/google/android/support-v4/r13/support-v4-r13.jar
[INFO] Installing /var/folders/49/6kvdjbmx2_55s6mt2vbdl12r0000gn/T/mvninstall6323110116717365831.pom to /Users/rexstjohn/.m2/repository/com/google/android/support-v4/r13/support-v4-r13.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.448s
[INFO] Finished at: Sun Dec 01 14:20:37 PST 2013
[INFO] Final Memory: 3M/81M
[INFO] ------------------------------------------------------------------------

Step 5: Build the BOX SDK

If you haven’t already, download the Box Android SDK (This is a totally separate SDK from the BOX Java SDK we installed earlier, which is also required).

Download, unzip (or use Git to fetch) the BOX Android SDK directory and navigate to the “BoxAndroidLibraryV2″ folder using the terminal.

You may need to add a “local.properties” file into the project directory with the following variable: “sdk.dir=/Applications/Android\ Studio.app/sdk”

Now run: “gradle build” while in that directory.

Edit: This is not working for me, I am getting the following error currently, will follow up with BOX.

WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.5 is ignored for Debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for Debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.5 is ignored for Debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
[Fatal Error] :13:12: Content is not allowed in trailing section.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'BoxAndroidLibraryV2'.
> Failed to notify project evaluation listener.
   > Failed to read manifest

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED