Firebase libraries must use the exact version error - android

I want to use google cloud messaging for push notification to android application. I read bellow document and set firebase to my application. My gradle build successfully but in implementation 'com.google.firebase:firebase-core:16.0.1' part, I get following error:
All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 17.1.0, 16.2.0, 16.1.1, 16.0.1, 16.0.0, 15.0.1. Examples include com.google.firebase:firebase-messaging:17.1.0 and com.google.firebase:firebase-iid:16.2.0 less... (Ctrl+F1)
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)
App gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "notificationtest.com.test.notification"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
}
apply plugin: 'com.google.gms.google-services'
Project gradle:
// 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.0.1'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url "https://maven.google.com" // Google's Maven repository
}
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
What is the problem and how can I solve it?

You have added 2 different versions of firebase library.
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
Please change it to same version i.e, 15.0.2
I am using this version only and did not face a problem until now. If you want you can probably use 16.0.1 for messaging also. There might be a possibility that google has not released version 17 for firebase-core.

Related

Error in library built with jitpack: Unable to resolve dependency for ':app#debug/compileClasspath'

I am trying to publish my android library on jitpack.io but when I tried to add dependency to test my artifact I am getting this error:
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.github.pashaoleynik97:GSBarcodeScannerHelper:0.1.1-alpha.
Open File
Show Details
Unable to resolve dependency for ':app#debugAndroidTest/compileClasspath': Could not resolve com.github.pashaoleynik97:GSBarcodeScannerHelper:0.1.1-alpha.
Open File
Show Details
Unable to resolve dependency for ':app#debugUnitTest/compileClasspath': Could not resolve com.github.pashaoleynik97:GSBarcodeScannerHelper:0.1.1-alpha.
Open File
Show Details
Unable to resolve dependency for ':app#release/compileClasspath': Could not resolve com.github.pashaoleynik97:GSBarcodeScannerHelper:0.1.1-alpha.
Open File
Show Details
Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not resolve com.github.pashaoleynik97:GSBarcodeScannerHelper:0.1.1-alpha.
Open File
Show Details
My gradle files in library project are listed below.
My build.gradle (app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.github.pashaoleynik97.gsbarcodescannerhelperdemo"
minSdkVersion 21
targetSdkVersion 28
versionCode 2
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
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:espresso-core:3.0.2'
implementation project(':gsbarcodescannerhelper')
}
My build.gradle (gsbarcodescannerhelper):
apply plugin: 'com.android.library'
group='com.github.pashaoleynik97;'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 2
versionName "0.1.1"
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'
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 'org.jetbrains.kotlin:kotlin-stdlib:1.3.10'
implementation(name: 'generalscan-sdk-1.0.6', ext:'aar')
}
And finally, my build.gradle (project):
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs project(':gsbarcodescannerhelper').file('libs')
}
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I pushed my project on github, created release (through github web interface), then went to jitpack.io and published my library. But when I tried to add this library to my new test project I had errors (listed in top of this post). What I am doing wrong?
UPD
I also tried to add classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' like in this docs: https://jitpack.io/docs/ANDROID/
But result remains the same.
UPD 2
Created issue: https://github.com/jitpack/jitpack.io/issues/3758
This seems to be a persisting issue for a few days, can be found here, the link mentions a workaround here. The workaround is to add www with the jitpack.io. Hence update it to the following:
maven { url 'https://www.jitpack.io' }
Jitpack is very sensative tool. There are a multitude of reasons why this issue comes up. I will try to itemized them.
1) Failing Unit Tests; if you have any failing unit tests, you will be able to create the artifact on jitpack (with no reported issues) but will be unable to reference the artifact. Make sure all your unit tests are working properly.
2) It is advisable that you include in your project level gradle for the project intended to be the artifact, the following:
Top of Project Level Gradle
apply plugin: 'maven-publish'
group = '<add-your-package-name-here>'
and at the very bottom of your project level gradle include
apply from: 'https://raw.githubusercontent.com/sky-uk/gradle-maven-plugin/master/gradle-mavenizer.gradle'
Now generate an artifact and see if the reference works
3) Private artifact? Maybe you are not referencing your artifact correctly. If your repo is private, be sure to add the auth token in gradle.properties and then reference it on the project level gradle like this,
gradle.properties
authToken=jp_myfake_token
Project Level Gradle:
maven {
url "https://jitpack.io"
credentials{ username authToken }
}
4) Wait a hour. For whatever reason there is syncing and caching issues with Jitpack. Sometimes all you have to do is wait a hour (or two) and everything starts to work.
Hopefully one of these will help you resolve your issue. Jitpack has easy setup, but it is buggy.
make sure that you add maven { url "https://jitpack.io" }
in build.gradle (Project Level) like this:
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
also, make sure that's your Gradle offline mode is disabled
Now it is free only for public repositories...
If you put your repository url in https://jitpack.io and looked up, you will see the following message as log:
Subscription not active

