5

Google's instructions for using the Play Service API (for example) say:

Copy the /extras/google/google_play_services/libproject/google-play-services_lib library project into the source tree where you maintain your Android app projects.

Note: You should be referencing a copy of the library that you copied to your source tree—you should not reference the library from the Android SDK directory.

This seems ugly to me - why not reference it from the SDK directory? Is there some technical reason for this? Or is it so that you have explicit control over when it gets upgraded?

Community
  • 1
  • 1
poolie
  • 9,289
  • 1
  • 47
  • 74

2 Answers2

4

I'd like to point out that this is entirely a limitation of Eclipse, and it is indeed ugly.

The problem is that this library contains resources in addition to source code. Eclipse can only deal with libraries packaged as jar files, which, for the purposes of Android development, cannot contain resources.

So, in order for the library's resource to be compiled into the application, the library's source code, with the resources, must be added to your project.

If you move your build to Maven, and use an IDE that 'understands' Maven, then you can compile a library that contains resources as an 'apklib', and treat it as an external library, in a manner similar to a jar file.

The new Gradle-based build system is built on Maven primitives, but uses a different format for this, 'aar'. Hopefully, it will eventually also support apklib so that Maven builds and Gradle builds can inter-operate.

I just went through the exercise of converting an Android application to a Maven build, including the use of some apklibs. I can tell you that Eclipse with the m2eclipse plugin does not handle apklibs properly. Both IntelliJ and the new Google Android Studio (based on IntelliJ) do handle apklibs with no issues.

GreyBeardedGeek
  • 29,460
  • 2
  • 47
  • 67
0

It's not about "Play Services Library" specifically. Just like any other libraries that the project makes use of, this library should be referenced from project's source tree.

In this case the external library is in the Android SDK directory and referencing from there is not a good practice too. So yes, it can be called "a technical reason".

Used libraries (Play Services library in this case) shouldn't be referenced from anywhere other than the project's source tree.

faradaj
  • 3,629
  • 1
  • 22
  • 21
  • What _is_ the technical reason? Why do you think it's not a good practice or this shouldn't be done? – poolie May 28 '13 at 03:20