InflationX / Calligraphy

Custom fonts in Android the easy way...
Apache License 2.0
1.09k stars 81 forks source link

I get android.content.res.Resources$NotFoundException. How can I solve this? #52

Open EcemMineOz opened 4 years ago

EcemMineOz commented 4 years ago

I use version 3.1.1.

Caused by android.content.res.Resources$NotFoundException Unable to find resource ID #0x7f090543 android.content.res.ResourcesImpl.getResourceEntryName (ResourcesImpl.java:289) android.content.res.Resources.getResourceEntryName (Resources.java:1996) io.github.inflationx.calligraphy3.Calligraphy.matchesResourceIdName (Calligraphy.java:94) io.github.inflationx.calligraphy3.Calligraphy.isActionBarTitle (Calligraphy.java:57) io.github.inflationx.calligraphy3.Calligraphy.getStyleForTextView (Calligraphy.java:33) io.github.inflationx.calligraphy3.Calligraphy.onViewCreatedInternal (Calligraphy.java:139) io.github.inflationx.calligraphy3.Calligraphy.onViewCreated (Calligraphy.java:117) io.github.inflationx.calligraphy3.CalligraphyInterceptor.intercept (CalligraphyInterceptor.java:19) io.github.inflationx.viewpump.internal.-InterceptorChain.proceed (-InterceptorChain.java:30) io.github.inflationx.viewpump.ViewPump.inflate (ViewPump.java:36) io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater$WrapperFactory2.onCreateView (-ViewPumpLayoutInflater.java:358) android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:772)

chrisjenx commented 3 years ago

If you haven't already try updating to ViewPump 2.0.3

Girish-Setti commented 2 years ago

still having the issue @chrisjenx

chrisjenx commented 2 years ago

Phone, xml, version, etc

Petr-Kubista commented 1 year ago

I also encountered this issue. I have multiple build flavours. The missing resource is a drawable, which I have the source for in the main res directory for the 5 standard screen density options. Then it is referenced in drawables.xml in the main resources directory: <item name="welcome_background" type="drawable">@drawable/xx_welcome_background</item> and used in a layout which crashes.

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/welcome_background" />

The project is using the following versions:

implementation "io.github.inflationx:calligraphy3:3.1.1"
implementation 'io.github.inflationx:viewpump:2.1.1'

I got the reports from Firebase Crashlytics for various devices with Android ranging from 12, through 10 to 8.1, devices like Google Nexus 5X, Xiaomi, Huawei

The code that crashes is an extension of CalligraphyInterceptor:

    @Override
    public InflateResult intercept(Chain chain) {
        try {
            InflateResult result = chain.proceed(chain.request());
            View view = result.view();

            if (
                    view instanceof CustomFontTextView
                            || view instanceof CustomFontButton
                            || view instanceof CustomFontToolbar
                            || view instanceof RelativeTimeTextView
                            || view instanceof ExpandableTextView
            ) {
                return result.toBuilder().build();
            }
        } catch (RuntimeException e) {
            Timber.w(e, "Unable to use custom font through CalligraphyInterceptor");
        }

        return super.intercept(chain);
    }