Android, one library with old google play service conflicts with google maps - android

I'm using asne google plus library for my project. It uses older version of google play service.
When I add Google maps with newer version, gradle build fails with this message:
Error:Execution failed for task ':app:processDebugResources'.
Error: more than one library with package name 'com.google.android.gms'
My dependencies in my app.gradle:
compile 'com.github.asne:asne-googleplus:0.3.3'
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'
When I make asne like this:
compile ('com.github.asne:asne-googleplus:0.3.3') {
transitive = true
}
This lib becomes invisible and I can't call its methods.
How to resolve this conflict?

I suggests that you use the entire dependency
compile 'com.google.android.gms:play-services:8.3.0'
and not split it into parts like play-services-location:8.3.0 and play-services-maps:8.3.0. This link provides a detailed explanation why.

You could try to just exclude the google dependencies of the library:
compile ('com.github.asne:asne-googleplus:0.3.3') {
exclude group: 'com.google.android.gms'
}

Related

Error comes while adding Admob in android studio [duplicate]

I am not sure what this error means.
Execution failed for task ':excelSior:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/util/TimeUtils.class
I am currently using android-support-v4.jar for my libraries
dependencies {
compile project(':addThisSDK')
compile project(':centeredContentButton')
compile project(':googleplayservices_lib')
compile files('libs/adxtag2.4.6.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/aws-android-sdk-1.7.1.1-debug.jar')
compile files('libs/commons-lang-2.6.jar')
compile files('libs/crittercism_v4_4_0_sdkonly.jar')
compile files('libs/dd-plist.jar')
compile files('libs/FiksuAndroidSDK_4.1.1.jar')
compile files('libs/iqengines-sdk-barcode.jar')
compile files('libs/irEventTracker-1.2.jar')
compile files('libs/jolt-core-0.0.7.jar')
compile files('libs/json-utils-0.0.7.jar')
compile files('libs/jsoup-1.7.2.jar')
compile files('libs/kooaba-api-v4-java.jar')
compile 'com.android.support:multidex:1.0.0'
}
Error does not show up during gradle sync. Just when I try to run the application
What could be the problem?
You've probably fixed this by now but just so this doesn't stay unanswered,
Try adding this to your build.gradle:
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
You need to check that you have inserted v4 library and compile library? You must not repeat library in your app or your dependence program.
delete the repeat library so that just one V4 remains.
in your app dir build.gradle file
add this command:
android{
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.android.support', module: 'support-annotations'
}
}
it works for me! You can try it!
I also came across this kind issue when re import old eclipse project. It occurred some old dependency as jar file in the project.
just remove
compile fileTree(dir: 'libs', include: '*.jar')
in gradle file
and add dependency in the gradle file.
It works for me ..
In my case the mentioned "duplicate entry" error arised after settingmultiDexEnable=true in the build.gradle.
In order to fully resolve the error first of all have a look at Configure Apps with Over 64K Methods (espescially "Configuring Your App for Multidex with Gradle").
Furthermore search for occurences of the class that causes the "duplicate entry" error using ctrl+n in Android Studio. Determine the module and dependency that contains the duplicate and exclude it from build, e.g.:
compile ('org.roboguice:roboguice:2.0') {
exclude module: 'support-v4'
}
I had to try multiple module labels till it worked. Excluding "support-v4" solves issues related to "java.util.zip.ZipException: duplicate entry: android/support/v4/*"
My understanding is that there are duplicate references to the same API (Likely different version numbers). It should be reasonably easy to debug when building from the command line.
Try ./gradlew yourBuildVariantName --debug from the command line.
The offending item will be the first failure. An example might look like:
14:32:29.171 [INFO] [org.gradle.api.Task] INPUT: /Users/mydir/Documents/androidApp/BaseApp/build/intermediates/exploded-aar/theOffendingAAR/libs/google-play-services.jar
14:32:29.171 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':BaseApp:packageAllyourBuildVariantNameClassesForMultiDex'
14:32:29.172 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :BaseApp:packageAllyourBuildVariantNameClassesForMultiDex FAILED'
In the case above, the aar file that I'd included in my libs directory (theOffendingAAR) included the Google Play Services jar (yes the whole thing. yes I know.) file whilst my BaseApp build file utilised location services:
compile 'com.google.android.gms:play-services-location:6.5.87'
You can safely remove the offending item from your build file(s), clean and rebuild (repeat if necessary).
check your dependencies versions, you must have compatible versions put attention specially to com.google packages, must have same version like:
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-maps:8.3.0'
Both are 8.3.0, if you have another version compilation will throw that exception.
Simple Remove Your Jar file from dependencies gardle.project as v7
and run your project
For Expose.class Error i.e
java.util.zip.ZipException: duplicate entry: com/google/gson/annotations/Expose.class
use the below code
configurations {
all*.exclude module: 'gson'
}
find out the lib depends on the support v4, and exclude it.
code in build.gradle is like this:
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
// http://stackoverflow.com/a/30931887/5210
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
}
In my situation, the lib 'espresso' has a jar called support-v4 and in my project 'app' have the same support-v4, exclude the support-v4 when import espresso.
PS: it seems compile project can not work with the exclude
This is because you have added a library and given its dependency on a module more than once.
In my case, I had added a library as a module and as a gradle dependency both.
Removing one source of adding library (I removed gradle dependency) solved my problem.
For Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug' com.android.build.api.transform.TransformException java.util.zip.ZipException duplicate entry com/google/gson/annotations/Expose.class
Here is what I did:
1) Delete the gson-2.5.jar file.
2) configurations { all*.exclude module: 'gson-2.5' }
I have faced this issue as i have manually copied the jar in libs as well as mentioned the dependency in gradle file. You also check in your project structure, whether the same jar file is copied in any other folder like libs or in project folder.
I had the same problem after upgrading the android SDK. I was able to run the application in the buildToolsVersion '23.0.1', I got the same error when I changed to buildToolsVersion '24.0.3'
I resolved the problem by updating my java version from 1.7 to 1.8 with compileSdkVersion 24
This problem cost me one whole day. I finally downgraded the firebase-ui library version from 2.0.0 to 1.2.0 and added the following code inside Project level build.gradle file:
allprojects {
repositories {
jcenter()
// Add the following code to your project level build.gradle
maven {
url 'https://maven.fabric.io/public'
}
}
}
I also have the issue because of i have compile 'com.android.support:appcompat-v7:24.0.0-alpha1' but i added recyclerview liberary compile 'com.android.support:recyclerview-v7:24.0.2'..i changed the version as same as compat like (24.0.2 intead of 24.0.0).
i got the answer..may be it will help for someone.
In my case the mentioned "duplicate entry" error arised after settingmultiDexEnable=true in the build.gradle.
and exact error which i was getting was below :
Error:Execution failed for task
':android:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
com/google/android/gms/internal/zzqx.class
So first thing I search for class which causes "duplicate entry" error using ctrl+n in Android Studio and searched for com/google/android/gms/internal/zzqx.class and then it was showing 2 entries for gms class with one version 8.4.0 and 1 with version 11.6.0 .
To fix it i made both to use 11.6.0 and it was fixed example
earlier
compile "com.google.android.gms:play-services-games:11.6.0"
compile "com.google.android.gms:play-services-auth:8.4.0"
compile "com.google.android.gms:play-services-ads:11.6.0"
After
compile "com.google.android.gms:play-services-games:11.6.0"
compile "com.google.android.gms:play-services-auth:11.6.0"
compile "com.google.android.gms:play-services-ads:11.6.0"
Rebuilding Fixed .
In my case exact error was below
':android:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzqx.class
I was using another version of google apis i.e. in one modules gradle file
if (!project.hasProperty('gms_library_version')) {
ext.gms_library_version = '8.6.0'
}
however in other modules version 11.6.0 as below
compile "com.google.android.gms:play-services-ads:11.6.0"
compile "com.google.android.gms:play-services-games:11.6.0"
compile "com.google.android.gms:play-services-auth:11.6.0"
However to find this i did a ctrl + n in android studio and entered class name zzqx.class and then it displayed 2 jar files being pulled for this class and then i understood that somewhere i am using version 8.6.0 . On changing 8.6.0 to 11.6.0 and rebuilding the project the issue was fixed .
Hope this helps .
More on this here
https://www.versionpb.com/tutorials/step-step-tutorials-libgdx-basic-setup-libgdx/implementing-google-play-services-leaderboards-in-libgdx/
For me something similar happened when I had accidently added
apply plugin: 'kotlin-android'
to my android library module. Removing the line fixes the issue.
I tried all the above solutions but not working for me. I tried update libraries by goto project structure > app. And it works for me! Hope this answer helpful to someone.
Try this:
android {
configurations {
all*.exclude module: 'PhotoView' //去除重复依赖库
}
}

