3

I have some questions on using a lgpl library in my android app:

  1. Is it possible to have the library anywhere else in my apk - not in the .dex-file?
  2. If I create a service in the same project, is the service within the .dex-file?
  3. Can android apps consist of more than one .dex-file in the apk?
  4. Is there a way to automatically install another apk during installation (without asking the user/without searching it first)?

Thanks, Florian

  • a good questiob! because lgpl are not allowed to be inside dex file. a good question is if lgpl lib are allowed on smartphones at all? Lgpl libs must be exchangeable by the end user, which is not the case in an app on the store. – AlexWien Dec 03 '12 at 12:09

2 Answers2

1

Regardless of the legal status (IANAL), I can't really see a scenario where you could technically achieve this.

As I understand it, Java libraries used in an android app have to supplied both to the dx compiler and apkbuilder, so that nixes #1. The input to dx also includes your compiled aidl source, so that's a "yes" on #2. Next, I believe there can only be one classes.dex file in an android app so #3 is out. Not sure about #4 (based on Matt Wolfe's comment this is also a no). Hope that helps clarify things, good luck ...

Reference: http://www.alittlemadness.com/2010/06/07/understanding-the-android-build-process/

Quinn Bailey
  • 200
  • 7
  • You can't install an apk on the user's phone without asking, I know this.. You can bundle another apk within your own, offload it to exteranal storage when the user launches the app, and then prompt them to install it (taking them directly to the installer).. We did this and it works well, the user needs to have the setting on to allow non play store apps to be installed though. – Matt Wolfe Feb 07 '13 at 01:55
  • That makes sense about offloading the 2nd apk, but still in compiling that 2nd apk I believe you will need to supply your Java libs to both dx and apkbuilder. I'm not trying to shoot down the possibility of what Florian's trying to do, but my understanding is the restrictions of the platform won't allow it (besides the fact that it's likely in a legal grey area due to LGPL requirements). – Quinn Bailey Feb 07 '13 at 17:49
  • This answer is factually incorrect - it actually is possible to have multiple dex files, if by no more direct means then by manually loading the additional ones. – Chris Stratton Sep 15 '13 at 14:57
1

If you don't obscure the LGPL library with Proguard, end users can convert your apk to jar, extract jar, replace the LGPL library classes, repack jar, sign it with user-generated key, convert jar to apk, then install the new apk to an Android device. droidtext project has an explanation page of this process. It is very confusing to do it though, so Quinn Bailey's answer is still better.

EDIT: The wiki page I referenced is dead because droidtext project was shutdown due to licensing issues. If you have a local copy of the wiki page I'd really appreciate it. The following is the list of important steps I can remember:

  1. Developers should edit their Proguard configuration file so it excludes entire LGPL library package from being obscured. (How to stop proguard from obfuscating entire package?)

  2. Users can unpack, modify, and repack the apk and its contents by using tools like apktool and dex2jar.

NullNoname
  • 2,056
  • 1
  • 15
  • 12