I'm working on a map library and I'm using Google-Play-Services. So Far so good. Problem is this:
- I include Google-Play-Services library project in my map library (using: properties -> android -> add library). Tested it using a client within the library (Unchcecking the library checkbox and launching a mainActivity) and works fine!
When I include my map library in a sample client project, this client project won't have access to Google Play Services, why? If I include Google play services in the client project, I get:
[2013-07-18 08:40:04 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/google/android/gms/R$attr;
[2013-07-18 08:40:04 - maps-sample-android] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/google/android/gms/R$attr;
Android won´t let include Google Play Services on my own or use it from my library project, is there any way to solve this?
[2013-07-18 08:40:04 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/google/android/gms/R$attr;
[2013-07-18 08:40:04 - maps-sample-android] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/google/android/gms/R$attr;
These errors suggest that you have 2 different jar files which are both trying to declare the same variable. Perhaps you have 2 different versions of the google-play-services?
In your library project properties in the java build path (order and export tab) make sure that the Android dependancies box is ticked.
This will allow the library project to export the google play library with it.
You will then not need to add a reference to google play in the client project.
来源:https://stackoverflow.com/questions/17724808/adding-google-play-services-to-library-project