Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font registration fails / not working #498

Closed
2 tasks
MFlisar opened this issue Apr 8, 2020 · 9 comments
Closed
2 tasks

Font registration fails / not working #498

MFlisar opened this issue Apr 8, 2020 · 9 comments

Comments

@MFlisar
Copy link
Contributor

MFlisar commented Apr 8, 2020

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
@MFlisar MFlisar changed the title Font registration fails Font registration fails / not working Apr 8, 2020
@mikepenz
Copy link
Owner

mikepenz commented Apr 8, 2020

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

@MFlisar
Copy link
Contributor Author

MFlisar commented Apr 8, 2020

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

@mikepenz
Copy link
Owner

mikepenz commented Apr 8, 2020

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.

@MFlisar
Copy link
Contributor Author

MFlisar commented Apr 8, 2020

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.

@mikepenz
Copy link
Owner

mikepenz commented Apr 8, 2020

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 :/

@MFlisar
Copy link
Contributor Author

MFlisar commented Apr 8, 2020

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.

@mikepenz
Copy link
Owner

@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

@mikepenz
Copy link
Owner

Do the init like this:

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

@MFlisar
Copy link
Contributor Author

MFlisar commented Apr 15, 2020

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants