3

In android applications we include many library files such as google-play-services-lib and Facebook-SDK etc. But we never really use all features and classes from those libraries, so my question is when .apk file gets created does all those classes are included or the only classes we use are included in our application? If yes then is there a way we can get around that? ie can we remove or do something to avoid inclusion of all classes?

Thank You...

nidhi_adiga
  • 1,114
  • 1
  • 16
  • 27

1 Answers1

3

You should keep your Android application as small as possible. Therefore you should only include classes in the jars which you really need.

http://www.vogella.com/blog/2010/02/11/java-library-jar-android/

It is better to obfuscate your code using Proguard.

ProGuard is a Java class file shrinker, optimizer, obfuscator, and preverifier. The shrinking step detects and removes unused classes, fields, methods, and attributes. The optimization step analyzes and optimizes the bytecode of the methods

Obfuscation also secures your code to an extent.

To enable ProGuard in your project, edit project.properties

# Project target.
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt
target=Google Inc.:Google APIs:16
android.library.reference.1=../actionbarsherlock

http://developer.android.com/tools/help/proguard.html

http://proguard.sourceforge.net/index.html#manual/introduction.html

Raghunandan
  • 132,755
  • 26
  • 225
  • 256
  • 2
    yes you can but you make sure the classes that you included in your project do not depend on those deleted. If there are lots of classes interdependent then finding the right one to delete will be problem. better to configure proguard – Raghunandan Apr 09 '13 at 07:18
  • yes. all you need to do is configure properly. check the 2nd link in the answer – Raghunandan Apr 09 '13 at 07:22