Skip to content

[Component name] BottomSheetDialogFragment bug #4825

Open
@AttemptD

Description

@AttemptD

Description: BottomSheetDialogFragment got error,when use 1.14.0-alpha02,but 1.14.0-alpha01 is ok

@SuppressLint("RestrictedApi")
class CustomBottomSheetDialogFragment(
   private val view: View,
   private val state: Int = BottomSheetBehavior.STATE_EXPANDED
) : BottomSheetDialogFragment() {

   private var onViewCreatedListener: ((View) -> Unit)? = null
   private var onDismissListener: ((CustomBottomSheetDialogFragment) -> Unit)? = null

   private var peekHeightRatio: Float = 0.5f // 默认半屏显示
   private var isHideable: Boolean = true
   private var expandedOffset: Int = 0

   @NonNull
   override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
       // Set up BottomSheetDialog
       val bottomSheetDialog =
           BottomSheetDialog(
               requireContext(), R.style.ThemeOverlay_Catalog_BottomSheetDialog_Scrollable
           )
       WindowPreferencesManager(requireContext()).applyEdgeToEdgePreference(bottomSheetDialog.window)
       if (view.parent != null) {
           (view.parent as ViewGroup).removeView(view)
       }
       val content = view
       bottomSheetDialog.setContentView(content)
       bottomSheetDialog.behavior.isHideable = true
       bottomSheetDialog.behavior.state = state

       val bottomSheetContent = content.findViewById<View>(R.id.bottom_drawer_2)
       ViewUtils.doOnApplyWindowInsets(bottomSheetContent) { v: View?, insets: WindowInsetsCompat, initialPadding: RelativePadding ->
           bottomSheetContent.setPaddingRelative(
               initialPadding.start,
               initialPadding.top,
               initialPadding.end,
               initialPadding.bottom + insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom
           )
           insets
       }
       onViewCreatedListener?.invoke(content)
       onDismissListener?.invoke(this)


       return bottomSheetDialog
   }

Error :
java.lang.NoSuchFieldError: No static field protection_layout of type I in class Lcom/google/android/material/R$id; or its superclasses (declaration of 'com.google.android.material.R$id' appears in /data/app/~~WSpnRDSRLjIbl1jltpiXJw==/com.attempt.afusekt-7gzw79vCjdyzH_s1jQKwAA==/base.apk!classes2.dex)
at com.google.android.material.bottomsheet.BottomSheetDialog.e(Unknown Source:20)
at com.google.android.material.bottomsheet.BottomSheetDialog.f(Unknown Source:0)
at com.google.android.material.bottomsheet.BottomSheetDialog.setContentView(SourceFile:2)
at com.attempt.afusekt.components.CustomBottomSheetDialogFragment.onCreateDialog(Unknown Source:58)
at androidx.fragment.app.DialogFragment.onGetLayoutInflater(Unknown Source:25)
at androidx.fragment.app.Fragment.performGetLayoutInflater(Unknown Source:0)
at androidx.fragment.app.FragmentStateManager.d(Unknown Source:30)
at androidx.fragment.app.FragmentStateManager.i(Unknown Source:153)
at androidx.fragment.app.FragmentManager.C(Unknown Source:1229)
at androidx.fragment.app.FragmentManager.Z(Unknown Source:91)
at androidx.fragment.app.FragmentManager.A(Unknown Source:150)
at androidx.fragment.app.FragmentManager$5.run(Unknown Source:3)
at android.os.Handler.handleCallback(Handler.java:959)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loopOnce(Looper.java:257)
at android.os.Looper.loop(Looper.java:342)
at android.app.ActivityThread.main(ActivityThread.java:9638)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:619)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)
Android API version: targetSdk 36 ,

Material Library version: 1.14.0-alpha02,

Device: samsung s23 android 15

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions