Android gradle google-services build failed "Duplicate Entry" - android

Edit:
I changed this line:
compile 'com.google.android.gms:play-services-analytics:8.1.0'
To:
compile 'com.google.android.gms:play-services-analytics:8.4.0'
I changed the classpath to be:
classpath 'com.google.gms:google-services:2.0.0-alpha7'
And updated the gradle version to 2.10 to fix the other issue I mentioned. Now I am having this error whenever I build:
Error:Execution failed for task ':app:processDebugGoogleServices'.
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 8.3.0.
--------------------------------------------------------------------------------------------------------------------------
Original Question
Out of nothing, my app wouldn't successfully build. I tried updating google-services and still I am getting an error.
What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/ads/identifier/AdvertisingIdClient$Info.class
I am also getting an error in my gradle, at the line:
compile 'com.google.android.gms:play-services-analytics:8.1.0'
saying that some google libraries are of version 8.4.0 and some in 8.1.0. I tried upgrading the google library to 8.4.0. The gradle won't build and gives me the following error:
Warning:Gradle version 2.10 is required. Current version is 2.8. If
using the gradle wrapper, try editing the distributionUrl in
/Users/essam/Desktop/Apptuto/gradle/wrapper/gradle-wrapper.properties
to gradle-2.10-all.zip
Here is my gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:1.4.0-beta3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
The app gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: "findbugs"
apply plugin: "pmd"
android {
android {
useLibrary 'org.apache.http.legacy'
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "my package name is written here"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.1"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
}
debug {
debuggable true
}
}
}
findbugs {
ignoreFailures = true
toolVersion = "2.0.1"
reportsDir = file("$project.buildDir/reports/findbugs")
effort = "max"
}
pmd {
ignoreFailures = true
reportsDir = file("$project.buildDir/reports/pmd")
ruleSets = [
"basic",
"braces"
]
}
dependencies {
compile('com.mikepenz:materialdrawer:4.3.7#aar') {
transitive = true
}
repositories {
mavenCentral()
maven {
url 'https://dl.bintray.com/intercom/intercom-maven'
}
}
compile('io.intercom.android:intercom-sdk:1.+#aar') {
transitive = true
}
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.google.android.gms:play-services-analytics:8.1.0'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.apache.httpcomponents:httpmime:4.2.3'
compile 'com.mixpanel.android:mixpanel-android:4.6.4'
compile 'info.hoang8f:android-segmented:1.0.6'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:23.1.1'
}

it's a rule that all google play services should be using the same version
while I can see only one line using 8.1.0, you might have another library using 8.4.0 , just edit yours to 8.4.0 instead of 8.1.0
now for the other error, I don't know, it didn't happen to me I copied your exact gradle and it compiled
if it kept appearing, try removing your second line:
apply plugin: 'com.google.gms.google-services'
why are you using this any way?

Related

Updating firebase library to 16.0.0 raises google play services dependency issue