Is there a way to avoid including Google Ads libraries from gradle? [duplicate]

Google has put a new option on their Pricing and Distribution page of their Google Play Developer Console that requires publishers to declare if they have ads or not. Our app does not have ads, yet we are being flagged as having the AdMob SDK.
We detected Ad SDKs in one or more of your active APKs:
version: XXXXX, sdk: AdMob
If your app is serving ads, please change your ads declaration to
'Yes'. Failure to accurately declare the presence of ads is a policy
violation and may result in your app's removal from Google Play. You
can visit our Help Center to learn more.
We don't have AdMob, as far as I can tell from our Gradle file:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'me.dm7.barcodescanner:zxing:1.7.2'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
}
What might be causing that dependency to show up? How can I get rid of it?
You can run gradlew -q dependencies app:dependencies to see a the dependencies (including all transitive dependencies) for each of your configurations.
You can also specify a single configuration, such as with --configuration releaseCompile
In your case, you will find that Google Play Services includes a transitive dependency on AdMob.
You can mitigate this by using only individual components of Play Services (such as play-services-location) instead of the entirety of Play Services. However, you may find that one of the individual components you use still relies on AdMob. For example, version 8.1.0 of play-services-analytics has a transitive dependency on play-services-ads, which is the AdMob SDK.
I have follow below steps and It removes the notification
First check that which gradle package contains "play-services-ads-identifier" package depency. You can add update those packages like below:
implementation('com.google.firebase:firebase-analytics') {
exclude module: "play-services-ads-identifier"
exclude module: "play-services-measurement"
exclude module: "play-services-measurement-sdk"
}
Second, If you have analytics package in your gradle which contains ads then you have to follow these steps OR you can skip it. You can add below tag in your app's manifest's tag.
<meta-data android:name="google_analytics_adid_collection_enabled"
android:value="false" />
Hope it will help you as well.
From the Google Play Support Chat I was addressed to say "No" in Google Play Console, despite the detection.
I have solved with these steps
First find list of android dependencies which contain play-services-ads-identifier. Through Android Studio Gradle Panel
Click on Gradle tab on the right side
Task will print all dependencies including internal packages example included in below image
After that exclude play-services-ads-identifier. in my case I have two dependencies which contain play-services-ads.
First dependency:
implementation('com.google.firebase:firebase-core:19.0.2') {
exclude module: "play-services-ads-identifier"
exclude module: "play-services-measurement"
exclude module: "play-services-measurement-sdk"
}
Second dependency:
implementation('com.google.firebase:firebase-analytics') {
exclude module: "play-services-ads-identifier"
exclude module: "play-services-measurement"
exclude module: "play-services-measurement-sdk"
}
It solved my issues.
According to the note in Google play console, you can just leave the answer as "NO"

