我有一个模块化的应用程序,可以支持即时应用程序.
I have an app that is modularized to support instant-apps.
应用程序模块:
- 应用
- instantapp
- 基地
- 主要
- 细节
- 搜索
我尝试通过添加以下内容来添加Firebase:
I tried to add Firebase by adding:
- classpath"com.google.gms:google-services:3.1.1"→到 Project Level build.gradle
- api"com.google.firebase:firebase-core:${versions.firebase}"→转到基本模块
- 在基本模块 底部应用插件:"com.google.gms.google-services"→
- google-services.json →转到基本模块文件夹
- classpath 'com.google.gms:google-services:3.1.1' → to the Project Level build.gradle
- api "com.google.firebase:firebase-core:${versions.firebase}" → to the Base Module
- apply plugin: 'com.google.gms.google-services' → to the bottom of the Base Module
- google-services.json → to the base module folder
运行非即时应用时,我收到以下错误消息:
When I run the non-instant app I receive the following errors:
I/FirebaseInitProvider:FirebaseApp初始化失败
I/FirebaseInitProvider: FirebaseApp initialization unsuccessful
E/FA:GoogleService未能初始化,状态:10,名称为google_app_id的字符串资源中缺少google app ID值.
E/FA: GoogleService failed to initialize, status: 10, Missing google app id value from from string resources with name google_app_id.
I/FA:应用测量正在启动,版本:11720
I/FA: App measurement is starting up, version: 11720
I/FA:要启用调试日志记录,请运行:adb shell setprop log.tag.FA VERBOSE
I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
I/FA:要启用更快的调试模式事件记录,请运行: 亚行外壳setprop debug.firebase.analytics.app com.punpuf.chacaraselazer.app
I/FA: To enable faster debug mode event logging run: adb shell setprop debug.firebase.analytics.app com.punpuf.chacaraselazer.app
E/FA:缺少google_app_id. Firebase Analytics已禁用.参见 goo(...)
E/FA: Missing google_app_id. Firebase Analytics disabled. See goo(...)
E/FA:无法上传.应用测量已禁用
E/FA: Uploading is not possible. App measurement disabled
I/FA:找不到标记管理器,因此将无法使用
I/FA: Tag Manager is not found and thus will not be used
当我运行即时应用时,出现以下错误:
And when I run the instant app I receive the following error:
V/FA:正在取消作业.职位编号:1799580119
V/FA: Cancelling job. JobID: 1799580119
E/FirebaseApp:Firebase API初始化失败. (...)原因:java.lang.NullPointerException:尝试在空对象引用上调用接口方法'void android.app.job.IJobScheduler.cancel(int)'
E/FirebaseApp: Firebase API initialization failure. (...) Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void android.app.job.IJobScheduler.cancel(int)' on a null object reference
I/FirebaseInitProvider:FirebaseApp初始化成功
I/FirebaseInitProvider: FirebaseApp initialization successful
如果我添加以下行:"FirebaseAnalytics.getInstance(this)",它不仅会收到先前的错误,还会崩溃:
If I add the following line: "FirebaseAnalytics.getInstance(this)", not only does it receive the previous errors, it also crashes:
E/AndroidRuntime:致命例外:主进程:com.punpuf.chacaraselazer.app,PID:11273 java.lang.RuntimeException:无法启动活动ComponentInfo {(...)}:java.lang.NullPointerException:尝试在空对象引用上调用接口方法'void android.app.job.IJobScheduler.cancel(int)'
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.punpuf.chacaraselazer.app, PID: 11273 java.lang.RuntimeException: Unable to start activity ComponentInfo{(...)}: java.lang.NullPointerException: Attempt to invoke interface method 'void android.app.job.IJobScheduler.cancel(int)' on a null object reference
所以我的问题是我如何才能使Firebase Analytics正常工作,并且在我的即时版本和非即时版本的应用程序上都不会崩溃.
So my question is how can I get Firebase Analytics to work, and not crash on both my instant and non-instant version of my app.
尽管此问题与 FirebaseApp初始化在Android Instant应用程序中失败类似,但我的错误类型不相同
Although this question is a bit similar to FirebaseApp initialization unsuccessful in Android Instant apps , mine not contain the same type of errors.
更新: 我创建了一个新的Firebase项目,并更新了google-services.json,但仍然无法正常工作.
Update: I've created a new Firebase Project, and updated my google-services.json, but still didn't work.
这是我的gradle文件:
Here are my gradle files:
- 项目: gist.github/Punpuf/8582fa3610a1c3dea13627e1207a6064 >
- app: gist.github/Punpuf/2104ffe0c90927cb79944860a7cb6c46 >
- instantapp: gist.github/Punpuf/233d96e91293a2a14e8fdf50092edd2d >
- base: gist.github/Punpuf/e1646f67d8a6094773c390d2df209eae >
- 主要: gist.github/Punpuf/f8bdd8789b11d274afdb1c51f490ed25 >
- 详细信息: gist.github/Punpuf/0a4f87b4fb512557ffe6cd110ce667de >
- 搜索: gist.github/Punpuf/455e28b38baad23294dda6c9592586a2 >
- project: gist.github/Punpuf/8582fa3610a1c3dea13627e1207a6064
- app: gist.github/Punpuf/2104ffe0c90927cb79944860a7cb6c46
- instantapp: gist.github/Punpuf/233d96e91293a2a14e8fdf50092edd2d
- base: gist.github/Punpuf/e1646f67d8a6094773c390d2df209eae
- main: gist.github/Punpuf/f8bdd8789b11d274afdb1c51f490ed25
- detail: gist.github/Punpuf/0a4f87b4fb512557ffe6cd110ce667de
- search: gist.github/Punpuf/455e28b38baad23294dda6c9592586a2
我还尝试用firebase消息传递替换firebase分析依赖项,但仍然收到" FirebaseApp初始化失败" 错误.
I've also tried replacing firebase analytics dependency with firebase messaging and I still received the "FirebaseApp initialization unsuccessful" error.
推荐答案我遇到了同样的问题,我解决了这个问题,将google-services.json添加到基本模块和应用模块中,并在两个版本中都应用了google services插件.gradle文件
I've had the same problem, I solved it adding the google-services.json to both base and app module and applying the google services plugin in both build.gradle files
更多推荐
Firebase Analytics无法与Instant App或Normal App一起使用
发布评论