7

I am currently working on an exiting Android application in order to create an Instant apps version.

My Android Studio is now split into several modules :

  • the business object module (which is a library)
  • the base -feature- module
  • the moduleA -feature- module
  • the app module (which is a phone/tablet module)
  • the instant module (which is an instant apps module)

My instant app module can be compiled and launched on a phone/tablet but each time it crashes due to Firebase issues. I have the following message into the logcat :

I/FirebaseInitProvider: FirebaseApp initialization unsuccessful

According to the documentation the Firebase library is compatible with Instant Apps, but I am pretty sure that I do not move the google-services.json file into the right place in my project...

Here what I have done :

  1. I defined the following classpath dependencies into the build.gradle file of the Android Studio project : classpath 'com.google.gms:google-services:3.1.1'

  2. I put the google-services.json file into my module base (because the documentation asks for it)

Now, if I try to apply the plugin (apply plugin: 'com.google.gms.google-services') into the build.gradle file of the base module, I cannot compile. I have the following message :

Error:Execution failed for task ':base:processGooglePlayProductionDebugFeatureGoogleServices'.

> No matching client found for package name 'com.mycompany.myapp.base'

In fact, the package name defined into the google-services.json file is the one use by the app (because according to the documentation the base library cannot have the same package name as the installed android app.

I also tried to apply the plugin into the build.gradle files of the installed app and into the instant apps module leaving the google-services.json file into the base module. The app compile but I have the log : "FirebaseApp initialization unsuccessful".

So I tried moving the google-services.json file into my instant app module but I still have the log : "FirebaseApp initialization unsuccessful"

I also tried to force the initialization calling the static method initializeApp from the FirebaseApp class but the log persists.

I cannot find an example of implementation on the web. In fact, the Google Sample repository does not use a google-services.json file.

Thank you in advance for your help !

Edit : Here the dependencies of my modules :

The dependencies of my base -feature- module :

  implementation project(':businessobject')
  feature project(':moduleA')
  application project(':app')

The dependencies of my moduleA -feature- module :

api project(':base')
api project(':businessobject')

The dependencies of my app module (which is a phone/tablet module) :

implementation (project(':base'))
implementation (project(':businessobject'))
implementation (project(':moduleA'))

The dependencies of my instant module (which is an instant apps module) :

implementation project(':base')
implementation project(':businessobject')
implementation project(':moduleA')
3
  • Per doc (developer.android.com/topic/instant-apps/guides/…), google-services.json file should be placed into base feature/ module: switch to Project view and move google-services.json file into your base module root directory. This SO post illustrates how to configure Firebase for android app stackoverflow.com/a/40800682/8320998 Commented Oct 10, 2017 at 23:57
  • This sample app shows how to integrate Google Analytics for Firebase into an instant app: github.com/googlesamples/android-instant-apps/tree/master/… After you clone this sample app, you need to add project to Firebase Console, then download generated for this project google-services.json file and place it in your base/ module. Commented Oct 10, 2017 at 23:58
  • How did you solve it? Im in the same situation Commented May 14, 2018 at 18:19

1 Answer 1

2

because according to the documentation the base library cannot have the same package name as the installed android app.

I think the documentation is a bit out of date. Each "feature" module needs to use a different package name, because that's what's used to generate the name of the R class. AFAIK there's no reason why you can't have the "base" feature use the same package name as the app itself.

It seems like the "google-services" plugin needs to be updated for the "feature" plugin to use the application ID rather than the name specified in AndroidManifest.xml (which will be overwritten later to be the same as the application ID).

tl;dr---changing the package name of "base" to "com.mycompany.myapp" should get things working.

Sign up to request clarification or add additional context in comments.

8 Comments

Im having the same problem but I dont understand your solution, can you explain it better please?
@PabloCegarra were you able to find a solution to this ?
Yes... I started a new app with a single feature following the basic Android example, now is it working
Instant apps are a headhache, now I can run my instant app from the play store but firebase says initialization unsuccessful
@Ezio no sorry, I deleted my instant app, to much pain xD
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.