prscX / react-native-popover-menu

React Native: Native Popover Menu
Apache License 2.0
483 stars 54 forks source link

react-native-popover-menu not working in android API level less than 21 (Android 5.0) #25

Closed SystemBlad closed 4 years ago

SystemBlad commented 6 years ago

Hi guys, I've tried this great library on a device with Android 4.4, but unfortunately it does not work.

The error is produced by this line in file RNPopoverMenuModule.java

image

Can you update your code so that the library will be compatible with all the versions of android that React Native supports?

Note: Maybe is not the best solution but I fixed changing that line by the following code:

                  if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP){
                      imageView.setImageTintMode(PorterDuff.Mode.DST);
                  }
mernxl commented 4 years ago

Having same issues, all phones with less than API 21, crashes with this error.

java.lang.NoSuchMethodError: 

  at ui.popovermenu.RNPopoverMenuModule$1$1$1.invoke (RNPopoverMenuModule.java:120)

  at com.github.zawadz88.materialpopupmenu.internal.PopupMenuAdapter$CustomItemViewHolder.bindItem (PopupMenuAdapter.kt:127)

  at com.github.zawadz88.materialpopupmenu.internal.PopupMenuAdapter.onBindItemViewHolder (PopupMenuAdapter.kt:83)

  at com.github.zawadz88.materialpopupmenu.internal.PopupMenuAdapter.onBindItemViewHolder (PopupMenuAdapter.kt:24)

  at com.github.zawadz88.materialpopupmenu.internal.SectionedRecyclerViewAdapter.onBindViewHolder (SectionedRecyclerViewAdapter.kt:103)

  at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder (RecyclerView.java:6781)

  at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder (RecyclerView.java:6823)

  at androidx.appcompat.widget.MaterialRecyclerViewPopupWindow.measureIndividualMenuWidth (MaterialRecyclerViewPopupWindow.kt:319)

  at androidx.appcompat.widget.MaterialRecyclerViewPopupWindow.setAdapter$material_popup_menu_release (MaterialRecyclerViewPopupWindow.kt:66)

  at com.github.zawadz88.materialpopupmenu.MaterialPopupMenu.show (MaterialPopupMenu.kt:39)

  at ui.popovermenu.RNPopoverMenuModule$2.run (RNPopoverMenuModule.java:176)

  at android.os.Handler.handleCallback (Handler.java:733)

  at android.os.Handler.dispatchMessage (Handler.java:95)

  at android.os.Looper.loop (Looper.java:136)

  at android.app.ActivityThread.main (ActivityThread.java:5579)

  at java.lang.reflect.Method.invokeNative (Native Method)

  at java.lang.reflect.Method.invoke (Method.java:515)

  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1268)

  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1084)

  at dalvik.system.NativeStart.main (Native Method)
prscX commented 4 years ago

Thanks @SystemBlad for raising issue and sharing solution.

I have added the shared source to library. You can now download latest version.

Thanks </ Pranav >