After configuring account kit sdk as
compile 'com.facebook.android:account-kit-sdk:4.+'
and gradle sync it conflict with com.google.android.gms gradle as mixing versions can lead to runtime crashes and my app crash as
Firebase API initialization failure.
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at ...
the above error is due to mixing google play services gradle (I think Google play services gradle may be used by Facebook Account Kit SDK) because I have same version for all Google play services gradles.
And one more crash is coming from Facebook Account Kit SDK side as
java.lang.RuntimeException: Unable to get provider com.facebook.accountkit.internal.AccountKitInitProvider: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
at android.app.ActivityThread.installProvider(ActivityThread.java:5260)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4808)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4748)
at android.app.ActivityThread.access$1700(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1436)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
at com.facebook.accountkit.internal.Initializer.initialize(Initializer.java:99)
at com.facebook.accountkit.internal.AccountKitController.initialize(AccountKitController.java:592)
at com.facebook.accountkit.internal.AccountKitInitProvider.onCreate(AccountKitInitProvider.java:31)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1758)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1733)
at android.app.ActivityThread.installProvider(ActivityThread.java:5257)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4808)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4748)
at android.app.ActivityThread.access$1700(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1436)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
But after removing
compile 'com.facebook.android:account-kit-sdk:4.+'
my app working without any issue.
But to integrate Facebook Account Kit in my app I have to include above gradle which conflict with google play services.
Totally disappointed, please help.
After upgrading Firebase Gradle as
compile 'com.google.firebase:firebase-messaging:11.6.0'
its not colliding but still gives above RuntimeException from Account Kit SDK.
To fix this you can do something like the following
compile ('com.facebook.android:account-kit-sdk:4.27.0') {
exclude group: 'com.google.android.gms', module: 'play-services-auth-api-phone'
exclude group: 'com.google.android.gms', module: 'play-services-auth'
}
compile 'com.google.android.gms:play-services-auth:11.6.0'
compile 'com.google.firebase:firebase-messaging:11.6.0'
That would remove the stale support gms library from Facebook's SDK and then swap in the same version of the lib that Firebase is using.
Possibly the conflict of libraries can be the reason. See dependencies here;
https://mvnrepository.com/artifact/com.facebook.android/account-kit-sdk/4.27.0
See if you could submit an issue with the facebook to update it.
Or if you need facebook for authentication only, you can use Facebook Android Sdk
What feature/service from firebase r u using , can u pls share the snippet of ur gradle dependencies for the same to better understand the problem here?
For Unable to get provider RuntimeException exception it seems that, Application is not initialized first, Content Providers are initialized before it.
And in Facebook account kit SDK's code it was trying to get my application context.
Now the problem was, I did implement method getApplicationContext() in application class that is getting application shared variable but that variable was setting globally and Facebook Account Kit sdk code getting Null application context.
Solution : setting shared variable in onCreate method instead of setting globally it resolved the problem of Unable to get provider.
And For Mixing issue, Account Kit SDK use 11.0.1 version for play services gradle and in my project I am having 11.0.4 that is actually not the issue because on compile time gradle takes latest gradle but In my project I am not referring below gradle which Facebook Account Kit SDK is using.
compile 'com.google.android.gms:play-services-auth-api-phone:11.0.1'
Solution : I have added above gradle with version 11.0.4 and the mixing gradle issue has been resolved.
compile 'com.google.android.gms:play-services-auth-api-phone:11.0.4'
And as suggested by #astryk if I exclude play-services-auth-api-phone module then gradle mixing error is not showing but it is not including that module becasue in AccountKitActivity on next button click my application crashes as
Crash Report Thread:main Exception:java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/auth/api/phone/SmsRetriever;
at com.facebook.accountkit.internal.PhoneLoginController.createSmsToken(PhoneLoginController.java:250)
at com.facebook.accountkit.internal.PhoneLoginController.logIn(PhoneLoginController.java:188)
at com.facebook.accountkit.internal.LoginManager.logInWithPhoneNumber(LoginManager.java:372)
at com.facebook.accountkit.internal.AccountKitController.logInWithPhoneNumber(AccountKitController.java:631)
at com.facebook.accountkit.ui.PhoneLoginFlowManager.logInWithPhoneNumber(PhoneLoginFlowManager.java:57)
at com.facebook.accountkit.ui.ActivityPhoneHandler.onPhoneLoginComplete(ActivityPhoneHandler.java:189)
at com.facebook.accountkit.ui.AccountKitActivity$1.onReceive(AccountKitActivity.java:176)
at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.auth.api.phone.SmsRetriever" on path: DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappList item -1/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 16 more
Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.auth.api.phone.SmsRetriever
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 17 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available`
Related
I am getting the following error when I build the app with proguard. This failure is new. I updated some of the libraries used in the app to latest (including the target and compile sdk version to 30)but the joda library version is not changed. It is implementation 'net.danlew:android.joda:2.8.2'
Any idea why this error is coming now and how it can be resolved.
I already have the rule -keep class org.joda.** { *; } in my progurad rules.
java.lang.RuntimeException: Unable to create application com.xxx.xxx.xxx: java.lang.RuntimeException: Could not read ZoneInfoMap
at android.app.ActivityThread.handleMakeApplication(ActivityThread.java:7506)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7440)
at android.app.ActivityThread.access$1500(ActivityThread.java:301)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2148)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8506)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by: java.lang.RuntimeException: Could not read ZoneInfoMap
at net.a.a.a.a.a(SourceFile:42)
at com.xxx.xxx.xxx.onCreate(SourceFile:116)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
EDIT
Updating joda version to the latest 2.10.9.1 fixes the issue.
I am not adding this as answer as I wanted to know why this error appeared all of a sudden? Can any other version update can lead to this.
I am using Firebase Crash Reporting and Firebase Remote Config. Version of both is 9.8.0.
On most devices setup works perfectly (I followed Set up crash reporting). But on small percentage of devices (it is actually crash with the highest occurrence) it crashes when I try to initialize Remote Config in Application onCreate method.
java.lang.RuntimeException: Unable to create application com.company.application.AppApplication: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.company.application. Make sure to call FirebaseApp.initializeApp(Context) first.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6429)
at android.app.ActivityThread.access$1800(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7329)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.company.application. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.a.d(Unknown Source)
at com.google.firebase.b.a.a(Unknown Source)
at com.company.application.d.a.a(SourceFile:21)
at com.company.application.AppApplication.onCreate(SourceFile:76)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6426)
... 8 more
Prior to version 10.0.0, Firebase Crash created an additional process in your app named background_crash. An instance of your AppApplication class is created and executed for each process in your app, including background_crash.
If you want to perform initialization of Firebase services in your application class, you need to add a guard to prevent the initialization from being performed in background_crash. On way to do that is:
if (!FirebaseApp.getApps(this).isEmpty()) {
// Not in crash process. Do your Remote Config init here.
}
Another solution is to upgrade to the latest version of Firebase, 10.0.1.
Assuming this answer is valid, I can't explain why the failure only occurs on some devices, unless the version of Google Play Services installed on the device is a factor, and the failing devices have an older version.
set classpath 'com.google.gms:google-services:4.0.1' in dependencies.
Implement the androidTestImplementation dependencies :
androidTestImplementation('com.android.support.test.espresso:espresso-core:.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
I'm implementing Smooch in Android app, I use latest version of Smooch(4.0.5) and in my App, I use Google play service v9.6.1. And the app crashes when I start.
In Application class:
Smooch.init(this, BuildConfig.SMOOCH_APP_TOKEN);
This is crash logs:
java.lang.NoSuchMethodError: No static method zzb(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzab; or its super classes (declaration of 'com.google.android.gms.common.internal.zzab' appears in /data/app/com.***.***/base.apk)
at com.google.firebase.provider.FirebaseInitProvider.zza(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:6762)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6357)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6297)
at android.app.ActivityThread.access$1800(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1860)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
I notice that Smooch v4.0.5 is using Firebase v9.4.0 which is not compatible with Google play service v9.6.1. So how can I fix this crash (I can not downgrade Google play service in my app for some reasons)
There have been known issues when using different versions of Firebase and Play Services. To fix this, you can update the Firebase version in your project to be in sync with your Play Services version. Include the Firebase dependency in your project's build.gradle file and set both to the same version, it will override the version provided by Smooch. Ex:
dependencies {
compile 'com.google.android.gms:play-services:9.6.1'
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.firebase:firebase-messaging:9.6.1'
// other dependencies
}
Recently I got feedback and also I was able to reproduce it easily on my Nexus 5 with cleared app data.
Simply, when adding compile 'com.google.firebase:firebase-crash:9.4.0' only to project dependencies I get following Exception:
09-14 00:47:54.899 3129-3129/com.szyk.myheart E/FirebaseCrash: Failed to initialize crash reporting
java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference
at bol.<init>(:com.google.android.gms.DynamiteModulesC:3201)
at com.google.firebase.crash.internal.api.FirebaseCrashApiImpl.init(:com.google.android.gms.DynamiteModulesC:67)
at bnu.onTransact(:com.google.android.gms.DynamiteModulesC:60)
at android.os.Binder.transact(Binder.java:387)
at com.google.firebase.crash.internal.zzd$zza$zza.zza(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.<init>(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.getInstance(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.zzek(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
The issue is more stranger, because once it will produce ANR and crash, then it works in next launches.
My dependencies:
compile 'com.google.firebase:firebase-core:9.4.0'
//not working compile 'com.google.firebase:firebase-crash:9.4.0'
compile 'com.google.firebase:firebase-invites:9.4.0'
compile 'com.google.firebase:firebase-ads:9.4.0'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.google.android.gms:play-services-plus:9.4.0'
compile 'com.google.android.gms:play-services-drive:9.4.0'
The issue has been introduced with the Google Play Services 9.6.80 (currently in rollout) and affects all the apps using the Firebase Crash reporting (despite of the version bundled in your app).
Temporary solution: disable Firebase Crash by removing the following entry from the build.gradle:
compile 'com.google.firebase:firebase-crash:9.x.x'
Long term solution: wait that Google releases a fixed version of the GPS before enabling Firebase Crash again.
UPDATE 09/16:
Google is rolling out a fixed version of Google Play Services (9.6.83) which addresses the issue with Firebase Crash.
Disable the Firebase Analytics Crash Reporting, use the below code inside app.gradle file.Hope this will help you
configurations {
all*.exclude group: 'com.google.firebase', module: 'firebase-crash'
}
9.6.83 still gives a different anr crash
Our app when pushed to Play Store Beta and when installed on devices crashes the first time on launch. Subsequently it works , but we cannot push to prod without understanding the issue.
Here is the ANR crash report
java.lang.RuntimeException: Unable to instantiate receiver com.google.android.gms.analytics.CampaignTrackingReceiver: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.analytics.CampaignTrackingReceiver"
Edit : We had to add compile 'com.google.android.gms:play-services-analytics:9.4.0' explicitly and the launch anr for first time got resolved. But I am not sure that was the fix as we dont use the library at all. Maybe Playstore fixed their bug to all apks?
Just for the record:
We solved the DynamiteModulesC NPE and Uncaught exception in Firebase runloop (3.0.0) by removing following line
//remove this "feature" if you should use it
FirebaseApp.setAutomaticResourceManagmentEnabled(true)
API description:
If set to true it indicates that Firebase should close database
connections automatically when the app is in the background. Disabled
by default.
(Might be, that we missed some configurations for correct usage of this feature, but App is working as expected after not enabling the ResourceManagment)
I am getting this crash in about 70% of devices in the market. However it never came up during testing.
public class MyApp extends Application{
public void onCreate() {
super.onCreate();
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
FirebaseAuth.getInstance().signInAnonymously();
}
}
This is the error.
Fatal Exception: java.lang.RuntimeException: Unable to create application com.mycompany.myapp.activities.MyApp: java.lang.ClassCastException: com.google.android.gms.internal.hc cannot be cast to com.google.firebase.auth.c
com.google.android.gms.internal.hc cannot be cast to com.google.firebase.auth.c
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4927)
at android.app.ActivityThread.access$1500(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5633)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:896)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: com.google.android.gms.internal.hc cannot be cast to com.google.firebase.auth.c
at com.google.android.gms.internal.aa.a(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.a(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.d(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)
at com.google.android.gms.internal.z.<init>(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.c(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.b(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.b(Unknown Source)
at com.tesseractmobile.solitairesdk.activities.SolitaireApp.onCreate(SolitaireApp.java:123)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4924)
I am using firebase 9.2.1
compile "com.google.firebase:firebase-core:${firebaseVersion}"
compile "com.google.firebase:firebase-database:${firebaseVersion}"
//For dynamic links
compile "com.google.firebase:firebase-invites:${firebaseVersion}"
//Authentication - for logging winning games
compile "com.google.firebase:firebase-auth:${firebaseVersion}"
Right now I am just disabling firebase in our app. We were just testing it to see how stable it is. I have no clue why it worked on all of our test devices then crashed this bad in the wild.
Update:
I was able to get a video of the issue using Firebase Test Lab. It happened when the robotest clicked on an Ad (Ad supported app) then came back to the app. So maybe it has something to do with FirebaseAuth.getInstance().signInAnonymously(); getting called twice? However Application.onCreate() should only be called once. I know there is a known bug with Firebase crash reporting that will cause two Application instances to be created but we are not using that sdk util they fix the issue.
I used Firebase Test Lab to find the issue. It crashed on one of their devices and I watched the video of what happened. Our app is ad supported. We don't click our own ads during testing so this never came up. The crash happens after a user clicks an ad and then reenters the app. The solution I found was the same as this issue. FirebaseApp with name [DEFAULT] doesn't exist
if (!FirebaseApp.getApps(this).isEmpty()){
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
FirebaseAuth.getInstance().signInAnonymously();
}
I think Application.onCreate() is called more than once. Though that should never happen.
EDIT: THIS ANSWER DOES NOT WORK
After a full week of testing by a 4 person QA team. Running 58 unit and connected tests with espresso on 7 test devices. Then running multiple tests on dozens of cloud devices using Google Test Lab. The problem never happened. Then on release day, 500 crashes in the first half hour!? 70% crash rate. So back to square one.
FINAL ANSWER: Proguard issue
I added these two line to my proguard-rules.pro
#Firebase Authentication
-keepattributes Signature
-keepattributes *Annotation*
Problem solved.
Hi I have a similar problem, after days without solution, I found what it's a version problem with the appcompat, so i Changed this:
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
to this:
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
in the app graddle and my problem solved, sorry for my English
Update your build.gradle:
// Firebase Gradle
compile "com.google.firebase:firebase-auth:9.4.0"
compile 'com.google.firebase:firebase-storage:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'