Calligraphy icon indicating copy to clipboard operation
Calligraphy copied to clipboard

Android application crashes for calligraphy library for Android Q

Open angelaheely opened this issue 6 years ago • 17 comments

Hey @chrisjenx , I am using your calligraphy library for my app and seems like it crashes right on app launch for Android Q. I have seen other people complain about this lately aswell. I have the latest version of your lib 2.3.0 and still face this issue. Any update if you are aware of this or if I need to do anything on my end to sort this out? Here's the crash report: Caused by: android.view.InflateException: Binary XML file line #17 in com.myapp.dev:layout/abc_screen_simple: Binary XML file line #17 in com.myapp.dev:layout/abc_screen_simple: Error inflating class android.support.v7.widget.FitWindowsLinearLayout Caused by: android.view.InflateException: Binary XML file line #17 in commyapp.dev:layout/abc_screen_simple: Error inflating class android.support.v7.widget.FitWindowsLinearLayout Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Field.get(java.lang.Object)' on a null object reference at uk.co.chrisjenx.calligraphy.ReflectionUtils.getValue(ReflectionUtils.java:29) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.createCustomViewInternal(CalligraphyLayoutInflater.java:203) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.access$000(CalligraphyLayoutInflater.java:20) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$PrivateWrapperFactory2.onCreateView(CalligraphyLayoutInflater.java:302) at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:239) at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1069) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:997) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961) at android.view.LayoutInflater.inflate(LayoutInflater.java:659) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) at android.view.LayoutInflater.inflate(LayoutInflater.java:534) at android.view.LayoutInflater.inflate(LayoutInflater.java:481) at android.support.v7.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:631) at android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:518) at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:466) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.myapp.dev.ui.splash.SplashActivity.onCreate(SplashActivity.java:36) at android.app.Activity.performCreate(Activity.java:7802) at android.app.Activity.performCreate(Activity.java:7791) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)

angelaheely avatar Aug 14 '19 13:08 angelaheely

Fixed in ViewPump, we worked around the issue, you'll need to upgrade to that.

chrisjenx avatar Aug 14 '19 15:08 chrisjenx

You mean use this : implementation 'io.github.inflationx:calligraphy3:3.1.1',replace :compile 'uk.co.chrisjenx:calligraphy:2.3.0' ?

goodluckier avatar Aug 28 '19 10:08 goodluckier

is it backwards compatible though? the new viewpump crashes for previous OS version (P and below.

angelaheely avatar Sep 10 '19 20:09 angelaheely

Fixed in ViewPump, we worked around the issue, you'll need to upgrade to that.

@chrisjenx exactly what changes are required to provide support for an old project where this old calligraphy library used, instead of changing to View pump, because that will be a major change for us.

Rony97376 avatar Sep 11 '19 09:09 Rony97376

Fixed in ViewPump, we worked around the issue, you'll need to upgrade to that.

@chrisjenx exactly what changes are required to provide support for an old project where this old calligraphy library used, instead of changing to View pump, because that will be a major change for us.

ViewPump is a very small migration, also as deps are transitive, you only need to follow the setup for Calligraphy 3 Setup.

There are many changes to make this injector valid, you would literally need to backport ViewPump back to this - it's much less work to move to VP.

chrisjenx avatar Sep 13 '19 04:09 chrisjenx

migrate to Calligraphy 3

pechpijit avatar Sep 16 '19 10:09 pechpijit

Fixed in ViewPump, we worked around the issue, you'll need to upgrade to that.

@chrisjenx exactly what changes are required to provide support for an old project where this old calligraphy library used, instead of changing to View pump, because that will be a major change for us.

ViewPump is a very small migration, also as deps are transitive, you only need to follow the setup for Calligraphy 3 Setup.

There are many changes to make this injector valid, you would literally need to backport ViewPump back to this - it's much less work to move to VP.

What about the crash that older target sdk version apps are facing, if they update to Calligraphy 3 ? Looks like some other Calligraphy library will be needed, because you are not providing a backwards compatible solution.

@chrisjenx Please use https://www.xda-developers.com/android-development-bypass-hidden-api-restrictions/ article to by pass reflection api restrictions by google, so that your library can be used for backwards compatibility.

aishwarya-agarwal avatar Mar 11 '20 12:03 aishwarya-agarwal

Fixed in ViewPump, we worked around the issue, you'll need to upgrade to that.

@chrisjenx exactly what changes are required to provide support for an old project where this old calligraphy library used, instead of changing to View pump, because that will be a major change for us.

ViewPump is a very small migration, also as deps are transitive, you only need to follow the setup for Calligraphy 3 Setup. There are many changes to make this injector valid, you would literally need to backport ViewPump back to this - it's much less work to move to VP.

What about the crash that older target sdk version apps are facing, if they update to Calligraphy 3 ? Looks like some other Calligraphy library will be needed, because you are not providing a backwards compatible solution.

@chrisjenx Please use https://www.xda-developers.com/android-development-bypass-hidden-api-restrictions/ article to by pass reflection api restrictions by google, so that your library can be used for backwards compatibility.

It's not an api restriction issue, the implementation on Q+ is different (to the point the hack isn't really needed on Q+). Support here is dead, we're not going to maintain two libraries that do the same thing, so as people have mentioned multiple times, move to Calligraphy 3 - it is a fairly trivial change and gives you much more flexibility going forwards.

