mikepenz / Android-Iconics

Android-Iconics - Use any icon font, or vector (.svg) as drawable in your application.
https://mikepenz.dev
Apache License 2.0
5.2k stars 615 forks source link

Error inflating class IconicsImageView #491

Closed TBog closed 4 years ago

TBog commented 4 years ago

About this issue

I forked phimpme-android to fix it because on my device it crashes on startup. The crash was similar to #470 and because phimpme used version 2.8.4 of iconics I migrated to 4.0.2 The migrated app can be found here: phimpme fork Now it still crashes on app start-up with the following log:

2020-01-15 15:16:52.032 1851-1851/org.fossasia.phimpme E/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.fossasia.phimpme, PID: 1851
    java.lang.RuntimeException: Unable to start activity ComponentInfo{org.fossasia.phimpme/org.fossasia.phimpme.gallery.activities.SplashScreen}: android.view.InflateException: Binary XML file line #137 in org.fossasia.phimpme:layout/activity_leafpic: Binary XML file line #49 in org.fossasia.phimpme:layout/activity_drawer: Error inflating class com.mikepenz.iconics.view.IconicsImageView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3447)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3594)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2146)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:7762)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
     Caused by: android.view.InflateException: Binary XML file line #137 in org.fossasia.phimpme:layout/activity_leafpic: Binary XML file line #49 in org.fossasia.phimpme:layout/activity_drawer: Error inflating class com.mikepenz.iconics.view.IconicsImageView
     Caused by: android.view.InflateException: Binary XML file line #49 in org.fossasia.phimpme:layout/activity_drawer: Error inflating class com.mikepenz.iconics.view.IconicsImageView
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at android.view.LayoutInflater.createView(LayoutInflater.java:854)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1126)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1126)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1126)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1126)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
        at android.view.LayoutInflater.parseInclude(LayoutInflater.java:1263)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1119)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
        at com.mikepenz.iconics.context.InternalLayoutInflater.inflate(InternalLayoutInflater.kt:80)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
        at org.fossasia.phimpme.base.BaseActivity.onCreate(BaseActivity.java:55)
        at org.fossasia.phimpme.base.ThemedActivity.onCreate(ThemedActivity.java:40)
        at org.fossasia.phimpme.base.SharedMediaActivity.onCreate(SharedMediaActivity.java:12)
        at org.fossasia.phimpme.gallery.activities.SplashScreen.onCreate(SplashScreen.java:63)
        at android.app.Activity.performCreate(Activity.java:7981)
        at android.app.Activity.performCreate(Activity.java:7970)
2020-01-15 15:16:52.078 1851-1851/org.fossasia.phimpme E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3594)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2146)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:7762)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
     Caused by: java.lang.AbstractMethodError: abstract method "android.graphics.Typeface com.mikepenz.iconics.typeface.ITypeface.getRawTypeface()"
        at com.mikepenz.iconics.IconicsDrawable.icon(IconicsDrawable.kt:372)
        at com.mikepenz.iconics.IconicsDrawable.icon(IconicsDrawable.kt:291)
        at com.mikepenz.iconics.context.IconicsAttrsExtractor.extract(IconicsAttrsExtractor.kt:90)
        at com.mikepenz.iconics.context.IconicsAttrsExtractor.extract(IconicsAttrsExtractor.kt:77)
        at com.mikepenz.iconics.internal.IconicsViewsAttrsApplier.getIconicsImageViewDrawable(IconicsViewsAttrsApplier.kt:56)
        at com.mikepenz.iconics.view.IconicsImageView.<init>(IconicsImageView.kt:41)
        at com.mikepenz.iconics.view.IconicsImageView.<init>(IconicsImageView.kt:30)
        at com.mikepenz.iconics.view.IconicsImageView.<init>(Unknown Source:6)

Details

    //icons
    implementation 'com.mikepenz:iconics-core:4.0.2@aar'
    implementation 'com.mikepenz:iconics-views:4.0.2@aar'
    implementation 'com.mikepenz:google-material-typeface:2.2.0.3.original@aar'
    implementation 'com.mikepenz:community-material-typeface:1.5.54.2@aar'
    implementation 'com.mikepenz:fontawesome-typeface:4.6.0.1@aar'
    implementation 'com.mikepenz:ionicons-typeface:+@aar'
    //google and support
    implementation "androidx.appcompat:appcompat:1.1.0"
    implementation "androidx.vectordrawable:vectordrawable-animated:1.1.0"
    implementation "androidx.legacy:legacy-support-v4:1.0.0"
    implementation "com.google.android.material:material:1.0.0"
    implementation "androidx.vectordrawable:vectordrawable:1.1.0"
    implementation "androidx.palette:palette:1.0.0"
    implementation "androidx.cardview:cardview:1.0.0"
    implementation "androidx.browser:browser:1.2.0"
    implementation "androidx.recyclerview:recyclerview:1.1.0"
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

Possible fix

I found a possible fix that seems related. https://github.com/InflationX/ViewPump/commit/8e4b4fb8fbcb71b195346c038142f8ab184b11aa

mikepenz commented 4 years ago

@TBog please update to the compatible typefaces.

https://github.com/mikepenz/Android-Iconics#2-choose-your-desired-fonts

Only v4 (which is kotlin (first/only) only supports typefaces with the -kotlin postfix