1

Ok this thread is going to be more like a discussion to the topic mentioned in the title. I googled the whole topic over and over but didn't find a good / acceptable solution for me.

Scenario

Let's assume I have an android project and I need a third-party library for it (for example drag-sort-listview library).

How to integrate it?

Without Git

According to the official documentation and to this thread we should do it like this (simplified!):

  1. Import Project into eclipse (from existing Android Source)
  2. Go to your project properties -> Android -> Add the library (from your workspace)

With Git

  1. Make a Git sub-module for the third-party library. Do this in a folder of your project (for example myproject/thirdpartylibs/newLibrary)

  2. Same steps as above but as the "existing Source" choose the one you just cloned into your project

Discussion

For me: this is NOT satisfying at all!

Why?

Firstly: I don't want a library project in my workspace - I just don't care about it. I just want to use it. I want a JAR which I can put in my "libs" folder (as described here). Sadly you can't create Jars out of Library-projects (source) (or is there a hidden way?).

Secondly: Everyone who pulls my project has to manually generate the project of the third-party library and then add it to the project. So if someone just pulls my project it won't work until he does this. Pretty shitty if you ask me.. (or I am missing something here?)

Thirdly: Git sub-module looks like an overkill most of the time. It would be so much easier to just put a JAR in the libs folder and be done with it. Sure it is not much work to do so, but it just adds kind of another layer of "complexity" to your project.

The questions

I am the only one who is annoyed like hell because of this?

How are the big boys doing this (like CyanogenMod, etc.)?

Why are there still JAR libraries out there (for example ORMLite) ? Is this only because they don't need android specific resources and stuff? Or does anyone know WHY they can build a JAR with their libraries and "all" other can't?

Community
  • 1
  • 1
OschtärEi
  • 2,175
  • 3
  • 18
  • 39

1 Answers1

3

I am the only one who is annoyed like hell because of this?

No.

How are the big boys doing this (like CyanogenMod, etc.)?

CyanogenMod is an entire fork of the AOSP Android, and work at a lower level than SDK libraries. Comparing them to Android Library Projects is not a good idea.

Why are there still JAR libraries out there (for example ORMLite) ?

JARs can be created for any project that does not use any R.*.* resources. You can create a JAR from other projects as well, but they will die with a ResourceNotFoundException. To get around this, you can have users add all of your required XML resources to their projects (like ACRA does, by requesting you to add an XML string if you opt to use the alert part of their library).

Or does anyone know WHY they can build a JAR with their libraries and "all" other can't?

Because they don't use XML resource from the R section. XML resources are not bundled into JARs because JARs are meant for code only. Android compiles all XML resources into a binary file, which is included separately in your apk.

Raghav Sood
  • 79,170
  • 20
  • 177
  • 186
  • Thank you - confirms my suspicisons. So short said: There is no better way right now? – OschtärEi Apr 19 '13 at 07:20
  • @tenhouse Aside from the way ACRA uses, no. – Raghav Sood Apr 19 '13 at 07:21
  • Thanks again. So stupid and ridiculous... And I know CM is on a lower level - just thought that they also need to use libraries from time to time like we do :) – OschtärEi Apr 19 '13 at 07:22
  • This might be a dumb comment, but have you looked into maven with the android-maven-plugin (https://code.google.com/p/maven-android-plugin/)? – Joris Apr 19 '13 at 09:06