mikepenz/Android-Iconics

Font registration fails / not working

MFlisar opened this issue · 9 comments

About this issue

Iconics.Font is of size 0

I do following in my app:

  • init Iconics in my application Iconics.init(this)
  • I do not use IconicsViews
  • I use xml menus and the IconicsMenuInflaterUtil.inflate function

I don't see icons in my menus because the font is not found at this location:

Iconics.findFont(icon.iconPrefix)?.let { icon(it.getIcon(icon.clearedIconName)) }

Is there anything I'm missing here?

Details

  •  Used library version: 5.0.1
  •  android x version:
    androidx = [
    supportv4 : "1.0.0",
    fragment : "1.2.1",
    appcompat : "1.1.0",
    material : "1.2.0-alpha05"
    ]
  • Test Device: Samsung S9 running android 9
  • font version: com.mikepenz:google-material-typeface:3.0.1.4.original-kotlin@aar

If the font is not registered / not auto detected you can register it manually and actually skip the usual init.

https://github.com/mikepenz/Android-Iconics/blob/develop/app/src/main/java/com/mikepenz/iconics/sample/CustomApplication.kt#L29-L42

But why could the auto registration fail? It should work in general, shouldn't it? Manual registration solves the problem of course

if the font was not used programmatically in a different place. the xml parser may not have access to the resources so it won't be able to search for them.

But I could have another look this weekend.

I thought something similar - my tested solution was to add the font in my main app module as well (I use a multi module setup and only add the fonts via implementation to those modules where needed) but without success.

No what I meant is if you use a IconicsDrawable programmatically somewhere with the font it should also result in registering it.

but your comment may also mean that obfuscation removes something which breaks the reflection detection :/

No what I meant is if you use a IconicsDrawable programmatically somewhere with the font it should also result in registering it.

I don't think this is true - I can't find anything in code that would do this. And simply creating a IconicsDrawable with an icon from a font does not solve the problem in my app - but manual font registration does.

@MFlisar could it be that that you use a different package name, or that proguard results in your packages be different than expected?

Adding a method to provide the R fields manually for such cases in v5.0.2

Do the init like this:

Iconics.init(context, R.string::class.java.fields)

Special setup

What I do is following:

 defaultConfig {
    // neue App ID
    applicationId "com.my.app.new.name"
}

Whereas my packages are located under com.my.app. Could this be the reason for the problems? There is no special proguarding in my app, I'm testing with my debug build without proguard anyways.

v5.0.2

I tried the new init method without success (I used my main apps R file)