I am try to use the new android multidex support for a project. I have some problem with this exception:
Error:Execution failed for task ':shineV3:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: com/google/android/gms/analytics/internal/Command$1.class
about the problem. I use 2 different jar package as dependency, and some class will be duplicated in classes.dex because both jars contains they. any idea?
thanks in Advance
For those that are coming into this, I figured out why this was happening. For me it was that I was compiling the Google Analytics V2 jar as well as the full play services. Google allows you to break down what play services you really need for you app and compile those individual items. Check them out here. I excluded the Google Play Analytics which is on V4 right now and it worked
If you are integrating Google Analytics V2 and Google play services in your app, then you need to do the following in your gradle file:
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
compile files('libs/libGoogleAnalyticsServices.jar')
}
It worked for me. Hope it will work for others too. :)
adding this to your grdale compile "com.google.android.gms:play-services:7.5.+" means adding all play services including analytics, maps, vcm .. etc. you can add
as guides mentions:
In versions of Google Play services prior to 6.5, you had to compile
the entire package of APIs into your app. In some cases, doing so made
it more difficult to keep the number of methods in your app (including
framework APIs, library methods, and your own code) under the 65,536
limit.
From version 6.5, you can instead selectively compile Google Play
service APIs into your app. For example, to include only the Google
Fit and Android Wear APIs, replace the following line in your
build.gradle file:
compile 'com.google.android.gms:play-services:7.5.0' with these lines:
compile 'com.google.android.gms:play-services-fitness:7.5.0' compile
'com.google.android.gms:play-services-wearable:7.5.0'
https://developers.google.com/android/guides/setup
Related
I used google map in android version new 2.2 and I get same messages error in messages gradle build.
and event log
I don't know where is the problem. Can anyone help me?
Your project is exceeding 65536 methods. This is likely because you are importing the whole Google Play Services library doing
dependencies {
compile 'com.google.android.gms:play-services:9.6.1'
}
You can import only the modules that you are going to use. If you are only using Google Maps you can change your Play Services dependency to be
dependencies {
compile 'com.google.android.gms:play-services-maps:9.6.1'
}
I implemented new module for an application, using a 3rd party library. In this library, they used com.google.android.gms:play-services-base:9.0.2, and in the original application, they used com.google.android.gms:play-services:4.3.23. So there was a conflict and I can't sync gradle at all. Is there anyway to fix this conflict ? update google play service of the original project is out of question, because the amount of work would be tremendous.
please reefer this ref: https://developers.google.com/android/guides/setup
and add google play service in your gradle
From version 6.5, you can instead selectively compile Google Play service APIs into your app.
try to do something like this
compile ('com.android.support:recyclerview-v7:22.2.0') {
exclude module: 'support-v4'
}
In the gradle dependencies I have included the following
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.google.android.gms:play-services-ads:8.3.0'
But it gives the following error.
Error:Execution failed for task ':app:processDebugResources'.
Error: more than one library with package name 'com.google.android.gms'
You can temporarily disable this error with android.enforceUniquePackageName=false
However, this is temporary and will be enforced in 1.0
How can it be fixed
The first line of compile 'com.google.android.gms:play-services:7.5.0' already includes the ads API (source):
Selectively compiling APIs into your executable
In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.
From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:
compile 'com.google.android.gms:play-services:8.3.0'
with these lines:
compile 'com.google.android.gms:play-services-fitness:8.3.0'
compile 'com.google.android.gms:play-services-wearable:8.3.0'
As described it's probably a better idea to only include the APIs you need. The link above provides a table of available APIs.
I am trying to add google play service to my project but it gives me error when I try to edit build (Gradle).
How can I fix it?
In your configuration there some issues.
You are using the wrong build.gradle file.
It is your top-level file.
You should add this line in your app/build.gradle
There is a typo. You are missing the ' at the end of the line compile.
Use an updated version.
For example use:
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.google.android.gms:play-services:8.1.0'
}
Finally refer this official doc for more info.
In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.
For example if you need to make only your app aware of location updates add
compile 'com.google.android.gms:play-services-location:8.1.0' only in gradle or if you need only map choose compile 'com.google.android.gms:play-services-maps:8.1.0'.
Please replace
compile 'com.google.android.gms:play-services:3.1.36
with
compile 'com.google.android.gms:play-services:3.1.36'
One thing you can try is Right Click on app open module settings on Dependencies Tab click '+' icon and add there 'com.google.android.gms:play-services:8.1.0' and click search icon and add that dependency,
So i don't want to elaborate what you had done wrong as my colleagues figured it out.I like to say, while playing with Google Play Service
Selectively compile APIs into your executable
In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.
For example if you need to make only your app aware of location
updates add compile
'com.google.android.gms:play-services-location:8.1.0' only in gradle
or if you need only map choose compile
'com.google.android.gms:play-services-maps:8.1.0'.
Thank you.
Visit for more.
I would like to include libraries of different versions in my Google Project.
For example, I'm using
compile "com.google.android.gms:play-services-base:6.5.87"
compile "com.google.android.gms:play-services-location:6.5.87"
compile "com.google.android.gms:play-services-maps:6.5.87"
I would like to include
compile 'com.google.android.gms:play-services-identity:7.5.0'
as well, but I get compiler errors that analytics and gcm classes can't be found.
Is the only solution to upgrade all the libs to 7.5.0? Is it possible to use different versions of Google Play Services libs? I would like to know what are all the different solutions.
The list of selective APIs includes all of the available APIs. For GCM, you'd need the play-services-gcm library included.
However, all APIs you include must be from the same version of Google Play services - all must be 7.5.0 or all 6.5.87.