Flutter: Firestore component is not present - android

I have a problem with Firestore database under Flutter. I have done everything, what the package setup documentation says, looked into 2-3 finished public application, and tried to use the package as others use. I even tried to implement native Firestore initialization, because i think the problem is on the platform side, but still, the application get
java.lang.NullPointerException: Firestore component is not present.
when i try to use the Firestore instance.
In project/build.gradle I set
classpath 'com.google.gms:google-services:4.0.1'
for dependency and also imported
'com.google.firebase:firebase-core:16.0.1'
'com.android.support:multidex:1.0.3'
I have the google-service.json in my app folder.
Can anyone help me with this problem? I wasted a day, and still nothing.
Thanks a lot!

Okay, so I figured out from looking into an other problem.
I don't know if I was the only one who didn't know, but because of a new gradle update,
classpath 'com.google.gms:google-services:3.2.1'
was deprecated. I don't really know how the hell, but this caused, that somehow Flutter didn't get the instance right, and throw a nullPointer exception.
If anyone has the same problem ( debug console show some deprecated warning), you should change the
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:3.2.1'
}
}
}
lines in android/build.gradle to
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath ('com.google.gms:google-services:3.2.1') {
exclude group: 'com.google.guava', module: 'guava-jdk5'
}
}
}
I don't really know, why a deprecated form of dependency include caused such a problem, but this change worked for me, and I hope it helps others too. Besides that, I don't think this should cause such a wasted day, as a lot a of documentation should include this fix for the devs.

I also have the same issue after I update my cloud_functions package to 0.4.0. I tried out varies combination and I got this configuration working:
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.2.0'
}
Note that according to the official documentation, Flutter is currently compatible with version 3.2.1 of the Google Services Plugins. I did not do a full test based on 4.2.0 of the Google Services Plugins. So far, Firebase Authentication, Cloud Functions, and Firestore work fine.

https://i.stack.imgur.com/ITWmu.png
check this once, My problem solved using this

Change the google-services to com.google.gms:google-services:3.2.1. Although its an older version, works well with all the latest firebase extensions.

I came across this issue the other day I started working on flutter firebasebase realtime DB. Looks like it is some caching issue with flutter. After spending 50minutes to fix this issue, this comment helped me quickly resolve it.
https://github.com/flutter/flutter/issues/28745#issuecomment-480651580

Related

Why on Android Studio 4.0.1 have error NotAfter: Fri Jul 09 01:43:44 ICT 2021?

I have error like this picture on today. Me already restart and invalid cache, build again. So i'm still don't why like that.
Image View
Yes..i thought im the only person who keep searching for this..i also have same issues..happened today..not sure whether its IDE issue or gradle issue since gradle cannot update..i can only proceed using offline mode..hopefully someone can check on this..
UPDATE:
checked the issue, im not sure how but on my build.gradle i just change this:
Before:
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
After:
dependencies {
classpath 'io.fabric.tools:gradle:1.31.2'
}
I also have same issues too. My friend sent me a solution like below.
If you using OneSignal on your project I think it may be help you.
implementation ('com.onesignal:OneSignal:3.15.3') {
exclude group: 'com.google.android.gms'
}
edit it on gradle app.
This means that one of your dependencies has an issue with the version, go to your app gradle and check if there is a .+ on any of your dependencies and just update it to the latest version, this should solve it
Try to set disable offline mode, then re-sync -> re,build
https://i.stack.imgur.com/UhVBN.png

Android Studio: Unresolved reference despite Gradle sync successful after adding third party implementation. Works fine with previous version

