InflationX / ViewPump

View Inflation you can intercept.
Apache License 2.0
899 stars 61 forks source link

Crash due to mConstructorArgs not found when targeting Q #48

Closed sraiteri closed 5 years ago

sraiteri commented 5 years ago

I've noticed a crash on Android Q Beta 2 using ViewPump 2.0.2 with Calligraphy 3.1.1. Seems to happen on ViewPumpContextWrapper.wrap() :

compileSdkVersion = android-Q targetSdkVersion = Q

Offending code:

    override fun attachBaseContext(newBase: Context?) {
        newBase?.let {
            super.attachBaseContext(ViewPumpContextWrapper.wrap(it))
        }
    }

Crash log details:

Caused by: java.lang.NoSuchFieldException: No field mConstructorArgs in class Landroid/view/LayoutInflater; (declaration of 'android.view.LayoutInflater' appears in /system/framework/framework.jar!classes3.dex)
        at java.lang.Class.getDeclaredField(Native Method)
        at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater$Companion$CONSTRUCTOR_ARGS_FIELD$2.invoke(-ViewPumpLayoutInflater.kt:421)
        at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater$Companion$CONSTRUCTOR_ARGS_FIELD$2.invoke(-ViewPumpLayoutInflater.kt:418)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater$Companion.getCONSTRUCTOR_ARGS_FIELD(Unknown Source:11)
        at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater$Companion.access$getCONSTRUCTOR_ARGS_FIELD$p(-ViewPumpLayoutInflater.kt:418)
        at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater.createCustomViewInternal(-ViewPumpLayoutInflater.kt:205)
        at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater.access$createCustomViewInternal(-ViewPumpLayoutInflater.kt:17)
        at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater$PrivateWrapperFactory2ViewCreator.onCreateView(-ViewPumpLayoutInflater.kt:413)
        at io.github.inflationx.viewpump.internal.-FallbackViewCreationInterceptor.intercept(-FallbackViewCreationInterceptor.kt:14)
        at io.github.inflationx.viewpump.internal.-InterceptorChain.proceed(-InterceptorChain.kt:30)
        at io.github.inflationx.calligraphy3.CalligraphyInterceptor.intercept(CalligraphyInterceptor.java:18)
        at io.github.inflationx.viewpump.internal.-InterceptorChain.proceed(-InterceptorChain.kt:30)
        at io.github.inflationx.viewpump.ViewPump.inflate(ViewPump.kt:36)
        at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater$PrivateWrapperFactory2.onCreateView(-ViewPumpLayoutInflater.kt:391)
        at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:235)
        at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1065)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:995)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:670)
        at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater.inflate(-ViewPumpLayoutInflater.kt:53)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:545)

Given Android Q is only in Beta 2 this is more a heads up than a request for a fix right now :smile:.

amolgupta commented 5 years ago

see https://github.com/InflationX/ViewPump/issues/21

jbarr21 commented 5 years ago

issue # 21 is unrelated