-
Notifications
You must be signed in to change notification settings - Fork 556
Work with DroneKit Android
- Why we need this
In this way, function calls are implicitly buried all over the code. It would be better if we know how to develop Tower and Dronekit using Android Studio at the same time and constantly keep them refer to each other. This document is a tutorial on how to do it.
- Build DroneKit-Android
![](http://i.imgur.com/VjhsyRW.png)
Modify the code if you have already figured out what you want (in other case, don't), and hit build. Now it will automatically generate an [aar](https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/aar-format) file in the directory "DroneKit-Android\ClientLib\build\outputs\aar". For example, "dronekit-android.2.5.21.aar"(the version number is programmically generated). That's the client lib dependency file Tower uses when it builds itself. In other words, whatever changes you made in Dronekit (especially client lib related changes). It should be reflected in that aar file.
![](http://i.imgur.com/g0wOujd.png)
Now hit "run" button in Android-Studio (with your Android device connected), will install the customer built 3DR service to your device. See below an example of customer built 3DR service app that calculate GCS's attitude in real time. ![](http://i.imgur.com/or09zjx.png)
- Link it in Tower Development
First, in the root directory of Tower, find "build.gradle" file and open it. In the "allprojects" definition, in the "repositories" entry, add one attribute called "flatDir" and put in the path to the directory "DroneKit-Android\ClientLib\build\outputs\aar" where the DroneKit aar file is. See below for details.
![Add](http://i.imgur.com/qLdqmE5.png)
Then we need to tell gradle and maven to search local DroneKit build. In the Android folder, find the "build.gradle" (different from the previous one), and open it. Find the entry "compile 'com.o3dr.android:dronekit-android:2.3.xx'" and delete the whole entry. Instead, add "compile(name:'dronekit-android.2.5.21', ext:'aar')" in the line below. See below for details.
![](http://i.imgur.com/9WOM5Ci.png)
Save everything and in Android-Studio, click "tools->Android->Sync Android with Gradle Files". It will automatically search all dependency libs (including our local DroneKit build) and link it in our codes. Now try to play around your Tower code, and call some functions in your Dronekit lib (for example, the "drone" and "controlTower" class in "FlightActivity"). Below is an example of a modified Tower that fetches GCS attitude data from 3DR service app and display them in GUI.