JoanZapata / android-iconify

Android integration of multiple icon providers such as FontAwesome, Entypo, Typicons,...
http://joanzapata.com/android-iconify
Other
3.93k stars 526 forks source link

Iconify in application without Application class #116

Closed datmt closed 9 years ago

datmt commented 9 years ago

Hello,

First of all, I want to thank you for the exceptional library. It has helped me a lot.

Here is my question. I have an application that use one activity and many fragments. My application doesn't extend Application class. Normally, the app runs just fine; however, today, I had this crash:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.stavira.ipaphonetics/com.stavira.ipaphonetics.Launcher}: java.lang.IllegalArgumentException: Can't add twice the same font "iconify/android-iconify-fontawesome.ttf", please initialize Iconify in your Application and not in your Activity. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2252) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2301) at android.app.ActivityThread.access$800(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5196) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.IllegalArgumentException: Can't add twice the same font "iconify/android-iconify-fontawesome.ttf", please initialize Iconify in your Application and not in your Activity. at com.joanzapata.iconify.Iconify.addIconFontDescriptor(Unknown Source) at com.joanzapata.iconify.Iconify.access$000(Unknown Source) at com.joanzapata.iconify.Iconify$IconifyInitializer.<init>(Unknown Source) at com.joanzapata.iconify.Iconify.with(Unknown Source) at com.stavira.ipaphonetics.Launcher.onCreate(Unknown Source) at android.app.Activity.performCreate(Activity.java:5240) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2216)

I use fontawesome only.

Could you tell me where should I add the iconify method to avoid this problem?

Thanks!

datmt commented 9 years ago

This is my code: public class Launcher extends AppCompatActivity {

.......

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Iconify.with(new FontAwesomeModule());`
JoanZapata commented 9 years ago

This was fixed in 2.0.9.