Error: cannot access zzbgl

I am developing an application and I am getting the following error:
error: cannot access zzbgl
class file for com.google.android.gms.internal.zzbgl not found
I know there's a question here in StackOverflow with the same error that I'm getting posted 4 days ago but the answer did not help in my case. (I am talking about this one)
The error appeared just right after setting Firebase Analytics in my project.
My build.gradle (Module: app) file is this:
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'
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId 'com.geoactio.montferri'
minSdkVersion 14
targetSdkVersion 26
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:appcompat-v7:26.1.0'
// compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.0'
implementation 'com.google.android.gms:play-services:12.0.1'
//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-base:15.0.1"
implementation 'com.navercorp.pulltorefresh:library:3.2.3#aar'
}
productFlavors {
}
lintOptions {
disable 'MissingTranslation'
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
}
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases' }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.4#aar') {
transitive = true;
}
}
apply plugin: 'com.google.gms.google-services'
My build.gradle (Project: myPorojectName) file is this:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.1.0'
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
And clicking in the error leads me here, just after new MarkerOptions():
mapView.addMarker(new MarkerOptions().position(new LatLng(puntomarker.getLatitud(), puntomarker.getLongitud()))
.zIndex(0.5f)
.anchor(0.5f, 0.5f)
.title(puntomarker.getId() + "")
.snippet(puntomarker.getNombre())
.icon(BitmapDescriptorFactory.fromBitmap(((BitmapDrawable) marker).getBitmap())));
(being mapView a GoogleMap instance).
I hope someone can see the error and solve this, thank you so much in advance.
If you need any more information in order to solve this, please let me know.
The Google API Release Notes indicate that support for the combined play-services library ended in April 2018:
Starting with 15.0.0, there will no longer be a play-services alias target to pull in all Google Play services components. This has been recommended against for some time.
You can no longer specify a single dependency on the combined Google Play services target like this anymore:
implementation 'com.google.android.gms:play-services:12.0.1'.
When this was supported with previous versions, it pulled in ALL the Google Play libs way more than you need. See the list of APIs in Table 1 of the Setup Guide and include only the specific ones your app uses.
A check of the Google Maven Repository confirms that version 12.0.1 was the last version of the combined play-services target.
So please delete the above implementation and use only:
implementation "com.google.android.gms:play-services-base:15.0.1"
If you are also using other play services, please add them as separate dependencies.
I think your main reason for the error is that you are using 2 different versions for play services libraries
implementation 'com.google.android.gms:play-services:12.0.1'
Here it is 12.0.1
implementation "com.google.android.gms:play-services-base:15.0.1"
While here it is 15.0.1.
Try to use same version of related libraries everywhere.
Just simply you need to change a Dependency because 12.0.1 is no more
implementation 'com.google.android.gms:play-services:12.0.1'
To
implementation 'com.google.android.gms:play-services-base:15.0.1'
And press sync Gradle
Hope this may help you
updates the version of all dependencies.
Generally, this error will happen if you are working with several new and old dependencies.

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.

