While I’m thrilled that we can now use Android Studio with enterprise projects, the documentation is still a little hit and miss with regards to using plugins. Facebook usage is a notable omission and it is surprising that v4 is still considered beta.
I’ve been successful getting a test app and my real app working with Facebook. It is actually pretty straightforward which comes with a bit of relief. The short answer is you need to import the Facebook project that is part of the enterprise distribution. Here’s the step-by-step:
-
In your libs directory add the plugin.facebook.v4.jar file. You SHOULD NOT have any of the other facebook jars like bolts-android-1.1.2.jar or facebook_sdk.jar.
-
Add the following to your app’s gradle.properties file (these values are copied from Facebook’s gradle.properties)
ANDROID_BUILD_MIN_SDK_VERSION=9
ANDROID_BUILD_TARGET_SDK_VERSION=21
ANDROID_BUILD_TOOLS_VERSION=21.1.2
ANDROID_BUILD_SDK_VERSION=21
-
In Android Studio, select File->New->Import Module…
-
Browse to the Facebook code in the CoronaEnterprise folder in applications:
/Applications/CoronaEnterprise/Plugins/sdk-facebook/android/4.5.0/facebook
-
If you don’t already have tools and sdk version 21 installed, you’ll get errors along with links to perform the install.
-
In your build.gradle for the app, add the following to dependencies:
compile project(’:facebook’)
- Clean / Rebuild / Run (It sometimes takes me a couple of clean, rebuild passes to get everything going)