Am trying to load Interstitial Ad on click of a button. unfortunately, getting this.
java.lang.IllegalArgumentException: Service not registered: com.google.android.gms.measurement.internal.zzjl#f5ae32b
at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1757)
app build.gradle
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation platform('com.google.firebase:firebase-bom:26.1.0')
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.2.0'
implementation 'com.google.firebase:firebase-core:18.0.0'
implementation 'io.github.kobakei:ratethisapp:1.2.0'
implementation 'com.google.android.gms:play-services-ads:19.6.0'
implementation 'com.google.firebase:firebase-perf'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.drawerlayout:drawerlayout:1.1.1'
implementation 'com.github.hotchemi:android-rate:1.0.1'
project build.gradle
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.google.gms:google-services:4.3.4'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
classpath 'com.google.firebase:perf-plugin:1.3.4'
If you're going to use the Firebase BoM, you should set it set the versions of all Firebase dependencies. Your are not letting it the version of this:
implementation 'com.google.firebase:firebase-core:18.0.0'
In fact, you shouldn't need firebase-core at all any more. According to the documentation:
The Firebase Android library firebase-core is no longer needed. This SDK included the Firebase SDK for Google Analytics.
So, just remove the dependency entirely if you aren't using it directly. Or at least remove the version number.
If you don't use analytics, try remove this line:
implementation 'com.google.firebase:firebase-analytics'
Related
I am getting error in the whole class that extends BottomSheetDialogFragment
Cannot access 'androidx.lifecycle.HasDefaultViewModelProviderFactory' which is a supertype of 'FavoriteBottomDialogFragment'. Check your module classpath for missing or conflicting dependencies
The class is in app module and this module implements two other modules : core and presentation-core
build.gradle
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project (':core')
implementation project (':presentation-core')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.41"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
testImplementation 'junit:junit:4.12'
implementation "com.google.android.material:material:1.1.0"
//Rx
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation "io.reactivex.rxjava2:rxjava:2.2.9"
//Architecture component
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'androidx.room:room-runtime:2.0.0'
kapt 'androidx.room:room-compiler:2.0.0'
kapt 'androidx.lifecycle:lifecycle-common-java8:2.0.0'
implementation 'androidx.room:room-rxjava2:2.0.0'
implementation 'androidx.room:room-guava:2.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
}
core dependencies
dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4"
api 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.2'
//library to serialize Java Objects between Contexts
implementation 'org.parceler:parceler-api:1.1.11'
kapt 'org.parceler:parceler:1.1.11'
//testing dependencies
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
testImplementation "org.mockito:mockito-core:2.24.5"
androidTestImplementation "org.mockito:mockito-android:2.24.5"
//architecture component
implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
implementation "androidx.lifecycle:lifecycle-livedata:2.0.0"
//RxJava2
implementation "io.reactivex.rxjava2:rxjava:2.2.9"
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
}
presentation-core
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
}
BottomSheetDialogFragment
Even with errors i got, I can run the project in a device
I experienced this exact same problem today, and was able to solve.
Turns out the issue was a version mismatch between the expected version of androidx.lifecycle:lifecycle-viewmodel used by the module where the "failing" class is and a later version in some other dependent code.
So in my case, my module was using version 2.1.0 of this module, but one of the dependencies was using version 2.2.0. The code will compile no problem, because gradle resolves the dependency to the latest version; however Android Studio is somehow confused by this situation (not always, because this doesn't happen all the time, but sometimes – this isn't the first time I've seen this.)
Therefore solution is: figure out what the latest version of this library is in your app and update your build.gradle for this module to point to the same version that gradle is resolving to. Or:
run gradlew app:dependencies
search the result for lifecycle-viewmodel
update build.gradle in your app to depend on lifecycle-viewmodel with the version that gradle says it is resolving to
Sync project with gradle files
in my case (an Android module), Android Studio 4.0.1, I get a number of warnings in the IDE related to androidx.lifecycle.HasDefaultViewModelProviderFactory,
I have solved the issue by adding this line to build.gradle:
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
thus the beginning of build.gradle becomes:
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
...
In my case, the problem was solved adding the lifecycle viewmodel dependency in the module of the troubled class.
Add dependency into you build gradle androidx.fragment:fragment-ktx:x.x.x with actual version. For activity you must add androidx.activity:activity-ktx:x.x.x. I hope this helps you, in my case it solved the problem.
I added the following lines to build.gradle to solve the same issue in a module:
def archLifecycleVersion = '2.2.0'
implementation "androidx.lifecycle:lifecycle-extensions:$archLifecycleVersion"
kapt "androidx.lifecycle:lifecycle-compiler:$archLifecycleVersion"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$archLifecycleVersion"
Your androidx.lifecycle:lifecycle-XXX dependency versions must be the same.
in my case:
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.4.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.1"
I need to use a different set of firebase libraries in the project. But I'm getting the following error :
Unable to resolve dependency for ':#debug/compileClasspath': Could not resolve com.android.support:support-v13:28.0.0.
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.android.gms:play-services-plus:17.0.0'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.google.firebase:firebase-messaging:19.0.0'
// Add dependency
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.google.firebase:firebase-iid:19.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
implementation 'com.google.firebase:firebase-crash:16.2.1'
If you want to use the latest versions, then you can use firebase BoM, in the build.gradle, write the following:
dependencies {
// Import the platform
implementation platform('com.google.firebase:firebase-bom:20.0.1')
// When using a BoM, dependencies don't require a specified version
// If you do specify a version, it overrides the library version specified in the BoM
implementation 'com.google.firebase:firebase-core'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-firestore'
}
com.google.firebase:firebase-bom:20.0.1 will contain the latest version of all firebase libraries, then to use each specific library you add them as you normally do but without a version.
References:
https://firebase.google.com/docs/android/setup#firebase-bom
I'm trying to create a game with firebase google and facebook login. I know that it is possible to use firebase with unity, but I don't want to create both login methods separately, when something like FirebaseUI exists.
So I've created android plugin with FirebaseUI authentication. I tested it in new android project and everything works fine. But when I use my plugin in unity, I have to add my own gradle (mainTemplate.gradle) with dependencies for firebaseUI.
Problem is that there is a default value in firebase auth library and when the game is built, values from my library (default_web_client_id etc.) is overwritten by default value.
Almost after week I found a solution, but I hope there is another way.
My solution: Build android library with firebase, copy library (.aar) to Assets/Plugins, export unity project with this library to Idea, then copy the entire file values.xml (that is created from google-services.json) and facebook appId to res folder in exported project. (then build from Idea)
It's working, but by this method, I have default_web_client_id 3 times in project (1x from my library, 1x from FirebaseUI dependency and 1x from copied values.xml, that overrides them). It's not a problem, but I think that it's not necessary.
Is there any more elegant way to work with firebaseUI and android libraries?
mainTemplate (dependency part):
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
def room_version = "1.1.1"
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation "android.arch.lifecycle:extensions:1.1.1"
implementation "android.arch.lifecycle:viewmodel:1.1.1"
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
implementation 'com.facebook.android:facebook-android-sdk:4.41.0'
**DEPS**}
after some more experiments I found that it depends on implementation order, so I moved **DEPS** up and now its working.
So the solution is easy:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
**DEPS**
def room_version = "1.1.1"
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation "android.arch.lifecycle:extensions:1.1.1"
implementation "android.arch.lifecycle:viewmodel:1.1.1"
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
implementation 'com.facebook.android:facebook-android-sdk:4.41.0'
}
Hope that this helps somebody.
After I added google analytics I get this error, can't find a solution yet...
here is my gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:support-v4:28.0.0-rc02'
implementation 'com.android.support:design:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.skyfishjy.ripplebackground:library:1.0.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.budiyev.android:circular-progress-bar:1.2.0'
implementation 'com.github.channguyen:adv:1.0.0'
implementation 'com.github.jetradarmobile:android-snowfall:1.2.0'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.github.Binary-Finery:Bungee:master-SNAPSHOT'
implementation 'jp.wasabeef:recyclerview-animators:2.3.0'
implementation 'com.google.firebase:firebase-ads:17.1.0'
implementation 'com.google.firebase:firebase-core:16.0.5'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.android.support:support-dynamic-animation:28.0.0'
implementation 'com.google.android.gms:play-services-analytics:16.0.5' //added this and got this error!
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'
build.gradle (Module:app) this code:
dependencies {
implementation 'com.google.firebase:firebase-core:16.0.6'
}
apply plugin: 'com.google.gms.google-services'`
and
build.gradle (Project:project) this code:
dependencies {
classpath 'com.google.gms:google-services:4.0.1'
}
this work for me.
I think it's because you have used a libraries for Firebase with Google Analytics Services SDK for Android.
It says from the documentation, Add Analytics to Your Android App that Firebase SDK is the recommended method to track Android Apps. There's a service from Firebase library you can use.
Analytics com.google.firebase:firebase-analytics:16.0.5
You can view here the other latest versions of Firebase SDK for Android.
If you want to continue to use Google Analytics Services SDK for Android, you can follow the guide from the documentation.
I use the latest version of Android Studio 3.2 & Plugin. When I try to connect firebase it show me to add dependencies -implementation 'com.google.firebase:firebase-auth:16.0.3:15.0.0' for Firebase authentication | implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0' for Realtime Database | implementation 'com.google.firebase:firebase-storage:16.0.1:15.0.0' for Cloud Storage
When using these dependencies it connect Firebase properly but Sync Failed. How to Use these dependencies?
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design: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.3'
implementation 'com.google.firebase:firebase-auth:16.0.3:15.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'
implementation 'com.google.firebase:firebase-storage:16.0.1:15.0.0'
}
apply plugin: 'com.google.gms.google-services'
I had faced the same issue before. If there is the update available then update your android it will fix it. from my experience when I use the assistant to add the dependencies then it comes like this
implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'
but the it is not correct update it with this
implementation 'com.google.firebase:firebase-database:16.0.1'
or
implementation 'com.google.firebase:firebase-database:15.0.0'
or this
maybe this will help you
here is official documentation for help
Update you firebase dependencies like this:
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
Basically, remove the last ":15.0.0" part. You probably copied these from the firebase website and made a mistake while pasting