TheFinestArtist / FinestWebView-Android

Beautiful and customizable Android Activity that shows web pages within an app.
https://finestwebview.web.app
2.32k stars 531 forks source link

Getting NullPointerException on Bitmap.getWidth() #24

Closed 3lywa closed 8 years ago

3lywa commented 8 years ago

I keep getting the following exception whenever i try to use: new FinestWebView.Builder(activity).show(url);

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.go.snoolabs/com.thefinestartist.finestwebview.FinestWebViewActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                     at android.os.Looper.loop(Looper.java:148)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
                                                                     at com.thefinestartist.finestwebview.helpers.BitmapHelper.getColoredBitmap(BitmapHelper.java:22)
                                                                     at com.thefinestartist.finestwebview.helpers.BitmapHelper.getColoredBitmap(BitmapHelper.java:38)
                                                                     at com.thefinestartist.finestwebview.FinestWebViewActivity.updateIcon(FinestWebViewActivity.java:809)
                                                                     at com.thefinestartist.finestwebview.FinestWebViewActivity.layoutViews(FinestWebViewActivity.java:450)
                                                                     at com.thefinestartist.finestwebview.FinestWebViewActivity.onCreate(FinestWebViewActivity.java:832)
                                                                     at android.app.Activity.performCreate(Activity.java:6237)
                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                     at android.os.Looper.loop(Looper.java:148) 
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5417) 
TheFinestArtist commented 8 years ago

@3lywa I think BitmapFactory.decodeResource(context.getResources(), drawableRes) returns null. Can you clean your project and build it again?

Let me know if this issue is keep occurring. I need more information such as build version and device name.

3lywa commented 8 years ago

I've tried to clean and rebuild with no luck. I've tried the latest build 17 as well as the previous 16.

The test device that i'm using is Nexus 6

TheFinestArtist commented 8 years ago

@3lywa I will try to look deeper! Thanks for your comments!

TheFinestArtist commented 8 years ago

Hi @3lywa, there is good new! Google released new version of support libraries and VectorDrawableCompat is not available.

I just added vector image files and updated all the icon drawable from png to xml. I removed getColoredBitmap() method and there won't be any of this issues.