JoaquimLey / faboptions

A multi-functional FAB component with customizable options
http://joaquimley.com/
Apache License 2.0
1.04k stars 140 forks source link

No static method getScreenWidthDp Error #43

Closed sohail77 closed 6 years ago

sohail77 commented 6 years ago

I implemented the library as in the sample and whenever i start the activity containing the fab my app force closes displaying the following error

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.sohail.spoonfulofhyderabad, PID: 15775 java.lang.NoSuchMethodError: No static method getScreenWidthDp(Landroid/content/res/Resources;)I in class Landroid/support/v4/content/res/ConfigurationHelper; or its super classes (declaration of 'android.support.v4.content.res.ConfigurationHelper' appears in /data/app/com.sohail.spoonfulofhyderabad-SJqeyfSr8m7ThbETpbtlWA==/base.apk) at android.support.design.widget.FloatingActionButton.getSizeDimension(FloatingActionButton.java:442) at android.support.design.widget.FloatingActionButton.getSizeDimension(FloatingActionButton.java:434) at android.support.design.widget.FloatingActionButton.onMeasure(FloatingActionButton.java:189) at android.view.View.measure(View.java:22002) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:22002) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at com.joaquimley.faboptions.FabOptions.onMeasure(FabOptions.java:284) at android.view.View.measure(View.java:22002) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461) at android.view.View.measure(View.java:22002) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139) at android.view.View.measure(View.java:22002) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:22002) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:22002) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:22002) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at com.android.internal.policy.DecorView.onMeasure(DecorView.java:721) at android.view.View.measure(View.java:22002) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2410) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1498) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1751) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1386) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6733) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911) at android.view.Choreographer.doCallbacks(Choreographer.java:723) at android.view.Choreographer.doFrame(Choreographer.java:658) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

sohail77 commented 6 years ago

I found the solution, there was no issue with the library I just needed to update my support dependency in gradle

deltamish commented 6 years ago

Update to which version ? Could brief a little more on the solution . I am facing the same issue

JoaquimLey commented 6 years ago

@deltamish can you tell me your support library version?

th-m commented 6 years ago

I have this same issue after adding react-native-firebase to my react-native project. Can someone tell me what support dependency I should be using?

JoaquimLey commented 6 years ago

@th-m I've never tried to add react-native with this component, but I would say this is not directly related to the component.

The component works fine in a normal Android environment, so I would suggest searching for cues on similar hybrid projects.

danielidt commented 6 years ago

Ok guys, I think i fixed it. I had to add implementation 'com.android.support:appcompat-v7:26.0.2' to my dependencies in fileapp/build.gradle

I was using compileSdkVersion = 27 and found that I could keep that as well. it also works with compileSdkVersion = 26

It also works with other versions of implementation 'com.android.support:appcompat-v7:{version}' included as long as 26.0.2 or 26.0.1 is in there also. Not sure what the best configuration is since im not an android dev but wanted to share the solution i found.