Failed to resolve: com.google.android.material:material:1.0.0-alpha1 - android

So I'm following the official documentation to add the Material Components library to my project https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md
But it throws me the following error
"Failed to resolve: com.google.android.material:material:1.0.0-alpha1"
I've tried installing the repository and sync project that Android Studio suggest to no avail.
My project config
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and the app config
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "mlluell.eftremp"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-auth:15.1.0'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.firebase:firebase-database:15.0.1'
implementation 'com.google.firebase:firebase-storage:15.0.2'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.google.android.material:material:1.0.0-alpha1'
//imatges recyclerview
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
// FirebaseUI for Firebase Realtime Database
implementation 'com.firebaseui:firebase-ui-database:3.3.0'
// FirebaseUI for Firebase Auth
implementation 'com.firebaseui:firebase-ui-auth:3.3.0'
// FirebaseUI for Cloud Storage
implementation 'com.firebaseui:firebase-ui-storage:3.3.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'

Instead of:
implementation 'com.google.android.material:material:1.1.0'
Use:
implementation group: 'com.google.android.material', name: 'material', version: '1.1.0-alpha05'
And it works.

Thought I'd share what fixed this for me now that I|O has started.
I had about the same initial setup as you. To get it working I had to change the following:
compileSdkVersion to 'android-P'
Support Libraries to '28.0.0-alpha1'
include api 'com.android.support:design:28.0.0-alpha1' in the dependencies block.
SDK Platform update - Android P Preview (latest)
targetSdkVersion 'P'
I then did the ritualistic 'Invalidate Caches / Restart' and rebuilt the project for good measure.

