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

Crash due to mConstructorArgs not found when targeting Q #48

Closed
sraiteri opened this issue Apr 28, 2019 · 2 comments
Closed

Crash due to mConstructorArgs not found when targeting Q #48

sraiteri opened this issue Apr 28, 2019 · 2 comments
Assignees

Comments

@sraiteri
Copy link

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 😄.

@amolgupta
Copy link

see #21

@jbarr21 jbarr21 changed the title Crash on Android Q Beta 2 Crash due to mConstructorArgs not found when targeting Q May 30, 2019
@jbarr21
Copy link
Contributor

jbarr21 commented May 30, 2019

issue # 21 is unrelated

@jbarr21 jbarr21 self-assigned this Jun 4, 2019
jbarr21 added a commit that referenced this issue Jun 7, 2019
In order to fix the NonSdkApiUsedViolation reported in #21 and #48, we no longer set the context or attrs on the recently created custom view. This was already fixed in P, so the work is no longer necessary. Thanks to @chrisjenx for discovering this.
@jbarr21 jbarr21 closed this as completed Jun 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants