Dependencies conflict error while adding admob gradle to android app - android

I want to add google admob to one of my android app.
But it shows dependency conflict error while adding google services ads and firebase ads.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "package name"
minSdkVersion 21
targetSdkVersion 28
versionCode 2
versionName "2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation'com.android.support.test.espresso:espressocore:3.0.2'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation "org.jetbrains.anko:anko-commons:$anko_version"
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.facebook.shimmer:shimmer:0.4.0'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.skyfishjy.ripplebackground:library:1.0.1'
implementation 'com.sasank.roundedhorizontalprogress:roundedhorizontalprogress:1.0.1'
implementation 'com.google.firebase:firebase-auth:16.2.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.tomer:fadingtextview:2.5'
implementation 'com.google.firebase:firebase-ads:18.0.0'
implementation 'com.google.android.gms:play-services-ads:18.0.0'
}
apply plugin: 'com.google.gms.google-services'
any help will be highly appericated

You don't need to use both firebase-ads and play-services-ads. You should use only one of them. If you're using firebase-ads follow Firebase ads guide or follow Google Admob guide if you're planning to use Standard alone Google Admob SDK

You are using:
implementation 'com.google.firebase:firebase-ads:18.0.0'
implementation 'com.google.android.gms:play-services-ads:18.0.0'
You can check the official release notes:
Warning: This release is a MAJOR version update and breaking change.
The latest update to Google Play services and Firebase includes the following changes:
Migration from Android Support Libraries to Jetpack (AndroidX) Libraries. Libraries will not work unless you make the following changes in your app:
Upgrade com.android.tools.build:gradle to v3.2.1 or later.
Upgrade compileSdkVersion to 28 or later.
Update your app to use Jetpack (AndroidX); follow the instructions in Migrating to AndroidX.
Also the 'firebase-ads' dependency just brings in the existing 'play-services-ads' library. The Firebase SDK is part of Google Play services.

Check your project gradle if this is added -
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.2.0'

You don't have to add admob when you have com.google.android.gms:play-services-ads:18.0.0, it include admob.
You are trying to ad admob twice, hence the error.
You can also remove
implementation 'com.google.firebase:firebase-ads:18.0.0'
Because it's also part of Google Play Services.

Related

Manifest merger failed, after setup android-gms:play-services-ads couldn't combine with appcompat issue [duplicate]

When I add implementation 'com.google.android.gms:play-services-ads:18.2.0' to my build.gradle, Android Studio highlights implementation 'com.android.support:appcompat-v7:28.0.0' with the error:
Dependencies using groupId com.android.support and androidx.* can not be combined but found IdeMavenCoordinates{myGroupId='com.android.support', myArtifactId='versionedparcelable', myVersion='28.0.0', myPacking='aar', myClassifier='null'} and IdeMavenCoordinates{myGroupId='androidx.interpolator', myArtifactId='interpolator', myVersion='1.0.0', myPacking='aar', myClassifier='null'} incompatible dependencies
My build.gradle is:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
configurations.all {
resolutionStrategy.force 'com.android.support:appcompat-v7:28.0.0'
}
defaultConfig {
applicationId "com.XXXXXX.XXXXXX"
minSdkVersion 14
targetSdkVersion 28
versionCode 3
versionName "1.1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:18.2.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'
}
You are using
implementation 'com.google.android.gms:play-services-ads:18.2.0'
Google Play services migrated to AndroidX in the latest release.
Dependencies using groupId com.android.support and androidx.* can not be combined
It means that you are using both, support libraries and androidx libraries.
You can:
migrate to androidx as described below (in your case you have to migrate appcompat to implementation 'androidx.appcompat:appcompat:1.0.2')
downgrade your google play ads dependencies (but it is not a real solution because you have to migrate sooner or later)
You can check the official release notes:
Warning: This release is a MAJOR version update and breaking change.
The latest update to Google Play services and Firebase includes the following changes:
Migration from Android Support Libraries to Jetpack (AndroidX) Libraries. Libraries will not work unless you make the following changes in your app:
Upgrade com.android.tools.build:gradle to v3.2.1 or later.
Upgrade compileSdkVersion to 28 or later.
Update your app to use Jetpack (AndroidX); follow the instructions in Migrating to AndroidX.

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

Updating Google Firebase dependencies in Android project build.gradle file

I have been working on a project where I am trying to build a messaging application in Android Studio using Google Firebase. I previously had to restart the project due to an error after reaching this stage of the tutorial I have been following which requires you to add an implementation of the 'com.firebaseui:firebase-ui-database:4.1.0' (Or whatever the most recent version is) in my project gradle file and update the existing dependencies I am using accordingly.
I am still relatively new to app dev and as such don't want to mess up this project and start from scratch again by screwing up my gradle file. So could somebody show me what my build.gradle file should look like with the new dependency added and the existing dependencies correctly updated before syncing?
Info on adding the dependency can be found under this link, mainly under the 'Installation' and 'Dependencies' headings. https://github.com/firebase/FirebaseUI-Android
My current gradle file looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.conormcadorey.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:11.8.0'
implementation 'com.android.support:support-v4:28.0.0-beta01'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.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'
//creates a rounded user profile image
implementation 'de.hdodenhof:circleimageview:2.2.0'
//ArthurHub - allows user to crop their profile image
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
//Picasso - image uploader
implementation 'com.squareup.picasso:picasso:2.71828'
}
apply plugin: 'com.google.gms.google-services'
ps - I appreciate that this may be a simple or obvious question, however when I attempted this myself I ended up having to rebuild the project from scratch so any help would be greatly appreciated.
Using Android Studio v3.1.3
According to the docs:
As of version 4.1.0, FirebaseUI has the following dependency versions:
Library Version
firebase-auth 16.0.1
play-services-auth 15.0.1
firebase-database 16.0.1
firebase-firestore 17.0.1
firebase-storage 16.0.1
Therfore change the following libraries:
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
into this:
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
Also add the firebase-core:
implementation 'com.google.firebase:firebase-core:16.0.1'
Your app gradle file now has to explicitly list com.google.firebase:firebase-core as a dependency for Firebase services to work as expected.