My project was working fine until one day, because of no reason (I didn't change anything), gradle started giving this strange error:
Program type already present: com.google.android.gms.internal.measurement.zzabo
At the time of this error my project level gradle was like this:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
// Alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
maven { url 'https://plugins.gradle.org/m2/'}
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.0'
classpath 'io.fabric.tools:gradle:1.25.3'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.8.1'
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://dl.bintray.com/sayyam/maven'
}
maven {
url "https://jitpack.io"
}
maven {
url 'https://maven.google.com'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and this was my app level gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'io.fabric'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
dexOptions {
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
defaultConfig {
applicationId "com.example"
deviceCheck
minSdkVersion 17
targetSdkVersion 27
versionCode 8
versionName "1.0"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.firebase:firebase-invites:15.0.1'
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.2'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
implementation 'com.google.maps.android:android-maps-utils:0.5'
implementation 'com.android.support:support-v13:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
.....other dependencies.....
testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
I searched and found this answer on stackoverflow. Which says that this issue might be related to firebase dependency version and google-services plugin. So i updated google-services plugin version to 4.0.0 and firebase to its latest version 16.0.0. And as one could expect from gradle, it gave another error which seems to be related to firebase version 16.0.0.
Whenever i change firebase version to 16.0.0, apparently it tries to automatically upgrade google play services dependencies to 16.0.0 too. Which doesn't EVEN exist! It raises following gradle error:
Failed to resolve: com.google.android.gms:play-services-maps:16.0.0
Failed to resolve: com.google.android.gms:play-services-location:16.0.0
Failed to resolve: com.google.android.gms:play-services-places:16.0.0
Failed to resolve: com.google.android.gms:play-services-gcm:16.0.0
Failed to resolve: com.google.android.gms:play-services-base:16.0.0
Failed to resolve: com.google.android.gms:play-services-basement:16.0.0
Failed to resolve: com.google.android.gms:play-services-measurement-base:16.0.0
Failed to resolve: com.google.android.gms:play-services-tasks:16.0.0
Failed to resolve: com.google.android.gms:play-services-stats:16.0.0
Failed to resolve: com.google.android.gms:play-services-ads-identifier:16.0.0
I have tried to force version of gms libraries using resolutionStrategy but to no avail. What should i do? What am I doing wrong?
NOTE: I didn't change play services libraries version explicitly, gradle seems to do it because of firebase.
EDIT: This problem can be solved by the solution given in this question, but still its not duplicate because in my case onesignal plugin was updating only gms libraries version and not firebase version. So anybody facing this problem won't search for keywords used in this question.
I believe you have run into the same issues as the poster of https://stackoverflow.com/a/50516114/7070704 with the same resolution.
Basically, the com.onesignal.androidsdk.onesignal-gradle-plugin plugin is forcing an uplift on your dependencies onto something which does not exist.

Can't upload Android Kotlin Project to Fabric Beta with gradle

I created a project with Android Studio Preview 3.0 (Canary 2) to start Kotlin development. I used the Android Studio Fabric Plugin to setup Fabric for my project.
But when I want to upload a beta version of my app to Fabric Beta (Crashlytics) with the following command
./gradlew crashlyticsUploadDistributionDebug
I receive the following error:
Configuration 'compile' in project ':app' is deprecated. Use
'implementation' instead. Configuration 'testCompile' in project
':app' is deprecated. Use 'testImplementation' instead. The
Task.leftShift(Closure) method has been deprecated and is scheduled to
be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
registerResGeneratingTask is deprecated, use
registerGeneratedFolders(FileCollection) registerResGeneratingTask is
deprecated, use registerGeneratedFolders(FileCollection)
:app:crashlyticsUploadDistributionDebug FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:crashlyticsUploadDistributionDebug'.
Not valid.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED in 1s 1 actionable task: 1 executed, 0 avoided (0%)
I do not have any idea, what "Not valid" means.
This is my root build.gradle:
buildscript {
ext.kotlin_version = '1.1.2-4'
repositories {
maven { url 'https://maven.google.com' }
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'org.ajoberstar:grgit:1.9.0'
classpath 'io.fabric.tools:gradle:1.22.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
ext {
supportLibVersion = "25.3.1"
buildVersion = "25.0.3"
daggerVersion = "2.9"
rxJavaVersion = "2.1.0"
rxAndroidVersion = "2.0.1"
countGitCommits = { ->
git = Grgit.open()
def commitCount = git.log(includes: ['HEAD']).size()
println("INFO: Number of commits $commitCount")
return commitCount
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And this is the app build.gradle
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 25
buildToolsVersion "$buildVersion"
defaultConfig {
applicationId "com.kotlin.sample"
minSdkVersion 21
targetSdkVersion 25
def numberOfCommits = countGitCommits()
versionCode 1000 + numberOfCommits
versionName "0.1.$numberOfCommits"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile files('libs/API_ADK.jar')
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "com.android.support:appcompat-v7:$supportLibVersion"
compile "com.android.support:support-v4:$supportLibVersion"
compile "com.android.support:design:$supportLibVersion"
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'io.reactivex.rxjava2:rxkotlin:2.0.3'
compile "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
compile "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
compile 'com.jakewharton.timber:timber:4.5.1'
compile "com.google.dagger:dagger:$daggerVersion"
// Needed for #Generated annotation (missing in Java <= 1.6; therefore, Android)
compile 'javax.annotation:jsr250-api:1.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
testCompile 'junit:junit:4.12'
}
The fabric.properties file with the apiSecret is also placed in the project.
Edit:
A manual upload of the APK to Fabric Beta works.
I just want to point to the comment from Mike Bonnell as it answers this question:
Our command line tools are not compatible with the Alpha version of Gradle 3. We're looking into the changes that have come with the alpha versions, but we test against betas and stable versions of the releases.
Edit 2017/08/25
Tried with Android Studio 3.0 Beta 3 and the corresponding android gradle plugin. The gradle task crashlyticsUploadDistributionDebug seems to work again.

Gradle sync failed: Failed to update Android plugin to version '2.0.0'

I've recently updated Android Studio to 2.0. I am working on a part time course and I have to work on a project provided. When gradle tried to build the project a dialog popped up asking me to update the android studio gradle plugin. When I clicked update, I got an error which is in the title.
My gradle files are as follows:
Gradle Wrapper:
#Wed Sep 30 11:56:02 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2-bin.zip
Module Gradle:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.sam_chordas.stockhawk"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
apt 'net.simonvt.schematic:schematic-compiler:0.6.3'
compile 'net.simonvt.schematic:schematic:0.6.3'
compile 'com.melnykov:floatingactionbutton:1.2.0'
compile 'com.android.support:design:23.1.1'
compile('com.github.afollestad.material-dialogs:core:0.8.5.7#aar') {
transitive = true
}
}
Project Gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2'
classpath 'com.google.gms:google-services:1.4.0-beta3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
I'm unable to work on the project as I'm unable to build it. If anyone has had any issues like this and fixed it I'd really appreciate some help as I'm wasting a lot of time. I should mention that this is a windows 7 machine.
Thanks
Since you're using compileSdkVersion = 23, you need to use support libraries of version starting with 23 as well. That's com.android.support:design:23.3.0 in your case. It may be unrelated to the issue at hand but it will save you runtime errors later so fix it ASAP.
Your gradle distribution is too old for Android build plugin. Use this in your gradle/gradle-wrapper.properties file:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Newest build tools are "23.0.2". Update the value in your modules' build.gradle files.
Google Play services plugin must be of the same version as Android build plugin. At least it had to be in beta stages and I imagine the major version has to correspond in any case. That's in your project build.gradle:
classpath 'com.google.gms:google-services:2.0.0'
While at it the Android build plugin is missing in there altogether!
classpath 'com.android.tools.build:gradle:2.0.0'
Optional
Your apt plugin is old. Newest version is 1.8.
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
Your OkHttp library is old. Newest versions are 2.7.5 or 3.2.0.
compile 'com.squareup.okhttp:okhttp:2.7.5'

Error adding dependency to project

I'm trying to add a library as a dependency but it keeps giving me this error:
Class android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat.AccessibilityServiceInfoIcsImpl
has already been added to output. Please remove duplicate copies.
Execution failed for task ':BrooklynTech:dexDebug'.
Could not call IncrementalTask.taskAction() on task ':BrooklynTech:dexDebug'
Here is my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
}
dependencies {
compile files('libs/Simple-Rss2-Android.jar')
compile 'org.jsoup:jsoup:1.7.3'
compile 'uk.co.androidalliance:edgeeffectoverride:1.0.1'
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
compile project(':libraries:calendar-card')
compile 'com.twotoasters.jazzylistview:library:1.0.0' }
the dependency I added was for jazzylistview - https://github.com/twotoasters/JazzyListView
How can I fix the error?
More than one of your dependencies is including the classes from the v4 support library; you'll need to track it down. You ought to be able to open up the jar files from the project viewer and find the culprit.
Ideally none of your dependencies ought to be bundling the support library; it's the responsibility of your app's build to make sure that gets finally linked in.
Not sure, but could you try the following snippet. Maybe the transitive libs are causing the trouble
dependencies{
...
compile ('com.twotoasters.jazzylistview:library:1.0.0'){
transitive = false
}
}
cheers,
René

Gradle error "Attribute "xxx" has already been defined" in Android Studio

I created a project in Android Studio and added a few dependencies using Maven Central and when I try to compile, I run into this type of errors:
Error:Gradle: Attribute "titleTextStyle" has already been defined
Error:Gradle: Attribute "subtitleTextStyle" has already been defined
[...]
And so on... Here is my build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 18
}
}
dependencies {
// Support Libraries
compile 'com.android.support:support-v4:18.0.0'
compile 'com.android.support:appcompat-v7:18.0.0'
compile 'com.android.support:support-v13:18.0.0'
// Third-Party Librairies
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'ch.acra:acra:4.5.0'
}
Sadly the Make Console doesn't speak as much as Eclipse's Console, so I have no idea of the problem's origin.
Does anyone have an idea of what causes these compile errors?
You should remove this line in your dependencies :
compile 'com.android.support:appcompat-v7:18.0.0'
The last version of Google Play Services now uses appcompat-v7, so u can't use it with actionbarsherlock. You have to use only appcompat-v7 or the previous version of play services:
compile 'com.google.android.gms:play-services:7.0.0'

Categories

Resources