Important
This article only applies to the Gimbal Android SDK v2.x Beta. Gimbal is constantly introducing changes to their SDK and possible discrepancies may be found within this article depending upon the reader’s unique circumstances. Please refer to the official Gimbal documentation as the definitive source of official information.
Introduction
This article discusses how to set up the Gimbal SDK v2.x Beta in Android Studio. As of the date of this article, Gimbal has plenty of documentation on getting things working with Eclipse, but many developers are moving to Android Studio. Following the instructions within will get that IDE working with Gimbal rather quickly. After reading this article, be sure to read this post to take a deep dive of how the SDK works with proximity beacons.
Setting up the Gimbal SDK v2.x Beta in Android Studio
- Download the applicable SDK from the Gimbal Developer site.
- Create a folder named libs in the root of the project. For example, \ProjectFolder\mobile\libs.
- Copy the following files from the SDK to the libs folder: gimbal-dev-logging.jar, gimbal.jar, spring-android-core-1.0.1.RELEASE.jar, and spring-android-rest-template-1.0.1.RELEASE.jar.
- Modify AndroidManifest.xml and ensure the following permissions are added:
12345678<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><uses-permission android:name="android.permission.WAKE_LOCK" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /><uses-permission android:name="android.permission.BLUETOOTH" /><uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> - Open the file build.gradle. For example, ProjectFolder\mobile\build.gradle.
- Ensure the dependencies node looks like this:
123dependencies {compile fileTree(dir: 'libs', include: ['*.jar']) // this adds all JARs in the libs folder} - Add the following right below the buildTypes node closing bracket:
12345678910buildTypes {// ...}/* LINES TO ADD START HERE */packagingOptions {exclude 'META-INF/notice.txt'exclude 'META-INF/license.txt'}/* END OF LINES TO ADD */ - In Android Studio, go to File → Synchronize.
- Then while still in the IDE, go to Build → Rebuild Project.
Conclusion
If the steps above were followed correctly, then no errors will occur upon building the project when using the Gimbal SDK. Hours of time were saved getting things working by following the advice of Rodrigo Esquivel, who posted this answer (edit: link removed as it now gives 404 error) to a question on the Gimbal Support page. It discussed how to modify the build.gradle file, which was a life-saver, so many thanks for such an excellent answer.
The steps shown within this article are different from those found in the v1.x of the SDK; Gimbal has simplified things. Moreover, keep in mind other steps will be needed to get it working even further (setting up keys with the SDK) but this article addressed getting the actual SDK files working with the IDE itself. It does not cover diving into the SDK, but again that topic is discussed in this post.