:app:dexDebug on adding libGoogleAnalyticsServices

On trying to run my project, I get the following error:
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_67\bin\java.exe'' finished with non-zero exit value 2
I am adding the google analytics jar file from here. The issue goes away if I remove this line compile files('libs/libGoogleAnalyticsServices.jar') from the dependencies in the build.gradle
Is 1libGoogleAnalyticsServices.jar` interfering with something else I have in my dependencies?
dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.1'
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/newrelic.android.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.google.android.gms:play-services:7.5.0'
compile('de.keyboardsurfer.android.widget:crouton:1.8.5#aar') {
}
compile ("com.doomonafireball.betterpickers:library:1.6.0")
compile ("com.doomonafireball.betterpickers:library:1.6.0") {
transitive = true
exclude group: 'com.android.support', module: 'support-v4'
}
compile project(':circularImageView')
}
This error could also indicate that you've hit the 65k method limit in Android.
If this is the case, then you have 3 options
Selectively use the parts of the play-services library that are required. This library itself will bring you close to the limit.
Let Progaurd minimize your application.
Use Multi-dex to split your dex index.
These guides will help you to achieve the options above;
http://googleadsdeveloper.blogspot.ie/2015/01/reducing-google-play-services-impact-on.html
https://developer.android.com/tools/building/multidex.html
Per the page you linked:
Important: This document describes a legacy version of the SDK. New users should use the latest SDK.
As the latest SDK is included in your 'com.google.android.gms:play-services:7.5.0' dependency, the two are overlapping and causing issues when building your application. You should instead follow the getting started guide for Google Analytics v4

gradle dependency error in android

In the following build.gradle, I added the configuration section to avoid double inclusion of support libraries. Support libraries are used in the main project and in the dependent projects like facebook sdk. Without the configuration section, I get "UNEXPECTED TOP-LEVEL EXCEPTION". Adding that configuration makes the error go away and the app all works fine.
Now, I'm trying to add RecyclerView to my app and I get RecyclerView class not found while inflating the recyclerview (although it builds ok). If I remove the facebook SDK and configuration section, the recyclerview works just fine.
Question: What changes can I make to the build.gradle to make the facebook SDK work and RecyclerView work? In other words, why is the config section excluding v7 when it is only supposed to exclude v4?
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:+'
compile 'com.android.support:support-v13:+'
compile 'com.android.support:cardview-v7:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.google.android.gms:play-services:4.4.52'
compile project(':facebook-3.15')
compile project(':parse-1.5.1')
compile project(':viewpagerindicator-2.4.1')
}
configurations {
// to avoid double inclusion of support libraries
all*.exclude group: 'com.android.support', module: 'support-v4'
}
If you're having a dependency conflict with the v4 support library, you can just exclude it from one of the libraries via the gradle script:
compile ('com.android.support:recyclerview-v7:+') {
exclude module: 'support-v4'
}
I fixed that adding:
compile ('com.facebook.android:facebook-android-sdk:3.22.0#aar'){
exclude module: 'support-v4'
}
Found a solution to this:
Removed the config section in the build.gradle that excludes support-v4
It turns out that .aar files are basically a zip, so removed the support-v4 jar from the dependency .aar library (using 7-zip).
And now, I don't get the top-level exception and at the same time able to use recyclerview-v7.
If you are using dependency projects instead of .aar files, try removing the support-v4.jar files in the dependency projects before compiling.
Shouldn't the gradle build tool be intelligent enough to exclude the duplicate packages rather than having the users go thru this kind of workarounds and headaches?

Gradle conflict play-services:4.0.30 with GoogleAdMobAdsSdk

I am using Android Studio 0.3.4 with Gradle build.
I get this error message when I build my project:
Gradle: Execution failed for task > Could not call IncrementalTask.taskAction()
This is because google play services and GoogleAdMobAdsSdk-6.4.1 are conflictiing. My build.gradle has this entry:
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v13:13.0.0'
compile 'com.google.android.gms:play-services:4.0.30'
compile files('libs/GoogleAdMobAdsSdk-6.4.1.jar')
When I remove GoogleAdMobAdsSdk then it builds fine. How can I solve this problem?
this is the error:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/google/ads/AdRequest$Err
orCode;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:12
3)
thanks
Google Mobile Ads SDK for Android is now included as part of Google Play services 4.0. More info http://googleadsdeveloper.blogspot.com.es/2013/10/upgrade-to-new-google-mobile-ads-sdk.html
As you say, your build.gradle should be without Google Mobile Ads SDK library:
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v13:13.0.0'
compile 'com.google.android.gms:play-services:4.0.30'
}
But Google Mobile Ads SDK doesn't support DoubleClick For Publishers, Ad Exchange or Search Ads for Mobile Apps yet. They say that soon will be supported. If this is your case, use the previous version of Play Services combined with Google Mobile Ads SDK:
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v13:13.0.0'
compile 'com.google.android.gms:play-services:3.2.65'
compile files('libs/GoogleAdMobAdsSdk-6.4.1.jar')
}

Categories

Resources