Failed to resolve: androidx.lifecycle:lifecycle-extensions-ktx:2.0.0-alpha1

I am trying to understand ViewModel and LiveData concepts in android. I am making a practice project but when i added implementation 'androidx.lifecycle:lifecycle-extensions-ktx:2.0.0-alpha1' line in my app level gradle file it shows me
Failed to resolve:
androidx.lifecycle:lifecycle-extensions-ktx:2.0.0-alpha1.
I have searched on google for solution and i found this answer, it works when i compile only viewmodel library but if i compile extensions library using same method as implementation group: 'androidx.lifecycle', name:'lifecycle-extensions-ktx', version: '2.0.0-alpha1', it shows the same error as above.
I have also tried to find it on Maven repositories site here but i didn't have any information for how to compile it.
UPDATE
App Level Build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "***************"
minSdkVersion 19
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 "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
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'
implementation group: 'androidx.lifecycle', name:'lifecycle-extensions-ktx', version: '2.0.0-alpha1'
implementation group: 'androidx.lifecycle', name:'lifecycle-viewmodel-ktx', version: '2.0.0-alpha1'
}
UPDATE
As per #Dr.jacky's comment and Android Developers Documentation,
The APIs in lifecycle-extensions have been deprecated. Instead, add dependencies for the specific Lifecycle artifacts you need.
More Info at https://developer.android.com/jetpack/androidx/releases/lifecycle
I have found the answer. As Thunder Knight said here it seems to be that the repository was emptied somehow. Hence, you can not download it from the repository.. I agree with this and so i was looking for answer on mvnrepository.com and i found it here. I have to add
implementation group: 'androidx.lifecycle', name: 'lifecycle-extensions', version: '2.0.0-alpha1'
line for adding lifecycle-extensions and also i was adding -ktx in name of library but it was the mistake. In documentation they have not commented to add -ktx in line of lifecycle-extensions.
Credits:- #Thunder Knight
The current version is 2.2.0
use -ktx for kotlin implementation
and kapt for annotationProcesssor
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
annotationProcessor 'androidx.lifecycle:lifecycle-compiler:2.2.0'
Check the developer site for more information
https://developer.android.com/topic/libraries/architecture/adding-components
Just dont use -ktx in lifecycle-extensions. There is no separate '-ktx' version of the dependency unlike in viewmodel
Add these line
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.legacy:legacy-support-core-utils:1.0.0'
and comment these lines
// testImplementation 'junit:junit:4.13.2'
//androidTestImplementation 'androidx.test.ext:junit:1.1.2'
//androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
in my case i was trying to using room with LiveData. and all i did was remove the suspend key word from the query method.
Reference: post in forums.bignerdranch.com
Error:
Failed to resolve: androidx.lifecycle:lifecycle-extensions:2.3.1
Solution:
The APIs in lifecycle-extensions have been deprecated. Instead, add dependencies for the specific Lifecycle artifacts you need.
More details: developer.android.com

play-services-measurement-based requested with several versions

Error:Failed to notify dependency resolution listener.
The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.2,15.0.2], [15.0.4,15.0.4]], but resolves to 15.0.4. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.intraday.geeks"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
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:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.android.support:design:26.1.0'
implementation 'com.google.firebase:firebase-core:15.0.4'
implementation 'com.google.android.gms:play-services-location:15.0.4'
implementation 'com.google.firebase:firebase-ads:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.0'
implementation 'com.firebaseui:firebase-ui:0.6.2'
}
apply plugin: 'com.google.gms.google-services'
Do you have the classpath 'com.google.gms:google-services:4.0.1'?
It is 4.0.1! I updated it from 4.0.0 to 4.0.1 and it is ok!
If it still doesn't work, you can do this, manually add and not use the plugin
There are several problems in your gradle, in general, the issue here is there is an incompatibility. With the latest Google Service version, Firebase an other Google libraries can be used in diferent version with no problem.
Upgrade your gradle: In the Project gradle, upgrade the gradle version
classpath 'com.android.tools.build:gradle:3.1.3'
You will have to updgrade gradle-wrapper.properties file as well
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Add in the project gradle the latest Google Services Version:
classpath 'com.google.gms:google-services:4.0.1'
Compile is no longer supported, so change it to implementation
implementation 'com.android.support:design:26.1.0'
Firebase-ui is no longer meant to be added all at once, remove it:
implementation 'com.firebaseui:firebase-ui:0.6.2' (delete that line)
Follow Firebase-ui docs to add the dependency you actually need

Categories

Resources