您好,我正在尝试构建我们的应用程序的版本变体,但它触发了以下错误时,第一次运行的应用程序。
复制步骤:
1.构建签名的APK
1.在模拟器上安装apk
1.应用程序崩溃
FATAL EXCEPTION: main
Process: silicon.android.app.alpha, PID: 7837
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
at android.app.ActivityThread.installProvider(ActivityThread.java:7493)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6999)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6770)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2134)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7898)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
at com.google.firebase.components.AbstractComponentContainer.setOf(Unknown Source:220)
at com.google.firebase.components.ComponentRuntime.setOf(ComponentRuntime.java:46)
at com.google.firebase.components.RestrictedComponentContainer.setOf(RestrictedComponentContainer.java:150)
at com.google.firebase.heartbeatinfo.DefaultHeartBeatController.lambda$component$4(DefaultHeartBeatController.java:157)
at com.google.firebase.heartbeatinfo.DefaultHeartBeatController$$ExternalSyntheticLambda3.create(Unknown Source:0)
at com.google.firebase.components.ComponentRuntime.lambda$discoverComponents$0$com-google-firebase-components-ComponentRuntime(ComponentRuntime.java:140)
at com.google.firebase.components.ComponentRuntime$$ExternalSyntheticLambda1.get(Unknown Source:4)
at com.google.firebase.components.Lazy.get(Lazy.java:53)
at com.google.firebase.FirebaseApp.initializeAllApis(FirebaseApp.java:606)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:307)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:271)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:256)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:51)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2451)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2421)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:45)
at android.app.ActivityThread.installProvider(ActivityThread.java:7488)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6999)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6770)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2134)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7898)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
巧合的是,这只在发布时运行,但在调试时运行良好。我在我的proguard规则中添加了-dontshrink,-dontoptimize,-dontobfuscate,这就是为什么我可以生成堆栈跟踪。
构建等级值
android {
compileSdkVersion 33
buildToolsVersion "33.0.0"
defaultConfig {
minSdkVersion 23
targetSdkVersion 33
versionCode 1
versionName '0.1.0'
consumerProguardFiles "consumer-rules.pro"
}
minifyEnabled、textCoverageEnabled、收缩资源全部变为false
Firebase库
"analytics" : "com.google.firebase:firebase-analytics-ktx",
"crashlytics": "com.google.firebase:firebase-crashlytics-ktx",
"config" : "com.google.firebase:firebase-config-ktx",
1条答案
按热度按时间whitzsjs1#
对于每个可能遇到这个问题的人来说,这是因为Dexguard模糊处理与我正在使用的一些库冲突,在这个例子中,firebase库、crashlytics和desugaring SDK是值得注意的。
把firebase和desugaring SDK降到旧版本解决了我的问题。
如果你下次遇到这种情况,请仔细检查你的提交并寻找SDK依赖更新。从那里开始,因为日志不会有任何帮助。
祝你好运!