Got Error when adding googlemaps - android

Here is my dependencies:
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'
implementation 'com.android.support:design:26.1.0'
implementation 'com.koushikdutta.ion:ion:2.2.1'
implementation 'com.firebase:firebase-client-android:2.5.2'
implementation 'com.google.firebase:firebase-core:11.6.2'
implementation 'com.google.firebase:firebase-messaging:11.6.2'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
}
apply plugin: 'com.google.gms.google-services'
when I added the last implementation which is com.google.android.gms:play-services-maps:15.0.1, I Got this error:
All firebase libraries must be either above or below 14.0.0
what's the problem?

You have two different Firebase. First, you're using the old version of firebase with:
implementation 'com.firebase:firebase-client-android:2.5.2'
Second, you're using the more recent Firebase version:
implementation 'com.google.firebase:firebase-core:11.6.2'
implementation 'com.google.firebase:firebase-messaging:11.6.2'
So, you need to migrate your old Firebase. You can do that by changing the old firebase dependency with:
implementation "com.google.firebase:firebase-database:15.0.0"
You must see the full step to migrate from your old Firebase on
Upgrade your Android app from Firebase.com
Also, you need to use the same version of Firebase and Google Play Service. In the end, your dependencies will be like this:
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'
implementation 'com.android.support:design:26.1.0'
implementation 'com.koushikdutta.ion:ion:2.2.1'
implementation "com.google.firebase:firebase-database:15.0.0"
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-messaging:15.0.0'
implementation 'com.google.android.gms:play-services-maps:15.0.0'
}
apply plugin: 'com.google.gms.google-services'

Related

How to get Firebase Token in android activity?

I am using setToken(FirebaseInstanceId.getInstance().getToken()) code to get the token but I am getting the following error
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/zzv;
build.gradle
dependencies {
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'android.arch.lifecycle:extensions:1.1.0'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
annotationProcessor "android.arch.lifecycle:compiler:1.1.0"
//noinspection GradleCompatible
implementation 'com.android.support:recyclerview-v7:28.0.0-rc02'
implementation 'pub.devrel:easypermissions:0.4.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0-rc02'
implementation 'com.google.firebase:firebase-messaging: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'
implementation 'net.bohush.geometricprogressview:geometricprogressview:1.1.1'
implementation project(path: ':andoird-sdk')
implementation project(path: ':opentok-android-sdk-2.16.3')
implementation 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'
The above code is my build.gradle. Help me to fix the issue.
you need to use FirebaseMessagingService to get token .. you will get token into its own method
public class MyFirebaseMessagingService extends FirebaseMessagingService {
#Override
public void onNewToken(final String token) {
/// you will get token here you
enter code here
}
}
First of all fix version of all firebase library to latest version.
you cant mix versions <= 12 and versions >= 15 of Firebase libraries as mentioned here
then check you have properly enable Multidex on your project. Enable multidex for apps with over 64K methods
then use build -> clean to cleanup your project and dependencies.
and for using token use the way of #sonali:

How to fix a problem in Android Studio build (update Firebase)

My problem is about firebase versions when I add the last line "implementation 'com.google.firebase:firebase-core:16.0.1'" I get this problem
This is my code :
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
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 'me.zhanghai.android.materialratingbar:library:1.2.0'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.squareup.retrofit2:retrofit:2.2.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.github.sharish:ShimmerRecyclerView:v1.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
implementation 'com.github.ivbaranov:materiallettericon:0.2.3'
implementation 'com.mikhaellopez:circularimageview:3.0.2'
implementation 'com.google.android.gms:play-services-places:12.0.1'
implementation 'com.google.android.gms:play-services-maps:12.0.1'
implementation 'com.google.firebase:firebase-auth:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.firebase:firebase-database:12.0.1'
implementation 'com.google.firebase:firebase-storage:12.0.1'
implementation 'com.firebaseui:firebase-ui-database:3.3.0'
implementation 'com.google.firebase:firebase-config:12.0.1'
implementation 'com.google.android.gms:play-services-appinvite:12.0.1'
implementation 'com.google.android.gms:play-services-ads:12.0.1'
implementation 'com.google.firebase:firebase-appindexing:12.0.1'
implementation 'com.google.firebase:firebase-analytics:12.0.1'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
implementation 'com.google.firebase:firebase-core:16.0.1'
I think that
'com.google.firebase:firebase-core:16.0.1'
need to be, before other firebase dependencies!
And the last version of firebase-core is 16.0.3, Android Studio warns this.
In the final of app.gradle include:
apply plugin: 'com.google.gms.google-services'
Try clean project and rebuild project, if this didn't work, post here the build errors.

Cannot resolve symbol 'OnSuccessListener' in Android Studio

I'm getting this strange behavior that I'm not able to import OnSuccessListener to my code after git cloning and building in a different machine (this resolved fine in my previous machine). However the project builds fine and runs on the emulator. But I'm not able to write firebase related codes further as the listener isn't resolving.
I tried cleaning the project, rebuilding, invalidating the cache but still no luck.
Gradle Dependencies,
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-v4:27.1.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-firestore:17.0.4'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
implementation 'com.android.support:design:27.1.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.github.drawers:SpinnerDatePicker:1.0.6'
implementation 'com.github.yalantis:ucrop:2.2.2'
}
Please try adding this into your app-gradle file.
implementation 'com.google.android.gms:play-services-tasks:16.0.1'
What you do is make all the firebase and gms version of the same number like for example:
implementation 'com.google.firebase:firebase-auth:102.0'
implementation 'com.google.android.gms:play-services-auth:10.2.0'

Gradle build errors in Firebase UI dependency

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support:exifinterface:28.0.0-alpha3'
implementation 'com.android.support:support-media-compat:28.0.0-alpha3'
implementation 'com.android.support:support-v4:28.0.0-alpha3'
implementation 'com.android.support:design:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-vector-drawable:28.0.0-alpha3'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-database: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'
implementation 'com.firebaseui:firebase-ui-database:4.1.0'
}
These are my dependencies but it is giving me gradle errors, its because of the FirebaseUI dependency as when I delete that the app builds fine.
Can anyone help me how to resolve this? I know its most probably some version issue.
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
Update the following to dependencies:
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
to this:
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'
Also add:
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.
In the top level gradle file use the following google-service plugin:
classpath 'com.google.gms:google-services:4.0.2'
If FirestoreRecyclerAdapter is showing an error means.....
just add these dependencies
implementation 'com.firebaseui:firebase-ui-firestore:8.0.1'
implementation 'com.google.firebase:firebase-core:19.0.2'
This will work fine

Update Google Service Plugins and Unable to Install App After gradle built Successfully

I am working on Android app that uses the Firebase Database for the Storage of Data but the problem comes when app doesn't Install after the Successful built.
Here is the Image of Error in the Gradle
Here is the code of Build.gradle
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-database: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'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:gridlayout-v7:27.1.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.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
}
Update the firebase libraries to the following:
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-database:16.0.1'
and in the top level gradle file use:
classpath 'com.google.gms:google-services:4.0.2'
Try this please, replace 27.1.1 with 26.1.0
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:gridlayout-v7:26.1.0'

Categories

Resources