Android Studio Gradle Sync Error using google play-services-maps 11.6.2

I am developing a google map app using Android Studio. When I sync the project with Gradle Files (Select Tools/Android/Sync Project with Gradle Files on Android Studio), I get the following error:
Could not resolve com.google.android.gms:play-services-maps:11.6.2.
Couold not get resource 'https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-maps/11.62./play-services-maps-11.6.2.pom
This is the software I am using:
Android Studio 3.0.1
Android Version 7.1.1
Google Play Services 46
Google Repository 58 (under Support Repository)
I've tried using both the google maps project template and the empty activity project but I get the same error.
I am using the http proxy setup I used from earlier projects. I am able to install the play-services-maps and the google repository.
I also added the maven url to the Gradle Project file in the All Projects/Repositories section.
I have tried the suggestions from Stack Overflow but none have not worked.
Any ideas?
Gradle Project Build file:
// 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.0.1'
// 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
}
The gradle app build file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "hansen.scott.googlemaps"
minSdkVersion 25
targetSdkVersion 26
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:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-maps:11.6.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.1'
}
The error is in the line:
implementation 'com.google.android.gms:play-services-maps:11.6.2'
try adding this in project level gradle file
allprojects {
repositories {
maven {
url "https://maven.google.com"
}
}
}
Someone had the same issue I did and entered it on Stack Overflow a day or two ago. The user was getting a build error when using player-services-maps 11.6.2. If the user changed the version to 11.0.0, the build succeeded.
Once I back-dated the maps version to 11.0.0, this solved my problem too. I created a new Google Map project and didn't modify the Gradle Build files.
The problem appears to be that play-services-maps won't build using a versions after 11.0.0. I will post the issue on Github.
Thank you for everybody's help.
I have been facing the same issue for the past one week and posted it on Stack Overflow as well but to no effect.
I have since then figured out the root cause. I am working out of my office and thus have firewalls in place. I got it checked with the system admin and on turning off the firewall the build worked.
So i would advice you to have this checked as well.
Kind regards,
Kabir

Getting .dex 64K error on a small app that works fine on a different PC

I've recently started a new Android Studio project on one PC (very barebones: 3 Activitys, 1 Fragment, all very basic at this stage), and uploaded it to Version Control System through Android Studio (I assume it will only add the necessary files).
When I checkout the project on a different PC, Android Studio recognizes it is a project, and offers to open it as one. The gradle build completes, but on attempting to run the app on a device or emulator, I get the old problem:
Error: The number of method references in a .dex file cannot exceed 64K.
The only dependency as such is the 'bluealliance spectrum color picker', which I have used in the past without issue. I would assume that it has built something wrong, but considering everything is identical to the original project I can't see how it's going wrong - or how it could possibly have >64K methods.
Below are the gradle files:
mobile build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.aetherum.timetableapp"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven {
url "http://github.com/wada811/Android-Material-Design-Colors/raw/master/repository/"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.thebluealliance:spectrum:0.6.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:preference-v7:23.2.1'
compile 'com.android.support:preference-v14:23.2.1'
compile 'com.wada811:android-material-design-colors:2.0.0'
}
And the project build.gradle :
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have tried cleaning and rebuilding the project, as well as checking it out again from git. At this stage, as an inexperienced developer, I'm out of ideas.
The only dependency as such is the 'bluealliance spectrum color picker',
No, you have at least seven dependencies, not including any JARs that might be in libs/.
One of those dependencies is play-services. Unless you are using every single API in the Play Services SDK, you will be much better off using more granular dependencies (e.g., play-services-maps for Maps V2), to pull in only those bits of Play Services that you need.
BTW, you should change your 23.2.1 dependencies to 23.4.0, so all your Android Support Library dependencies are from the same version.
Please remove this line of code
compile 'com.google.android.gms:play-services:9.4.0'

Categories

Resources