chrisjenx avatar Mar 11 '20 14:03 chrisjenx

Fixed in ViewPump, we worked around the issue, you'll need to upgrade to that.

@chrisjenx exactly what changes are required to provide support for an old project where this old calligraphy library used, instead of changing to View pump, because that will be a major change for us.

ViewPump is a very small migration, also as deps are transitive, you only need to follow the setup for Calligraphy 3 Setup. There are many changes to make this injector valid, you would literally need to backport ViewPump back to this - it's much less work to move to VP.

What about the crash that older target sdk version apps are facing, if they update to Calligraphy 3 ? Looks like some other Calligraphy library will be needed, because you are not providing a backwards compatible solution. @chrisjenx Please use https://www.xda-developers.com/android-development-bypass-hidden-api-restrictions/ article to by pass reflection api restrictions by google, so that your library can be used for backwards compatibility.

It's not an api restriction issue, the implementation on Q+ is different (to the point the hack isn't really needed on Q+). Support here is dead, we're not going to maintain two libraries that do the same thing, so as people have mentioned multiple times, move to Calligraphy 3 - it is a fairly trivial change and gives you much more flexibility going forwards.

What about the crash that older target sdk version apps are facing, if they update to Calligraphy 3?

aishwarya-agarwal avatar Mar 11 '20 17:03 aishwarya-agarwal

migrate to Calligraphy 3

Thank you so much bro

pvtai avatar Mar 11 '20 18:03 pvtai

What about the crash that older target sdk version apps are facing, if they update to Calligraphy 3?

No idea, but if it's problem still on ViewPump + Calligraphy 3 then we'll fix it over there. 👍

chrisjenx avatar Mar 11 '20 18:03 chrisjenx

CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() .setDefaultFontPath("fonts/Roboto-Regular.ttf") .setFontAttrId(R.attr.fontPath) .disableCustomViewInflation() .build());

write this line ---- disableCustomViewInflation()

VivekRai29 avatar Sep 24 '20 10:09 VivekRai29

CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() .setDefaultFontPath("fonts/Roboto-Regular.ttf") .setFontAttrId(R.attr.fontPath) .disableCustomViewInflation() .build());

write this line ---- disableCustomViewInflation()

it helped me, thank you

PavelScherbakov avatar Nov 27 '20 10:11 PavelScherbakov

CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() .setDefaultFontPath("fonts/Roboto-Regular.ttf") .setFontAttrId(R.attr.fontPath) .disableCustomViewInflation() .build());

write this line ---- disableCustomViewInflation()

you saved my day, thanks.

phatdq101 avatar Dec 03 '20 07:12 phatdq101

migrate to Calligraphy 3

Does it support lower versions like Android L,M ?

ArnoldBrown avatar Dec 04 '20 06:12 ArnoldBrown

migrate to Calligraphy 3

Does it support lower versions like Android L,M ?

Yes

chrisjenx avatar Dec 14 '20 18:12 chrisjenx

在 ViewPump 中已修复,我们解决了该问题,您需要升级到该问题。

@chrisjenx确切地需要进行哪些更改才能为使用此旧书法库的旧项目提供支持,而不是更改为 View pump,因为这对我们来说将是一个重大变化。

ViewPump 是一个非常小的迁移,而且由于 deps 是可传递的,您只需要按照 Calligraphy 3 Setup 的设置进行操作即可。

有很多改变可以使这个注入器有效,你实际上需要将 ViewPump 反向移植回这个——转移到 VP 的工作要少得多。

Fixed in ViewPump, we worked around the issue, you'll need to upgrade to that.

@chrisjenx exactly what changes are required to provide support for an old project where this old calligraphy library used, instead of changing to View pump, because that will be a major change for us.

ViewPump is a very small migration, also as deps are transitive, you only need to follow the setup for Calligraphy 3 Setup.

There are many changes to make this injector valid, you would literally need to backport ViewPump back to this - it's much less work to move to VP.

I try to ViewPump ,but Failed resolution of: Lio/github/inflationx/viewpump/ViewPump;

LvBing1995 avatar Jun 10 '22 08:06 LvBing1995