I am trying to add this library:
https://github.com/blipinsk/ViewPropertyObjectAnimator
I have added this to my build.gradle file's dependencies:
implementation 'com.bartoszlipinski:viewpropertyobjectanimator:1.5.0'
The Gradle sync is successful after this too.
However when I try to use it:
ViewPropertyObjectAnimator.animate(this#CustomToolbar).topMargin(it).setDuration(200).start()
It keeps telling me Unresolved reference: ViewPropertyObjectAnimator. And I am unable to import as the com.bartoszlipinski doesn't exist when importing.
If I change the library version from 1.5.0 to 1.4.5:
implementation 'com.bartoszlipinski:viewpropertyobjectanimator:1.4.5'
it works fine and import works fine too.
I would prefer using the newer version instead of the old one. Where am I going wrong?
EDIT: I just noticed that even though Gradle sync is successful, it logs a warning:
Failed to resolve: com.bartoszlipinski:viewpropertyobjectanimator:1.5.0 Show in Project Structure dialog Affected Modules: app
And with the older version, I can see the library in the Android Studio's "External Libraries" but it's not there in the newer library version:
Edit 2: I think I figured it out. I came across this:
https://github.com/blipinsk/ViewPropertyObjectAnimator/issues/16
Using custom bintray repo is a bit unusual, and mavenCentral only has up to 1.4.5. Any chance of updating to 1.5.0 on mavenCentral too? Just curious, but technically bintray works well for me atm too
So it seems like mavenCentral doesn't have the updated version.
I recently came across this issue, I added jitpack repository to the settings.gradle file instead of the root file.
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url "https://jitpack.io" }
}
}
Implementation in the build.gradle file was the same.
implementation 'com.github.blipinsk:ViewPropertyObjectAnimator:1.5.0'
I was able to figure this out. I came across this:
https://github.com/blipinsk/ViewPropertyObjectAnimator/issues/16
Using custom bintray repo is a bit unusual, and mavenCentral only has up to 1.4.5. Any chance of updating to 1.5.0 on mavenCentral too? Just curious, but technically bintray works well for me atm too
So it seems like mavenCentral doesn't have the updated version. As a workaround, I added
maven { url "https://jitpack.io" }
to
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
and then change the dependency to:
implementation 'com.github.blipinsk:ViewPropertyObjectAnimator:1.5.0'

Android Firebase not Implementing Properly

In my Project build.gradle i added these lines
buildscript {
...
dependencies {
...
classpath 'com.google.gms:google-services:3.1.1'
...
}
}
allprojects {
repositories {
...
maven {
url "https://maven.google.com"
}
...
}
}
and in my app build.gradle
dependencies {
//firebase
implementation 'com.google.firebase:firebase-ads:11.8.0'
...
}
apply plugin: 'com.google.gms.google-services'
every thing is fine, gradle sync without warning or any errors, but am not able to use any of the firebase-ads library classes i can't find them it's like i never added that dependency even i manually types com.google.android.gms. and there is no package called ads
even in .xml files i added an AdView when i press Ctrl and hover over the class name, all packages get highlighted untill gms, the ads and adView dosen't get highlighted.
i restarted Android studio,invalidate the cache, sync gradle with and without firebase-ads dependency, removed the library cache from .gradle file, nothing worked.... am i missing something?
You should also add implementation 'com.google.firebase:firebase-core:11.8.0' as a dependency. This is Firebase core dependency and should be added always.
I would recommend you to use the option from Android Studio: Tools->Firebase and then you can choose the tool you want.
the solution was to use an older version of firebase libraries '9.0.2' and it worked, thats still wierd i still want to know the real reason and if it was a bug in the libraries or Android studio to send a bug report

Default FirebaseApp is not initialized

