question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Class cast exception android.app.ContextImpl when using with Firebase

See original GitHub issue

The Issue is during FCM integration

Exception java.lang.RuntimeException: Unable to start receiver com.google.firebase.iid.FirebaseInstanceIdInternalReceiver: java.lang.ClassCastException: uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper cannot be cast to android.app.ContextImpl
android.app.ActivityThread.handleReceiver (ActivityThread.java:2750)
android.app.ActivityThread.access$1800 (ActivityThread.java:154)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1431)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:148)
android.app.ActivityThread.main (ActivityThread.java:5443)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:728)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:618)
arrow_drop_down
Caused by java.lang.ClassCastException: uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper cannot be cast to android.app.ContextImpl

When i comment the below ApplicationController code, it works fine

 @Override
    public void onCreate() {
        super.onCreate();
        CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
                .setDefaultFontPath("fonts/RobotoCondensedLight.ttf")
                .setFontAttrId(R.attr.fontPath)
                .build()
        );
    }


    @Override
    protected void attachBaseContext(Context base) {
        MultiDex.install(this);
        super.attachBaseContext(CalligraphyContextWrapper.wrap(base));
    }

FirebaseInstanceIdInternalReceiver is not created by me so i could’t manage the context there.

I tried solutions of your different lib at below url but didn’t found any solution https://github.com/mikepenz/Android-Iconics/issues/180

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
chrisjenxcommented, Jan 12, 2017

@amitkaira87 see #211

Wrap the Activity Context:

@Override
protected void attachBaseContext(Context newBase) {
    super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}

Activity NOT Application

0reactions
chrisjenxcommented, Feb 1, 2021

We Deprecated this lib in favor of https://github.com/InflationX/Calligraphy about 3ish years ago. It’s a pretty easy migration.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.ClassCastException: android.app.ContextImpl
... it shows that it casts the context to Activity . Try using this instead of getBaseContext , since you're calling from an...
Read more >
Class cast exception android.app.ContextImpl when using ...
The Issue is during FCM integration. Exception java.lang.RuntimeException: Unable to start receiver com.google.firebase.iid.
Read more >
android.app.ContextImpl cannot be cast to android ... - Lynxbee -
Solved: java.lang.ClassCastException: android.app.ContextImpl cannot be cast to android.app.Activity.
Read more >
Android – Unable to start receiver com.google.firebase.iid ...
My app integrates FCM to receive push notifications and it works okay. However, I am facing issue that on installation it crashes randomly....
Read more >
Android Question [SOLVED] App crashes after SDK update
It didn't specifically say that it fixes crashes related to the latest Firebase SDK, however I updated from v1.01 & it fixed the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found