FOR ANDROIDX USERS:
You can implement as follows:
AndroidX:
implementation 'com.google.android.material:material:1.0.0'
Old build artifact users can use the following implementation:
implementation 'com.android.support:design:[Enter Design library version here]'
Use that version without square brackets.
You can find design library version via this link : https://mvnrepository.com/artifact/com.android.support/design/28.0.0

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
androidTestImplementation 'androidx.test:runner:1.2.0'`

Well that happened to me an hour ago...
I always suggest check the most basic issues for example:
Go to >> Gradle module.app:
implementation 'com.google.android.material:material:1.2.1'
When you have a syntax's error; Failed to resolve: com.google.android.material:material:x.x.x appears.
Have a great day!

Make sure your gradle.properties enabled AndroidX using the following Line:
android.useAndroidX = true
If not added then add this line and sync project again
Visit For More Details

For androidx users:
My problem got solved by just updating all the dependencies with latest version. It got solved in just 2 minutes. My previous version was 1.0.2 and showed same error. I just clicked on 'Show in Project Structure dialog' which appeared below the error. From there you will get options to update dependencies to latest version. For users other than androidx might be the same soution works.

Related

Error: Program type already present: androidx.versionedparcelable.ParcelImpl

I'm Trying to add this https://github.com/ArthurHub/Android-Image-Cropper But when i add it i get this error "Error: Program type already present: androidx.versionedparcelable.ParcelImpl"
I have attached project gradle and app gradle. (i'm new to android development and am not entirely sure how to fix.)
i think it might have something to do with
implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation "com.android.support:design:${supportLibVersion}"
But these are used for TextInputLayout in one of my layouts for an activity.
Any help will be greatly appreciated.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven{
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.something.app"
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
ext {
supportLibVersion = '27.1.1' // variable that can be referenced to keep support libs consistent
}
dependencies {
api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation "com.android.support:design:${supportLibVersion}"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support:design:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-auth:16.0.4'
implementation 'com.google.firebase:firebase-database:16.0.3'
implementation 'com.google.firebase:firebase-storage:16.0.3'
testImplementation 'junit:junit:4.12'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.android.support:support-v4:28.0.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:design:28.0.0-rc01'
//implementation 'com.google.android.gms:play-services-maps:16.0.0'
// implementation 'com.google.android.gms:play-services-analytics:7.3.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-analytics:16.0.4'
implementation 'com.google.android.gms:play-services-places:16.0.0'
}
apply plugin: 'com.google.gms.google-services'
You use support library whereas new version of Image-Cropper Library used androidx library.
check change log
So, You have two option either you can move to androidx or change library version to old version
api 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
I solved my issue by downgrading butterknife dependencies to version 8.8.1
// BUTTERKNIFE
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
Alternatively, another solution was me for searching through entire project files for any import statements using androidx and then replacing them with the android.support version.
In my case I found -
import androidx.annotation.NonNull; which I replaced with import android.support.annotation.NonNull;
You can keep latest version and configure gradle to use AndroidX
api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
From Doc Using AndroidX
See Migrating to AndroidX to learn how to migrate an existing project.
If you want to use AndroidX in a new project, you need to set the
compile SDK to Android 9.0 (API level 28) or higher and set both of
the following Android Gradle plugin flags to true in your
gradle.properties file.
android.useAndroidX: When set to true, the Android plugin uses the
appropriate AndroidX library instead of a Support Library. The flag is
false by default if it is not specified.
android.enableJetifier: When
set to true, the Android plugin automatically migrates existing
third-party libraries to use AndroidX by rewriting their binaries. The
flag is false by default if it is not specified.
You need to use
api 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
Because android-image-cropper:2.8.+' is Update to support library to AndroidX
For com.android.support Use this
api 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
For AndroidX Use this
api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
Change log 2.8.0
Fix crash on Android O
Update to support library to AndroidX
Handle failure when selecting non image file
More translations
For more information Please Read the Change log of Android Image Cropper
If you have added a model cropper , remove it
and add
For com.android.support Use this
api 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
For AndroidX Use this
api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'

Cannot access zzbfm class file for com.google.android.gms.internal.zzbfm not found

I am migrating my Android app project from GCM to FCM. For this I use Firebase assistant tool in Android Studio and followed instructions from Google developer guide. Everything went fine and changed my app code for FCM according to Assistant tool. Now, its time to run and test app. And I got following strange error :
cannot access zzbfm class file for com.google.android.gms.internal.zzbfm not found
I am getting this error where I am using google maps and trying to set marker position.
Here's my app level gradle :
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
maven { url 'https://dl.bintray.com/kennyc1012/maven' }
}
android {
signingConfigs {
msapp {
}
}
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.package"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
useLibrary 'org.apache.http.legacy'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
renderscriptTargetApi 18
renderscriptSupportModeEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
lintOptions {
checkReleaseBuilds false
abortOnError false
}
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//Default
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.firebase:firebase-messaging:11.8.0'
testImplementation 'junit:junit:4.12'
//modules
implementation 'com.facebook.android:facebook-android-sdk:4.+'
//jar files
implementation files('libs/classes.jar')
implementation files('libs/YouTubeAndroidPlayerApi.jar')
//google repos
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support:support-v4:26.0.0'
implementation 'com.android.support:recyclerview-v7:26.0.0'
implementation 'com.google.android.gms:play-services:11.8.0'
implementation 'com.google.android.gms:play-services-analytics:11.8.0'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
implementation 'com.android.support:design:26.0.0'
//square lib
implementation 'com.squareup.retrofit2:converter-gson:2.0.0'
//compile 'com.squareup.leakcanary:leakcanary-android:1.5'
//text manupulation
implementation 'commons-lang:commons-lang:2.6'
//permission library.
implementation 'com.karumi:dexter:5.0.0'
implementation 'com.google.firebase:firebase-core:16.0.3'
}
apply plugin: 'com.google.gms.google-services'
To resolve your problem, first i will ask you to always use specified and updated version.
1. Replace + with specific version here : classpath 'io.fabric.tools:gradle:1.25.4'
2. Try to use same version for now to run the apk,
compileSdkVersion 27
buildToolsVersion '27.0.3'
targetSdkVersion 27
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
3. Use an updated version of google play service
implementation 'com.google.android.gms:play-services:16.0.3'
implementation 'com.google.android.gms:play-services-analytics:16.0.3'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
This will fix your problem.
Please Change your Firebase and Google Library to same version .
For an Example like this
implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.android.gms:play-services-analytics:12.0.1'
implementation 'com.google.android.gms:play-services-maps:12.0.1'
//your firebase lib version to the same version
implementation 'com.google.firebase:firebase-core:12.0.1'
In most cases is required to upgrade play-services and firebase version dependencies, maybe the last one available if you are using androidx but if not:
Try to check it out the maven_repository and choose some version that helps you fix it. For example:
implementation 'com.google.android.gms:play-services-analytics:16.0.8'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
the chosen version is the last one before version 17 due to the v17.0.0 require androidx (in play-service)
Don't forget to update your google-service in your build.gradle(project)
classpath 'com.google.gms:google-services:4.3.0'
I encountered same issue after migrating AndroidX and
Solved by changing version of gms library for maps and location as below
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
According to the official documentation regarding Latest SDK versions, please change the following line of code:
implementation 'com.google.firebase:firebase-messaging:11.8.0'
to
implementation 'com.google.firebase:firebase-messaging:17.3.1'
And according to official documentation regarding on to set up Google Play Services, please change the follwing lines of code:
implementation 'com.google.android.gms:play-services:11.8.0'
implementation 'com.google.android.gms:play-services-analytics:11.8.0'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
to
//implementation 'com.google.android.gms:play-services:11.8.0' //Commented line
implementation 'com.google.android.gms:play-services-analytics:16.0.3'
implementation 'com.google.android.gms:play-services-maps:15.0.1
Please also be sure to have:
classpath 'com.google.gms:google-services:4.1.0'
In your top level build.gradle file.
Just update versions of libraries "......gms:play-services....." to the latest
To check the latest versions, refer this link

Trying to update my build.gradle in Android Studio using Firebase and getting an "AAPT2 error: check logs for details" error

Hello I am building a messaging app using Firebase and Android Studio and have ran into an issue with my build.gradle file. I have tried to update the versions of Firebase I am using and at first after updating I was getting an error message saying
"Failed to resolve: com.google.firebase:firebase-core:16.0.1"
I found this similar post ( Failed to resolve: com.google.firebase:firebase-core:16.0.1 ) and updated my project build.gradle file and top level build gradle file accordingly.
Since also following the advice from the responses I have rerun the app and I am now instead getting a "AAPT2 error: check logs for details" error in the build console.
I really have no idea how to provide a solution to this and I've already spent hours trying and browsing this website. Any help would be greatly appreciated!
The tutorial I was following:
https://www.youtube.com/watch?v=5Y0foGqYmxc (Around 12:00)
build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.cmc.chatbox"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
implementation 'com.android.support:design:28.0.0-beta01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.android.support:support-v4:28.0.0-beta01'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-firestore:17.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
//creates a rounded user profile image
implementation 'de.hdodenhof:circleimageview:2.2.0'
//ArthurHub - allows user to crop their profile image
compile 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
//Picasso - image uploader
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.firebaseui:firebase-ui-database:4.1.0'
}
apply plugin: 'com.google.gms.google-services'
Top level gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.0.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Try adding android.enableAapt2=false in gradle.properties
add implementation 'com.google.firebase:firebase-core:16.0.1' as the first one dependency, before firebase-database:16.0.1. should not be like that, but may cause issues.
the error message clearly reads: check logs for details ...

Program type already present: com.google.android.gms.internal.zzfq

I getting this error. Despite trying all thing I am unable to resolve it. Please help me.
Things that I tried are:
Delete .build, .idea etc then rebuild
Clean and rebuild
Change version of compile library
Thank you
plugins
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
Android
android {
dexOptions {
preDexLibraries = false
javaMaxHeapSize "2g"
}
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.funzone.alarmnap"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
multiDexEnabled true
versionName "1.1"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Greendao Plugin
apply plugin: 'org.greenrobot.greendao'
greendao {
targetGenDir 'src/main/java'
schemaVersion 2
}
All libraries:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.jjoe64:graphview:4.2.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.facebook.android:audience-network-sdk:4.+'
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
implementation 'com.facebook.android:notifications:1.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support:support-v13:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'org.greenrobot:greendao:3.2.2'
testImplementation 'junit:junit:4.12'
testImplementation "org.robolectric:shadows-multidex:3.0"
testImplementation 'org.robolectric:robolectric:3.4.2'
implementation 'com.android.support:preference-v7:27.1.0'
}
repositories {
mavenCentral()
google()
}
Google plugin
apply plugin: 'com.google.gms.google-services'
I fix the same issue in my project - after updating the Kotlin plugin to 1.2.41 (I don't know if it is really related. Edit: apparently this is not related with Kotlin) - with :
classpath 'com.google.gms:google-services:3.2.1'
https://developers.google.com/android/guides/google-services-plugin
Remark: I could stay with the unique 15.0.0 Google Play Services libraries version but not the play-services-tagmanager one and firebase :
implementation "com.google.android.gms:play-services-tagmanager:15.0.2"
implementation "com.google.firebase:firebase-core:15.0.2"
The project is compiling now.
set implementation 'com.google.firebase:firebase-messaging:15.0.2' at the app level build.gradle file, if you are using firebase
set classpath 'com.google.gms:google-services:3.2.0' at the project level build.gradle file
Then sync the build.gradle files
classpath 'com.google.gms:google-services:3.2.0'
and
//Firebase
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.google.firebase:firebase-auth:15.0.0'
implementation 'com.google.firebase:firebase-database:15.0.1'
You will need to update the version of the individual libraries. This addresses the issue where version 3.3.0 of the Google Services Gradle plugin reports: The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.0,15.0.0], [15.0.2,15.0.2]], but resolves to 15.0.2...
For more info regarding the latest update check release updates from below link
Firebase May 2nd release notes
I started seeing this after I upgraded to kotlin plugin version : 1.2.41-release-Studio3.1-1.
Upgrading firebase-core and firebase-messaging from 15.0.0 --> 15.0.2. Fixed the problem, database, auth and gms-auth-services are at 15.0.0
I fixed the issue using new firebase independent version numbers
https://firebase.google.com/support/release-notes/android#latest_sdk_versions
SDK Update - May 2, 2018 -> Firebase Android SDKs now have independent version numbers, allowing for more frequent, flexible updates.
I had the same error and I fixed it updating lines below:
build.grade (Project: [project_name])
classpath 'com.google.gms:google-services:3.3.0'
build.grade (Module: app)
implementation 'com.firebaseui:firebase-ui-auth:3.3.1'
I hope it helps.
I had the same exact error.
I was using
implementation 'com.firebaseui:firebase-ui-auth:3.2.2'
I solved it updating to
implementation 'com.firebaseui:firebase-ui-auth:3.3.0'
Another possible cause/fix might be the build.gradle at project level
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
This is very boring. Google should review these updates better. I tried everything, but my issue was only fixed by returning the version of the Google Play Services APIs:
implementation 'com.google.android.gms:play-services-gcm:11.8.0'
Go to the folllowing link :
https://firebase.google.com/support/release-notes/android
and check for the latest firebase dependencies with the current compatible google play service version as shown in the screenshot below.
For me the problem was
dependencies {
classpath 'com.google.firebase:firebase-plugins:1.1.5'
}
used for Performance Monitoring. Just commented out.
I had the same issue, the thing which is causing this error is 2 versions of same dependency with different services
I changed this:
implementation 'com.google.android.gms:play-services-ads:17.1.0'
implementation 'com.google.android.gms:play-services-analytics:16.0.5'
To:
implementation 'com.google.android.gms:play-services-ads:17.1.1'
these versions are importing same subpackages which is why it is a ambiguity error basically same subpackage is imported from 2 different dependencies (in background)
Have fun coding!!

Error:Program type already present: android.arch.lifecycle.LiveData

When I press the run button in Android Studio, my app compiles but shows this error (redacted):
Error:Program type already present: android.arch.lifecycle.LiveData
(Full log)
I've tried deleting the .gradle folder, then going to Build > Clean Project and Build > Rebuild Project. However, it doesn't work. I've also tried deleting the source code, then cloning again from git and importing the folder to Android Studio. However, it still produces that error.
Here's my app's app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.edricchan.studybuddy"
minSdkVersion 24
targetSdkVersion 27
versionCode 8
versionName "1.0.0-rc.503"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
resConfigs "en"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support:support-annotations:27.1.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
testImplementation 'junit:junit:4.12'
// Firebase stuff
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.android.gms:play-services-auth:11.8.0'
implementation 'com.firebaseui:firebase-ui-auth:3.1.0'
implementation 'com.firebaseui:firebase-ui-firestore:3.1.0'
implementation 'com.firebaseui:firebase-ui-storage:3.1.0'
// Provide a way to update the app
implementation 'com.github.javiersantos:AppUpdater:2.6.4'
// Chrome Custom Tabs
implementation 'com.android.support:customtabs:27.1.0'
// The app's intro screen
implementation 'com.heinrichreimersoftware:material-intro:1.6.2'
// Use for new Material Text field boxes recently introduced
implementation 'com.github.HITGIF:TextFieldBoxes:1.3.7'
// Report an issue to Github without having to open a new tab and so on...
implementation 'com.heinrichreimersoftware:android-issue-reporter:1.3.1'
}
apply plugin: 'com.google.gms.google-services'
Apparently, this is intended behavior:
com.firebaseui:firebase-ui-firestore:3.1.0 depends on android.arch.lifecycle:extensions:1.0.0-beta1. Switching to version 3.2.2 fixes the issue by using the Lifecycle 1.1 libraries that Support Library 27.1.0 are built upon. - Issue Tracker
For me, removing the firebase-ui dependencies solved the issue since I wasn't even using the library in the first place.
I had the very same problem today when I raised the support library version.
Try to replace all '27.1.0' with '27.0.2'
Later on I did manage to remove the error by upgrading other libraries as well.
THis is my current working state:
root gradle:
buildscript {
ext.kotlin_version = '1.2.21'
ext.support_version = '27.1.0'
ext.anko_version = '0.10.4'
ext.android_plugin_version = '3.0.1'
ext.google_services_version = '11.8.0'
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
classpath 'com.android.tools.build:gradle:3.1.0-beta4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
//////////////////
app gradle libraries:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1#aar') {
transitive = true
}
// kotlin:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation "org.jetbrains.anko:anko-common:$anko_version"
implementation "org.jetbrains.anko:anko-commons:$anko_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.22.3'
// support libraries:
implementation "com.android.support:recyclerview-v7:$support_version"
implementation "com.android.support:support-v4:$support_version"
implementation "com.android.support:design:$support_version"
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:cardview-v7:$support_version"
implementation "com.android.support:support-vector-drawable:$support_version"
// misc:
implementation 'com.github.d-max:spots-dialog:0.7#aar'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta5'
implementation 'com.backendless:backendless:4.4.0'
implementation 'io.nlopez.smartlocation:library:3.3.3'
// Google services:
implementation "com.google.firebase:firebase-core:$google_services_version"
implementation "com.google.firebase:firebase-auth:$google_services_version"
implementation 'com.firebaseui:firebase-ui-auth:3.2.2'
implementation "com.google.android.gms:play-services-location:$google_services_version"
implementation "com.google.android.gms:play-services-auth:$google_services_version"
implementation('com.google.api-client:google-api-client:1.23.0') {
exclude group: 'com.google.code.findbugs', module: 'jsr305'
}
}
///////////////
I also upgraded graddle-wrapper.properties to:
#Wed Dec 20 15:08:34 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
This post is the top search result for the very similar error: "Program type already present: android.arch.lifecycle.ViewModelProvider$Factory"
My project uses Room and LiveData, but not firebase. The following changes removed the error:
FROM:
implementation 'android.arch.persistence.room:runtime:1.0.0'
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'
implementation 'android.arch.lifecycle:extensions:1.0.0'
annotationProcessor 'android.arch.lifecycle:compiler:1.0.0'
TO:
implementation 'android.arch.persistence.room:runtime:1.1.1'
annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'
implementation 'android.arch.lifecycle:extensions:1.1.1'
annotationProcessor 'android.arch.lifecycle:compiler:1.1.1'
--- UPDATED ANSWER ---
My previous answer was aimed at solving this error. However, I thought it would be worth presenting it again using best practises:
App level build.gradle file:
// Room components
implementation "android.arch.persistence.room:runtime:$rootProject.roomVersion"
annotationProcessor "android.arch.persistence.room:compiler:$rootProject.roomVersion"
androidTestImplementation "android.arch.persistence.room:testing:$rootProject.roomVersion"
// Lifecycle components
implementation "android.arch.lifecycle:extensions:$rootProject.archLifecycleVersion"
annotationProcessor "android.arch.lifecycle:compiler:$rootProject.archLifecycleVersion"
Project level build.gradle file:
ext {
roomVersion = '1.1.1'
archLifecycleVersion = '1.1.1'
}
Reference:
https://codelabs.developers.google.com/codelabs/android-room-with-a-view/#2
Firebase-UI 3.1.0 isn't compatible with Firebase / Google Services 11.8.0
You will need to upgrade or downgrade according to https://github.com/firebase/FirebaseUI-Android#compatibility-with-firebase--google-play-services-libraries
Firebase-UI 3.1.0 with Firebase / Google Services 11.4.2
Firebase / Google Services 11.8.0 with Firebase-UI 3.1.3
Hope this help ;)
I also had the error posted in the original question, namely:
Error:Program type already present: android.arch.lifecycle.LiveData
It wasn't clear which libraries were causing the problem. With a hint from #lienmt above I realized that it may be related Firebase.
In my case, I am using Firebase and was also using firebase-ui library 3.2.2:
implementation 'com.firebaseui:firebase-ui-database:3.2.2'
I had upgraded all my other Firebase libraries to 15.0.0 but realized my firebase-ui library was incompatible and confirmed it here:
https://github.com/firebase/FirebaseUI-Android#compatibility-with-firebase--google-play-services-libraries
Be sure to match your firebase-ui version to the exact Firebase versions that for which they are fixed for pairing.
Bumping my firebase-ui version to 3.3.1 was what resolved the error:
implementation 'com.firebaseui:firebase-ui-database:3.3.1'
For reference here are the versions I'm using now and my app is running with no errors:
implementation 'com.google.android.gms:play-services-wearable:15.0.0'
implementation 'com.google.android.gms:play-services-auth:15.0.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-database:15.0.0'
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-auth:15.0.0'
implementation 'com.google.firebase:firebase-messaging:15.0.0'
implementation 'com.firebaseui:firebase-ui-database:3.3.1'
Please add following dependencies in your app build.gradel file
implementation "android.arch.core:runtime:1.1.1"
implementation "android.arch.core:common:1.1.1"
#Edric: since I couldn't replay with images in the thread I am answering your question here.
Changes that worked for me:
PS: I also upgraded distributionUrl in gradle-wrapper.properties to
http://services.gradle.org/distributions/gradle-4.6-all.zip
Like Edric mention, this happens because some library still use the old version of android.arch.lifecycle:extensions library, that is android.arch.lifecycle:extensions:1.0.0.
One way to handle this is by forcing the app to use the same version of that library (and if we can, use the newest one).
There are two ways to do that:
Explicitly defined the library version that we want to use in our Gradle, under dependencies section.
implementation 'android.arch.lifecycle:extensions:1.1.1
or
Force resolution of the library, also under dependencies section.
android {
configurations.all {
resolutionStrategy.force 'android.arch.lifecycle:extensions:1.1.1'
}
}
In my case, bumping targetSdkVersion and compileSdkVersion to 28, as well as using version 28 of all support libraries fixed the issue.
I encountered this when I upgraded Glide. I got an error regarding a duplicate CoordinatorLayout. I solved that by using com.android.support:design:27.1.0, but then I got another error regarding LiveData$LifecycleBoundObserver.
After a few hours, I gave up and upgraded targetSdkVersion and compileSdkVersion to API 28, as well as using
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
because YOLO. By dumb luck, it worked.
Just gotta upgrade. For me I had to upgrade the following in App build.gradle file:
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-auth:16.2.0'
implementation 'com.firebaseui:firebase-ui-database:3.2.2'
Then you will sync your files. When you run you will get a new issue of installation failed pop up boxes. Just cancel those and do the following:
1) Build -> Clean Project
2) Build -> Build Bundle(s) / APK(s) -> Build APK(s)
3) Run your project! Should work!
Follow this link if you want any other details on how I solved it but this should do the trick!

Categories

Resources