Skip to content

Building AntennaPod

daniel oeh edited this page Sep 28, 2013 · 13 revisions

Building AntennaPod

Step 1: Clone the repository, download dependencies

Clone repository

Execute the following commands to download the AntennaPod repository and the repositories of its library projects:

git clone --recursive https://github.com/danieloeh/AntennaPod.git  

Set up the Android SDK

In order to be able to build the app, you should download the following SDK components:

  • Android SDK tools, Android SDK platform-tools and Android SDK Build-tools
  • The latest version of the Android SDK platform
  • Android support repository
  • Android support library

.jar dependencies (not necessary for gradle)

Create a new directory called libs in the root directory of the AntennaPod repository. Next, download the following libraries and move their jar-file into the libs directory. If you are using maven, you only have to download the 'Presto Client' library":

Pulling from the main repository

This repository uses git submodules. That means you should run git submodule update every time you pull from the main repository to receive any changes in the submodules.

Step 2: Create FlattrConfig.java

AntennaPod accesses the Flattr API for flattring podcasts. In order to gain access, a client ID and a client secret is required, which you can get by registering a new app on the flattr website. The official API credentials have been excluded from the public source code.
In order to successfully build the project, a java class called FlattrConfig with two fields containing the credentials has to be created in src/de/danoeh/antennapod/util/flattr . You can also use the file called FlattrConfig.java.example to do that. If you leave the two fields blank, everything except the authentication process will work.

Execute the following command from the root directory of the AntennaPod repository to create FlattrConfig.java:

cp src/de/danoeh/antennapod/util/flattr/FlattrConfig.java.example src/de/danoeh/antennapod/util/flattr/FlattrConfig.java

Step 3: Set up build system

There are several different tools available for building AntennaPod. You only have to choose one of them.

Building in Android Studio

  • In Android Studio, go to File → Import Project…
  • Select the root directoy of the AntennaPod repository and click "OK".
  • Select "import project from external model"
  • Select "gradle" in the list below "import project from external model" and click "Next"
  • Select "Use local gradle distribution" and type in the path to your Gradle home directory. Click "Finish"

Building in Eclipse

  • In Eclipse, go to File → Import... → Android → Existing Android Code Into Workspace
  • Select the root directory of the AntennaPod repository as the root directory in the import dialog.
  • Deselect all projects except the one located in the root directory of AntennaPod (it should be called "MainActivity"). Click "Finish".
  • Next, you have to import two library projects. Open the same import dialog and select the same root directory as before. Deselect all projects except the one located in submodules/dslv/library (it should be called "library"). Click "Finish" and rename the project, for example to "dslv".
  • Repeat the previous step to import the appcompat-v7 library. It should be located in Android SDK home/extras/android/support/v7/appcompat.
  • In eclipse, right-click the AntennaPod project, then go to Properties → Android. Make sure that both library projects are referenced by AntennaPod.
  • If you want to run tests, you can also import the test project that is located in the "test" directory. This step is optional.
  • Eclipse might refuse to build the app because of different versions of the support library. To solve this issue, right-click the AntennaPod project and go to Android Tools → Add Support Library... . Repeat this step with every one of the two library projects.
  • Wait until Eclipse has finished building the workspace. If no errors are displayed, you can start developing. Congratulations!

Building on the command-line with gradle

  • Make sure that you have installed gradle 1.7
  • Gradle will download the project's dependencies automatically when building the project.

Useful commands for building with gradle

Build debug APK:

gradle assembleDebug

Install debug APK on device:

gradle installDebug			

Print a list of all available commands:

gradle tasks

More commands can be found in the Gradle Plugin User Guide

Building a release APK with gradle

  • If you want the release APK to be signed by gradle automatically, you have to create a file called gradle.properties in the root of the project's directory.

  • Add the following lines to the gradle.properties and replace the value to the right of the = with information about your keystore:

      releaseStoreFile=keystore
      releaseStorePassword=password
      releaseKeyAlias=alias
      releaseKeyPassword=password
    

Useful commands for building release versions with gradle

Build release APK:

gradle assembleRelease

Install release APK on device:

gradle installRelease

Building on the command-line with maven

  • Set the environment variable called ANDROID_HOME to the location of your Android SDK installation

  • Make sure you have added the tools and platform-tools directories of the Android SDK to your PATH.

  • Use the maven-android-sdk-deployer to add the "support-v4" and "appcompat-v7" libraries as well as the latest "android" core platform dependency to your local maven repository.

  • Navigate into the submodules/dslv directory of the AntennaPod project folder.

  • In the "dslv" directory, execute the following command to add the library to your local maven repository:

      mvn clean install  
    

    You might have to repeat this step if the version of the library that is used by AntennaPod changes.

Building release APKs with maven (optional)

  • If you want to build signed release APKs and want them to be signed automatically by maven, create a new file called settings.xml in ~/.m2 if it doesn't exist yet.

  • Add the following lines to it or modify it accordingly if it already has any content. Replace the content of the <sign.*> tags with information about your keystore:

      <settings>
      <profiles>
      	<profile>
          	<activation>
              	<activeByDefault>true</activeByDefault>
      		</activation>
      		<properties>
      			<sign.keystore>/absolute/path/to/your.keystore</sign.keystore>
      			<sign.alias>youralias</sign.alias>
      			<sign.keypass>keypass</sign.keypass>
      			<sign.storepass>storepass</sign.storepass>
      		</properties>
      	</profile>
      </profiles>
      </settings>
    

Useful commands for building with maven

Build APK for developing/debugging:

mvn clean package

Build release APK:

mvn clean install -P release

Running unit tests

Unit test source files can be found in src/instrumentationTest. In order to run the unit tests, you have to set up gradle first (see Building on the command-line with gradle for details). Execute the following command to run the unit tests on all connected devices:

gradle connectedInstrumentTest

Once the unit tests have been run, a HTML report can be found in build/report/