We're seeing a few exceptions with the message Default FirebaseApp is not initialized in this process com.example.app. Make sure to call FirebaseApp.initializeApp(Context) first. in our Android app in which we just added Firebase Remote Config.
The stack trace is as follows:
Fatal Exception: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.app. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
at com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance(Unknown Source)
at com.example.app.fragments.SomeFragment.updateFooter(SourceFile:295)
at com.example.app.fragments.SomeFragment.onCreateView(SourceFile:205)
at android.support.v4.app.Fragment.performCreateView(SourceFile:2080)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1108)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1290)
at android.support.v4.app.BackStackRecord.run(SourceFile:801)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(SourceFile:1638)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(SourceFile:679)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(SourceFile:143)
at android.support.v4.view.ViewPager.populate(SourceFile:1240)
at android.support.v4.view.ViewPager.populate(SourceFile:1088)
at android.support.v4.view.ViewPager.setAdapter(SourceFile:542)
at com.example.app.SomeActivity.onSomeAsyncCallback(SourceFile:908)
at com.example.app.SomeDataRetriever.onAsyncHttpCompleted(SourceFile:72)
at com.example.app.io.AsyncHttp.onPostExecute(SourceFile:141)
at com.example.app.io.AsyncHttp.onPostExecute(SourceFile:19)
at android.os.AsyncTask.finish(AsyncTask.java:679)
at android.os.AsyncTask.access$500(AsyncTask.java:180)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:696)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5665)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:799)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:689)
This is version 9.6.1 and we're also using other Firebase components:
compile 'com.google.firebase:firebase-ads:9.6.1'
compile 'com.google.firebase:firebase-config:9.6.1'
compile 'com.google.firebase:firebase-invites:9.6.1'
compile "com.google.firebase:firebase-messaging:9.6.1"
As I can see from the documentation and the Javadoc we shouldn't have to do any manual initialization in our case.
The exception happens on Android 4-6 on a variety of devices.
Edit:
I see this question gets a little bit of attention. I think this explanation can be interesting for some of you: https://firebase.googleblog.com/2016/12/how-does-firebase-initialize-on-android.html
Make sure to add to your root-level build.gradle
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.3.2'
}
}
Then, in your module level Gradle file (usually the app/build.gradle), add the 'apply plugin' line at the bottom of the file to enable the Gradle plugin:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
implementation 'com.google.firebase:firebase-core:9.6.1'
// Getting a "Could not find" error? Make sure you have
// the latest Google Repository in the Android SDK manager
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
As said in documentation. I had exception as in a question above when forgot to add this in my gradle files.
I had this same issue some time ago.
You're trying to get an instance of Firebase without initialize it.
Please add this line of code before you try to get an instance of Firebase, in your main function or a FutureBuilder:
FirebaseApp.initializeApp();
It seems that google-services:4.1.0 has an issue. Either downgrade it to
classpath 'com.google.gms:google-services:4.0.0'
or upgrade it to
classpath 'com.google.gms:google-services:4.2.0'
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0-alpha08'
classpath 'com.google.gms:google-services:4.2.0'
/*classpath 'com.google.gms:google-services:4.1.0' <-- this was the problem */
}
Hope it helps
UPDATE (11th Nov. 2021):
We do not need to call FirebaseApp.initializeApp(this); anywhere manually. and we should not too.
Possibility 1:
It seems that com.google.gms:google-services:4.3.9 has an issue.
We can either UPGRADE it to
classpath 'com.google.gms:google-services:4.3.10'
or DOWNGRADE it to
classpath 'com.google.gms:google-services:4.3.8'
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.google.gms:google-services:4.3.9'// <-- this was the problem
}
Possibility 2:
Make sure to add the below line in app/build.gradle file
apply plugin: 'com.google.gms.google-services'
then clean project and run again. It worked for me.
Possibility 3:
I just faced the same issue about it and got an unexpected and strange solution.
From this answer:
I have removed tools:node="replace" and it's working like charm.
I was missing the below line in my app/build.gradle file
apply plugin: 'com.google.gms.google-services'
and once clean project and run again. That fixed it for me.
First thing you need to add com.google.gms:google-services:x.x.x at root level build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
After that you need to apply plugin: 'com.google.gms.google-services' at app/build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.google.android.gms:play-services-gcm:9.8.0'
compile 'com.google.android.gms:play-services-maps:9.8.0'
compile 'com.google.android.gms:play-services-location:9.8.0'
compile 'com.google.firebase:firebase-messaging:9.8.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
and if still you are getting problem then you need to add
FirebaseApp.initializeApp(this);
just before you are calling
FirebaseInstanceId.getInstance().getToken();
classpath 'com.google.gms:google-services:4.1.0'
has a problem. instead use:
classpath 'com.google.gms:google-services:4.2.0'
After updating various dependencies I got a Crashlytics error in the compile, 'Crashlytics found an invalid API key: null. Check the Crashlytics plugin to make sure that the application has been added successfully! Contact support#fabric.io for assistance.' The one non-auto response I got from repeated attempts to support#fabric.io the error directs you to was that Fabric and Crashlytics are separate teams so they couldn't help me. I've avoided implementing the extra Fabric layer to Crashlytics, and was unable to get a new key from the Fabric site, or even get the site to recognize me. On attempting to work around this by just removing Crashlytics from my code, I got the 'Default FirebaseApp is not initialized in this process com.example.app. Make sure to call FirebaseApp.initializeApp(Context) first' crash in the run.
I've never had to add the initialization line of 'FirebaseApp.initializeApp(this)', and in fact had it commented out. The documentation even mentions not needing this if only using Firebase for one activity. Adding it made no difference, still got the run killing error.
Turns out what was causing the new obscure errors was the updated google-services dependency. For now, I don't have time to spend more days trying to fix the shotgun errors the new dependency is causing, so until someone comes up with solutions I'll stick to the old version. Besides the odd initialization crash, the new version may be forcing Fabric on Crashlytics users. Users are being forced back to the old dependency version for this too: Crashlytics found an invalid API key: null. after updated com.google.gms:google-services:4.1.0
//com.google.gms:google-services:4.1.0 BAD
com.google.gms:google-services:4.0.1//GOOD
EDIT 10/17/18: After updating the following dependencies again
implementation 'com.google.firebase:firebase-ads:17.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.4'
implementation 'com.google.firebase:firebase-database:16.0.3'
implementation 'com.google.firebase:firebase-core:16.0.4
I got an immediate crash on the install attempt with 'xxx has unexpectedly closed', like when I attempted the google-services dependency update. Digging into the log I found a link directing me to add this to the manifest
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxx~xxxxxx"/>
This is new, and is not mentioned in the setup and interstitial instructions here https://firebase.google.com/docs/android/setup and here https://developers.google.com/admob/android/interstitial.
I used to only have to deal with one ad-related ID for my app, the INTERSTITIAL_UNIT_ID. Now two need to be dealt with. Besides the above addition, documentation directs adding ADMOB_APP_ID here (the same number you tie with ads.APPLICATION_ID in the new manifest code)
MobileAds.initialize(this, ADMOB_APP_ID);
The INTERSTITIAL_UNIT_ID and ADMOB_APP_ID ids can be dug up in your Google AdMob console. My game app stopped serving ads on my first update of the firebase dependencies and still does not serve ads, giving error code 0 in the
public void onAdFailedToLoad(int errorCode){...
Even after all this added clutter, I still can't update the google-services dependency without the initialize error run crash. I expect to be stuck at google-services:4.0.1 for some time.
EDIT 10/24/18: From mobileadssdk-advisor+support#google.com after weeks of correspondence on not getting ad serves after updates:
'Thanks for sharing the device logs. From the logs, it looks like an existing issue and this is on our priority list and our team is working on the fix and this is only happening on Android O and P devices.'
Only O and P devices? That's the last two versions, O came out on September 25, 2017. Yikes.
UPDATE 8/8/21: After updating google-services from 4.3.8 to 4.3.9 I'm suddenly getting this issue from almost 3 years ago again, despite having indeed called the initialization (although allegedly not needed). Will again have to delay update implementation:
//com.google.gms:google-services:4.3.9 BAD
com.google.gms:google-services:4.3.8//GOOD
As mentioned by #PSIXO in a comment, this might be the problem with the dependency version of google-services. For me changing,
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.1.0'
}
}
to
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.0.1'
}
}
worked.There might be some problem with 4.1.0 version. Because I wasted many hours on this, I thought to write this as an answer.
If you are using FirebaseUI, no need of FirebaseApp.initializeApp(this); in your code according the sample.
Make sure to add to your root-level build.gradle :
buildscript {
repositories {
google()
jcenter()
}
dependencies {
...
classpath 'com.google.gms:google-services:3.1.1'
...
}
}
Then, in your module level Gradle file :
dependencies {
...
// 1 - Required to init Firebase automatically (THE MAGIC LINE)
implementation "com.google.firebase:firebase-core:11.6.2"
// 2 - FirebaseUI for Firebase Auth (Or whatever you need...)
implementation 'com.firebaseui:firebase-ui-auth:3.1.2'
...
}
apply plugin: 'com.google.gms.google-services'
That's it. No need more.
For me the problem was that I did not add this line in app/build.gradle file.
apply plugin: 'com.google.gms.google-services'
You need add Firebase Gradle buildscript dependency in build.gradle (project-level)
classpath 'com.google.gms:google-services:3.1.0'
and add Firebase plugin for Gradle in app/build.gradle
apply plugin: 'com.google.gms.google-services'
build.gradle will include these new dependencies:
compile 'com.google.firebase:firebase-database:11.0.4'
Source: Android Studio Assistant
In my case, the Google Services gradle plugin wasn't generating the required values.xml file from the google-services.json file. The Firebase library uses this generated values file to initialize itself and it appears that it doesn't throw an error if the values file can't be found. Check that the values file exists at the following location and is populated with the appropriate strings from your google-sevices.json file:
app/build/generated/res/google-services/{build_type}/values/values.xml
and/or
app/build/generated/res/google-services/{flavor}/{build_type}/xml/global_tracker.xml
For more detail see:
https://developers.google.com/android/guides/google-services-plugin
My particular case was caused by using a gradle tools version that was too advanced for the version of Android Studio that I was running (ie ensure you run grade tools v3.2.X-YYY with Android Studio v3.2).
Another possible solution - try different Android Studio if you are using some betas. Helped for me. New Android Studio simply didn't add Firebase properly. In my case 3.3preview
After some more investigation I found the problem was that new Android studio starts project with newer Google Services version and it looks it was the original problem. As #Ammar Bukhari suggested this change helped:
classpath 'com.google.gms:google-services:4.1.0' ->
classpath 'com.google.gms:google-services:4.0.0'
I'm guessing there are compatibility problems with the version of google-services and firebase versions.
I changed in the Project's build.gradle file, the dependency
classpath 'com.google.gms:google-services:4.1.0' to 4.2.0
and then updated the module's build.gradle dependencies to:
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation 'com.google.firebase:firebase-core:16.0.7'
Everything works like a charm, no need to type FirebaseApp.initializeApp(this);
One of the reason of this happening could be to forgetting adding android.permission.INTERNET permissions in AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
Reason for happening this is com.google.gms:google-services version.When I was using 4.1.0, I faced the same error. Then I downgrade the version.
Before
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.1.0'
After
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:3.2.0'
Hope, it will solve the error.
If you recently update your Android Studio to 3.3.1 that have a problem with com.google.gms:google-services (Below 4.2.0) dependencies So please update com.google.gms:google-services to 4.2.0.
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.2.0'
}
to me it was upgrading dependencies of com.google.gms:google-services inside build.gradle to
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
By following #Gabriel Lidenor answer, initializing app with context is not work in my case. What if you are trying to create firebase-app without google-service.json ? So before initializing any number of firebase app, first need to initialize as;
FirebaseOptions options = new FirebaseOptions.Builder().setApplicationId("APP_ID")
.setGcmSenderId("SENDER_ID").build();
FirebaseApp.initializeApp(context, options, "[DEFAULT]");
I created my Android project in 2023, it is a little different than the other answers.
You do NOT need to call FirebaseApp.initializeApp(this) yourself
You do NOT need <uses-permission android:name="android.permission.INTERNET" />
Go to your Project's build.gradle and add id 'com.google.gms.google-services' version '4.3.15' apply false under plugins {
Go to your Module's build.gradle and add id 'com.google.gms.google-services' under plugins {
Although manually initialize Firebase with FirebaseApp.initializeApp(this); makes the error disappear, it doesn't fix the root cause, some odd issues come together doesn't seem to be solved, such as
FCM requires com.google.android.c2dm.permission.RECEIVE permission which
is only for GCM
token becomes unregistered after first notification sent
message not received/ onMessageReceived() never get called,
Use newer Gradle plugin (e.g. Android plugin 2.2.3 and Gradle 2.14.1) fixed everything. (Of course setup has to be correct as per Firebase documentation )
My problem was not resolved with this procedure
FirebaseApp.initializeApp(this);
So I tried something else and now my firebase has been successfully initialized. Try adding following in app module.gradle
BuildScript{
dependencies {..
classpath : "com.google.firebase:firebase-plugins:1.1.5"
..}
}
dependencies {...
implementation : "com.google.firebase:firebase-perf:16.1.0"
implementation : "com.google.firebase:firebase-core:16.0.3"
..}
Installed Firebase Via Android Studio Tools...Firebase...
I did the installation via the built-in tools from Android Studio (following the latest docs from Firebase).
This installed the basic dependencies but when I attempted to connect to the database it always gave me the error that I needed to call initialize first, even though I was:
Default FirebaseApp is not initialized in this process . Make sure to
call FirebaseApp.initializeApp(Context) first.
I was getting this error no matter what I did.
Finally, after seeing a comment in one of the other answers I changed the following in my gradle from version 4.1.0 to :
classpath 'com.google.gms:google-services:4.0.1'
When I did that I finally saw an error that helped me:
File google-services.json is missing. The Google Services Plugin
cannot function without it. Searched Location:
C:\Users\%username%\AndroidStudioProjects\TxtFwd\app\src\nullnull\debug\google-services.json
C:\Users\%username%\AndroidStudioProjects\TxtFwd\app\src\debug\nullnull\google-services.json
C:\Users\%username%\AndroidStudioProjects\TxtFwd\app\src\nullnull\google-services.json
C:\Users\%username%\AndroidStudioProjects\TxtFwd\app\src\debug\google-services.json
C:\Users\%username%\AndroidStudioProjects\TxtFwd\app\src\nullnullDebug\google-services.json
C:\Users\%username%\AndroidStudioProjects\TxtFwd\app\google-services.json
That's the problem. It seems that the 4.1.0 version doesn't give that build error for some reason -- doesn't mention that you have a missing google-services.json file. I don't have the google-services.json file in my app so I went out and added it.
But since this was an upgrade which used an existing realtime firsbase database I had never had to generate that file in the past.
I went to firebase and generated it and added it and it fixed the problem.
Changed Back to 4.1.0
Once I discovered all of this then I changed the classpath variable back (to 4.1.0) and rebuilt and it crashed again with the error that it hasn't been initalized.
Root Issues
Building with 4.1.0 doesn't provide you with a valid error upon precompile so you may not know what is going on.
Running against 4.1.0 causes the initialization error.
use com.google.gms:google-services:4.0.1' instead of 4.1.0
changing
classpath 'com.google.gms:google-services:4.1.0'
to
classpath 'com.google.gms:google-services:4.0.1'
Works for me
If you're using Xamarin and came here searching for a solution for this problem, here it's from Microsoft:
In some cases, you may see this error message:
Java.Lang.IllegalStateException: Default FirebaseApp is not
initialized in this process Make sure to call
FirebaseApp.initializeApp(Context) first.
This is a known problem that you can work around by cleaning the
solution and rebuilding the project (Build > Clean Solution, Build >
Rebuild Solution).
I downgrade project gms:google_services to
classpath 'com.google.gms:google-services:4.0.1'
and it work for me.
In my case I was deactivating the service in the build gradle (app) as follows:
android.applicationVariants.all { variant ->
def googleTask = tasks.findByName("process${variant.name.capitalize()}GoogleServices")
googleTask.enabled = "mock" != variant.flavorName
}
As this variant was only used for testing and mocking services it was deactivated. This didn't cause any issues for me for nearly 2 years. Once I noticed it within the gradle file it was a bit of a facepalm moment...
If you also do this, simply delete it.
I fix the problem with :
apply plugin: 'com.google.gms.google-services' in build.gradle file and move the file google-service.json under app folder.

Gradle dependency.. Kaltura Player & Google analytics incompatibility [Android]

So, I´ve been messing around this issue for a day, until I found what it seems to be the problem, but now I can´t figure out how to solve it..
I have a proyect that uses Kaltura player sdk for android (https://github.com/kaltura/player-sdk-native-android). I did some tests and it worked like a charm.. but then I tried to use it in my project and Gradle always fails when making the playerSDK with this error:
Error:Execution failed for task ':playerSDK:transformNative_libsWithSyncJniLibsForDebug'.
java.io.FileNotFoundException: ../video-android/player-sdk-native-android/playerSDK/build/intermediates/bundles/debug/jni/lib/armeabi/libHLSPlayerSDK.so (No such file or directory)
After a day trying to figure out why this happens just in this particular proyect.. I found the problem occurs just when I add Google Analytics (https://developers.google.com/analytics/devguides/collection/android/v4/). Adding classpath 'com.google.gms:google-services:1.5.0-beta2' to the build.gradle (project) will make kaltura to throw this error on make proccess.
I´m not a gradle expert, in fact, I´m pretty new with it.. but I would like to know if there is some way to exclude this project dependency when building the playerSDK module.
This is the structure I have now:
|
\-- build.gradle(Project:SampleApp)
\-- build.gradle(Module:App)
\..
\..
\-- build.gradle(Module:playerSDK)
the project build has this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:1.5.0-beta2' //<<This classpath is the problem
}
}
So, I need that classpath there to make google analytics work.. but for some strange reason, it brokes the playerSDK module.. Does anybody knows if there is a way to exclude that classpath for playerSDK module?
Thanks in advance!
Kaltura developer here. This issue was fixed in our develop branch, and will be released in a few days.

Categories

Resources