E/FirebaseInstanceId: Token retrieval failed: AUTHENTICATION_FAILED Firebase - firebase

I've tried many solutions but none of them seem to work. I'm trying to setup firebase with my android project but I keep getting an error which states E/FirebaseInstanceId: Token retrieval failed: AUTHENTICATION_FAILED. Note: Google-services.json is installed into my app directory.
App:
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:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
My App:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
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
}

Related

Firebase implementation in flutter issues

I am having a lot of issues with implementing firebase in my flutter project, I had to revert back from 4.3 to 4.2 because of gradle errors. Now it is taking forever to load it on my emulator, I switched to an actual device but that install wont open. Has anyone implemented firebase messaging in a flutter project recently? I’m about to scrap the whole idea of using it.
Ive added the required lines to build.gradle and app/build.gradle and to my yaml file and thats it.
I have it working as of today (2019-09-27 20:00 UTC, because flutter builds can break at any moment), and I'll let you know what I have in my build in order to get it to work (bit too long for a comment). I have tested that it works in both iOS and Android and builds correctly for release.
Firstly, switch to the flutter master channel flutter channel master. This is to fix a gradle appbundle naming issue.
pubspec.yaml
dependencies:
firebase_messaging: ^5.1.6
android/build.gradle (note the change in gradle version)
buildscript {
ext.kotlin_version = '1.3.41'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.2'
}
}
android/gradle.properties (change for AndroidX)
android.enableJetifier=true
android.useAndroidX=true
android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
android/app/build.gradle
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
}
apply plugin: 'com.google.gms.google-services'
In the same file make sure in the defaultConfig section you've changed the testInstrumentationRunner as follows:
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
android/app/src/main/AndroidManifest.xml
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Make sure you've added your google-services.json to android/app folder. I assume at some point this will all be nicely documented but at the moment it's a bit wild-west.

Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check

