7

There are a couple of tutorials or even questions here about creating an application for Android. But I was wondering, if I just want to compile an application from the available source on Github, I'm not going to develop anything, do I need to install the Android SDK, Eclipse with ADT plugin, and the SDK tools and platforms?

In GNU/Linux you just have to install the build tools and dependency libraries, not an IDE, which is generally for doing the development. How would you proceed in compiling the APK? Not that I want it to be like GNU/Linux, but what are the required tools just for compiling? And do I need to downgrade my Java version to 6 when I'm compiling for Android 4.1.2 (if Java is needed)?

Also, there are no build instructions on the source, including a few steps on your answer would be highly appreciated!

admirabilis
  • 177
  • 1
  • 1
  • 8

1 Answers1

9

The minimal requirements for building an Android app are usually the Android SDK and ant. Then, you are able to build the majority1 of projects with the following steps.

  • If there is no build.xml generate it

android update project -p . -n $PROJECT_NAME -s

  • Then build the project with

ant debug

which will create an .apk signed with your debug key.

All other dependencies range from the used VCS (e.g. git), over the required 3rd party libraries, up to other required build tools (e.g. Android NDK).

1 Why did I write majority? Because there is no definitive answer for such a question, as it simply depends on the used build system and the overall build setup of the project.

Let's have a look at F-Droid's metadata, which is a big database of build recipes for FOSS Android apps. You will find that there are many ways how an Android app can be build. For example goo.TeaTimer has a very clean and short build recipe, namely none, which defaults basically to F-Droid using ant debug to create the .apk. On the other hand, org.transdroid.full requires a few more steps to create the .apk: First the transdroid core library needs to be created, that is the ant -f ../lib/build.xml line in prebuild, then options are disabled with the sed command. Now the final .apk can be built.

Flow
  • 18,464
  • 16
  • 79
  • 138
  • Your command doesn't work because it lacks a AndroidManifest.xml, and the error from running is "Unable to load key from Google Drive, retrying: null" – admirabilis Jan 04 '14 at 21:06
  • The command was incorrect rendered. I've edited it. It's the same command F-Droid and I use within my Android project to generate build.xml. I've took a closer look at keepshare: It uses sbt (simple build tool) and is a good example for a project which does not use ant but instead some other build tool. Therefore the commands and tools to build the project differ. – Flow Jan 04 '14 at 21:32
  • The answer here only works for java apps; keepshare has Scala source code which is why SBT is necessary. There are very few Scala apps and F-Droid doesn't support it. Also ant is deprecated—gradle is the future for building Android apps. The app label in AndroidManifest.xml is Keepass database access so that's how it should appear in the launcher. – daithib8 Jan 06 '14 at 19:31
  • This statement is not correct. The used programming language and the used build system are not dependent on each other. SBT is not required to build Scala code, as little as Ant is required for Java code. The answer focuses on the most common build system for Android at this time: Ant. But it is true that the new build system is gradle. I think I made it clear in the answer, that there is no definitive answer for such a question, as it simply depends on the used build system and the overall build setup of the project. – Flow Jan 06 '14 at 19:36
  • Ant with the Android SDK build.xml only works with Java only apps; I think that's true. – daithib8 Jan 06 '14 at 19:57
  • No, you can transform anything with ant, not only Java. And Android's build.xml provides hooks to modify it to your needs (e.g. compile C code), it's also not restricted to Java. – Flow Jan 06 '14 at 20:03
  • I don't know why you'd use ant to compile C code for an Android app. If ant could be used to compile Android Scala apps, I think it would have been done already. – daithib8 Jan 06 '14 at 20:07
  • C was just an example. It could be any language. And why one would do that doesn't matter for this discussion. But I'd would say that some developer do it because they don't want to depend on another build tool, for example. – Flow Jan 06 '14 at 20:24
  • 1
    Your answer still isn't relevant for Keepshare. The real answer is provided in comment #3. – daithib8 Jan 06 '14 at 20:32
  • 1
    That's right. I think more users benefit from an general answer compared to a specific one. OP already figured out that SBT is the used build tool. – Flow Jan 06 '14 at 20:35
  • It's a pity the OP still doesn't have a usable apk. – daithib8 Jan 06 '14 at 20:46