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

NullPointerException: Attempt to invoke virtual method 'int android.content.res.TypedArray.getDimensionPixelSize(int, int)' on a null object reference #19

Open
ductranit opened this issue Sep 28, 2017 · 1 comment

Comments

@ductranit
Copy link

hi, got a crash log from device HUAWEI like when load this view:
Fatal Exception: java.lang.RuntimeException: Unable to start activity

ComponentInfo{com.mz.tkw/com.mz.tkwui.SplashActivity}: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class com.github.jorgecastillo.FillableLoader
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2638)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2720)
       at android.app.ActivityThread.access$900(ActivityThread.java:196)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1538)
       at android.os.Handler.dispatchMessage(Handler.java:111)
       at android.os.Looper.loop(Looper.java:210)
       at android.app.ActivityThread.main(ActivityThread.java:5988)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:852)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742)
Caused by android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class com.github.jorgecastillo.FillableLoader
       at android.view.LayoutInflater.inflate(LayoutInflater.java:561)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:437)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
       at android.support.v7.app.AppCompatDelegateImplV9.setContentView(SourceFile:292)
       at android.support.v7.app.AppCompatActivity.setContentView(SourceFile:140)
       at com.mz.tkwui.SplashActivity.setContentView(SourceFile:51)
       at android.app.Activity.performCreate(Activity.java:6444)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2720)
       at android.app.ActivityThread.access$900(ActivityThread.java:196)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1538)
       at android.os.Handler.dispatchMessage(Handler.java:111)
       at android.os.Looper.loop(Looper.java:210)
       at android.app.ActivityThread.main(ActivityThread.java:5988)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:852)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742)
Caused by android.view.InflateException: Binary XML file line #10: Error inflating class com.github.jorgecastillo.FillableLoader
       at android.view.LayoutInflater.createView(LayoutInflater.java:672)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:791)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:731)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:862)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:825)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:537)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:437)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
       at android.support.v7.app.AppCompatDelegateImplV9.setContentView(SourceFile:292)
       at android.support.v7.app.AppCompatActivity.setContentView(SourceFile:140)
       at com.magez.ScreenEffect.ui.activities.SplashActivity_.onCreate(SourceFile:40)
       at android.app.Activity.performCreate(Activity.java:6444)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2720)
       at android.app.ActivityThread.access$900(ActivityThread.java:196)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1538)
       at android.os.Handler.dispatchMessage(Handler.java:111)
       at android.os.Looper.loop(Looper.java:210)
       at android.app.ActivityThread.main(ActivityThread.java:5988)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:852)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742)
Caused by java.lang.reflect.InvocationTargetException
       at java.lang.reflect.Constructor.newInstance(Constructor.java)
       at android.view.LayoutInflater.createView(LayoutInflater.java:641)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:791)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:731)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:862)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:825)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:537)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:437)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
       at android.support.v7.app.AppCompatDelegateImplV9.setContentView(SourceFile:292)
       at android.support.v7.app.AppCompatActivity.setContentView(SourceFile:140)
       at com.magez.ScreenEffect.ui.activities.SplashActivity_.setContentView(SourceFile:51)
       at com.magez.ScreenEffect.ui.activities.SplashActivity_.onCreate(SourceFile:40)
       at android.app.Activity.performCreate(Activity.java:6444)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2720)
       at android.app.ActivityThread.access$900(ActivityThread.java:196)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1538)
       at android.os.Handler.dispatchMessage(Handler.java:111)
       at android.os.Looper.loop(Looper.java:210)
       at android.app.ActivityThread.main(ActivityThread.java:5988)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:852)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.res.TypedArray.getDimensionPixelSize(int, int)' on a null object reference
       at com.github.jorgecastillo.attributes.AttributeExtractorImpl.getStrokeWidth(SourceFile:72)
       at com.github.jorgecastillo.FillableLoader.initAttrs(SourceFile:139)
       at com.github.jorgecastillo.FillableLoader.(SourceFile)
       at java.lang.reflect.Constructor.newInstance(Constructor.java)
       at android.view.LayoutInflater.createView(LayoutInflater.java:641)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:791)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:731)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:862)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:825)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:537)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:437)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
       at android.support.v7.app.AppCompatDelegateImplV9.setContentView(SourceFile:292)
       at android.support.v7.app.AppCompatActivity.setContentView(SourceFile:140)
       at com.magez.ScreenEffect.ui.activities.SplashActivity_.setContentView(SourceFile:51)
       at com.magez.ScreenEffect.ui.activities.SplashActivity_.onCreate(SourceFile:40)
       at android.app.Activity.performCreate(Activity.java:6444)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2720)
       at android.app.ActivityThread.access$900(ActivityThread.java:196)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1538)
       at android.os.Handler.dispatchMessage(Handler.java:111)
       at android.os.Looper.loop(Looper.java:210)
       at android.app.ActivityThread.main(ActivityThread.java:5988)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:852)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742)

Is there any suggestion?

@amylinn
Copy link

amylinn commented Oct 4, 2017

Looks like the weakReference to weakAttributeArray gets null somehow

private TypedArray attributeArray() {
if (weakAttributeArray == null) {
weakAttributeArray = new WeakReference<>(context().getTheme()
.obtainStyledAttributes(weakAttrs.get(), R.styleable.FillableLoader, 0, 0));
}
return weakAttributeArray.get();
}
when calling getDimensionPixelSize
@Override public int getStrokeWidth() {
return attributeArray().getDimensionPixelSize(R.styleable.FillableLoader_fl_strokeWidth, context().
getResources().getDimensionPixelSize(R.dimen.strokeWidth));
}
.

I think there is more information necessary - which device exactly, how do you use it, etc. :)

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

2 participants