I'm setting firebase on my project and when I add inappmessaging-display lib this error appears:
Dependency resolved to an incompatible version:
Dependency(fromArtifactVersion=ArtifactVersion(groupId=com.google.firebase,
artifactId=firebase-messaging, version=17.3.2),
toArtifact=Artifact(groupId=com.google.firebase,
artifactId=firebase-iid), toArtifactVersionString=[17.0.2]) FAILURE:
Build failed with an exception.
What went wrong: Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during
up-to-date check. In project 'app' a resolved Google Play services
library dependency depends on another at an exact version (e.g.
"[17.0. 2]", but isn't being resolved to that version. Behavior
exhibited by the library will be unknown.
Dependency failing: com.google.firebase:firebase-messaging:17.3.2 -> com.google.firebase:firebase-iid#[17.0.2], but fire base-iid version was 17.0.3.
The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art ifact
with the issue. -- Project 'app' depends onto
com.google.firebase:firebase-iid#17.0.3 -- Project 'app' depends
onto com.google.firebase:firebase-messaging#17.3.2 -- Project 'app'
depends onto com.google.firebase:firebase-ads#17.1.2 -- Project
'app' depends onto
com.google.firebase:firebase-inappmessaging-display#17.0.4 --
Project 'app' depends onto
com.google.firebase:firebase-analytics#16.0.6 -- Project 'app'
depends onto com.google.firebase:firebase-analytics-impl#16.2.4 --
Project 'app' depends onto
com.google.firebase:firebase-inappmessaging#17.0.4 -- Project 'app'
depends onto com.google.firebase:firebase-core#16.0.6 -- Project
'app' depends onto
com.google.firebase:firebase-measurement-connector-impl#17.0.4 --
Project 'app' depends onto com.google.firebase:firebase-config#16.1.3
-- Project 'app' depends onto com.google.firebase:firebase-crash#16.2.1 -- Project 'app' depends
onto com.google.firebase:firebase-abt#16.0.1 -- Project 'app'
depends onto com.google.firebase:firebase-perf#16.2.3 -- Project
'app' depends onto
com.google.android.gms:play-services-measurement-api#16.0.4
For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep endency
paths to the artifact. This error message came from the
google-services Gradle plugin, report issues at https://
github.com/google/play-services-plugins and disable by adding
"googleServices { disableVersionCheck = false }" to your build.gradle
file.
project file
buildscript {
ext.kotlin_version = '1.3.11'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.2.0'
classpath ('com.google.firebase:firebase-plugins:1.1.5')
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id 'com.gradle.build-scan' version '1.16'
}
ext {
support_library_version = '28.0.0' //use the version of choice
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.myapp.pocapp"
minSdkVersion 25
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:animated-vector-drawable:$support_library_version"
implementation "com.android.support:exifinterface:$support_library_version"
implementation "com.android.support:cardview-v7:$support_library_version"
implementation "com.android.support:customtabs:$support_library_version"
implementation "com.android.support:support-media-compat:$support_library_version"
implementation "com.android.support:support-v4:$support_library_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.android.support:appcompat-v7:$support_library_version"
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'
//Play services dependencies
implementation('com.google.android.gms:play-services-plus:15.0.1')
implementation('com.google.android.gms:play-services-gcm:15.0.1')
implementation('com.google.android.gms:play-services-maps:15.0.1')
implementation('com.google.android.gms:play-services-ads:15.0.1')
implementation('com.google.android.gms:play-services-location:15.0.1')
implementation('com.google.android.gms:play-services-analytics:16.0.3')
implementation('com.google.android.gms:play-services-basement:15.0.1')
implementation('com.google.android.gms:play-services-auth:16.0.0')
implementation('com.google.android.gms:play-services-drive:15.0.1')
//General google dependencies
implementation('com.android.installreferrer:installreferrer:1.0')
implementation('com.android.billingclient:billing:1.2')
//Firebase dependencies
implementation('com.google.firebase:firebase-core:16.0.6')
implementation('com.google.firebase:firebase-perf:16.2.3')
implementation('com.google.firebase:firebase-ads:17.1.2')
implementation('com.google.firebase:firebase-crash:16.2.1')
implementation('com.google.firebase:firebase-config:16.1.3')
implementation('com.google.firebase:firebase-messaging:17.3.2')
implementation('com.google.firebase:firebase-inappmessaging:17.0.4')
implementation('com.google.firebase:firebase-inappmessaging-display:17.0.4')
}
apply plugin: 'com.google.gms.google-services'
I already updated all libs to latest versions.
I am also facing same issue,
At finally got a Solution.
Please remove Cordova-plugin-firebase and
Use the latest major releases just by running: cordova plugin add cordova-plugin-firebase-lib
Simply follow the following link: https://www.npmjs.com/package/cordova-plugin-firebase-lib
Check your internet connection.
If you are connected,try to use a proxy server (using hotspot shield,PSiphone, etc.)
The problem was on firebase libs versions, Just update every lib to fix this.
cd android
./gradlew clean
try this

Firebase Failed to resolve: firebase-messaging-15.0.0 (Previous solutions disconnect Firebase Connection)

I have been trying to set up Firebase Cloud Messaging on an app. Everything runs ok until I add FCM dependencies to the app. I immediately get this error:
Failed to resolve: firebase-messaging-15.0.0
Open File
Here are the dependencies;
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
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 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-messaging:17.0.0:15.0.0'
}
apply plugin: 'com.google.gms.google-services'
I have been reading answers like this all day and the only solution that works involves deleting everything from ": - 0" in the last line of the code.
The problem is that it immediately removes the connection to FCM. New to android programming, so forgive any obvious oversight. Thanks
This happens because the version of the dependencies conflict. You can remove one of the version and select the preferred one. In this case your
implementation 'com.google.firebase:firebase-messaging:17.0.0:15.0.0'
seems to have double version. You should choose whether to use 17.0.0 or 15.0.0 one.
The detail can be found in this video
https://youtu.be/NN_Ch5qzFWQ
cheers !

Migration to androidx.databinding on AndroidStudio 3.0

I'd like to ask if it's possible to migrate to androidx.databinding in AndroidStudio 3.0.
I don't want to upgrade to AndroidStudio 3.2 just yet, and it seems that I can only import android.databinding instead of the androidx version.
I have added this in my app gradle file:
kapt "androidx.databinding:databinding-compiler:3.2.0-alpha16"
Project gradle dependency:
classpath 'com.android.tools.build:gradle:3.1.0'
All the other androidx libraries I added on gradle can be imported in code, but not databinding. Has anyone here still using AndroidStudio 3.0 successfully used androidx.databinding?
Thanks.
UPDATE:
In the app build.gradle, I updated the dependency from -jre8 to -jdk8:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
This is the app build.gradle dependencies:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:$rootProject.supportLibVersion"
implementation "com.google.android.material:material:$rootProject.supportLibVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
kapt 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
// architecture components
implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.archLifecycleVersion"
implementation "androidx.lifecycle:lifecycle-runtime:$rootProject.archLifecycleVersion"
implementation "androidx.room:room-runtime:$rootProject.roomVersion"
implementation "androidx.paging:paging-runtime:$rootProject.pagingVersion"
kapt "androidx.lifecycle:lifecycle-compiler:$rootProject.archLifecycleVersion"
kapt "androidx.room:room-compiler:$rootProject.roomVersion"
kapt "androidx.databinding:databinding-compiler:3.2.1"
testImplementation 'junit:junit:4.12'
}
configurations {
all {
exclude group: 'com.android.support'
exclude module: 'httpclient'
exclude module: 'commons-logging'
}
}
And this is the project build.gradle versions:
ext {
archLifecycleVersion = '2.0.0'
roomVersion = '2.1.0-alpha02'
pagingVersion = '2.1.0-beta01'
supportLibVersion = '1.0.0'
}
I executed this to find out more about the issue on my project:
./gradlew :app:kaptDebugKotlin
and I got this error:
e: error: cannot access NonNull
class file for android.support.annotation.NonNull not found
Consult the following stack trace for details.
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for android.support.annotation.NonNull not found
e: [kapt] An exception occurred: java.lang.UnsatisfiedLinkError: org.sqlite.core.NativeDB._open_utf8([BI)V
at org.sqlite.core.NativeDB._open_utf8(Native Method)
at org.sqlite.core.NativeDB._open(NativeDB.java:71)
at org.sqlite.core.DB.open(DB.java:174)
at org.sqlite.core.CoreConnection.open(CoreConnection.java:220)
at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:76)
at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:25)
at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:24)
at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:45)
at org.sqlite.JDBC.createConnection(JDBC.java:114)
at androidx.room.verifier.DatabaseVerifier$Companion.create(DatabaseVerifier.kt:81)
So it seems that the underlying sqlite library is still using android.support.annotation.NonNull. Any idea on how to solve this?
Thanks.

Failed to resolve: com.google.firebase:firebase-firestore:11.0.4

I looked at some articles on Stack Overflow regarding the problem but they haven't worked. The problem is that my build failes to resolve:
com.google.firebase:firebase-firestore:11.0.4
I'm using android studio to make my app and I'm trying to implement the Firebase Firestore into it.
Here is the code in my build.gradle for my Module:App file:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-media-compat: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-core:11.0.4'
implementation 'com.google.firebase:firebase-auth:11.0.4'
implementation 'com.google.firebase:firebase-storage:11.0.4'
implementation 'com.google.firebase:firebase-firestore:11.0.4'
implementation 'de.hdodenhof:circleimageview:2.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'
compile 'com.android.support:design:27.1.1'
compile 'com.android.support:support-annotations:27.1.1'
compile 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
}
I have no idea what's going on. Help would be very much appreciated!
The initial release of Firestore was 11.4.2 in October 2017. See the Release Notes.

Resources