glance-experimental-tools icon indicating copy to clipboard operation
glance-experimental-tools copied to clipboard

[AppWidget Viewer] NoSuchMethodError: No static method ModalBottomSheetLayout

Open leinardi opened this issue 1 year ago • 33 comments

Describe the bug

The project is currently using outdated version of many dependencies, including Compose and Glance. This is causing crashes like the following:

 java.lang.NoSuchMethodError: No static method ModalBottomSheetLayout-BzaUkTc(Lkotlin/jvm/functions/Function3;Landroidx/compose/ui/Modifier;Landroidx/compose/material/ModalBottomSheetState;Landroidx/compose/ui/graphics/Shape;FJJJLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V in class Landroidx/compose/material/ModalBottomSheetKt; or its super classes (declaration of 'androidx.compose.material.ModalBottomSheetKt' appears in /data/app/com.leinardi.ubuntucountdownwidget.debug-1/base.apk)
 	at com.google.android.glance.tools.viewer.ui.ViewerScreenKt.ViewerScreen-_ngmBi8(ViewerScreen.kt:118)
 	at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1$1$1.invoke(GlanceViewerActivity.kt:95)
 	at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1$1$1.invoke(GlanceViewerActivity.kt:94)
 	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
 	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
 	at androidx.compose.material3.SurfaceKt$Surface$1.invoke(Surface.kt:133)
 	at androidx.compose.material3.SurfaceKt$Surface$1.invoke(Surface.kt:114)
[...]

To Reproduce

Steps to reproduce the behavior:

  1. Use the viewer library with the latest version of Compose and Material 3.

Expected behavior

The viewer should work as expected

Environment:

  • Android OS version: API 24
  • Device: Emulator
  • Glance Experimental Tools version: 0.2.2

Additional context

I would be happy to work on a PR that bumps the dependencies but, before investing effort on it, I would like to have a confirmation that it would be appreciated and merged if successful.

leinardi avatar Aug 25 '23 09:08 leinardi

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Sep 25 '23 03:09 github-actions[bot]

comment or this will be closed in 5 days.

leinardi avatar Sep 25 '23 07:09 leinardi

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Oct 27 '23 03:10 github-actions[bot]

comment or this will be closed in 5 days.

leinardi avatar Oct 27 '23 07:10 leinardi

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Nov 27 '23 03:11 github-actions[bot]

Remove stale label or comment or this will be closed in 5 days.

A fix is getting worked on but isn't released yet: https://issuetracker.google.com/issues/298066147#comment3

leinardi avatar Nov 27 '23 08:11 leinardi

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Dec 29 '23 03:12 github-actions[bot]

comment or this will be closed in 5 days

leinardi avatar Jan 01 '24 12:01 leinardi

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Feb 02 '24 03:02 github-actions[bot]

comment or this will be closed in 5 days

leinardi avatar Feb 02 '24 09:02 leinardi

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Mar 04 '24 03:03 github-actions[bot]

comment or this will be closed in 5 days

leinardi avatar Mar 04 '24 08:03 leinardi

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Apr 04 '24 03:04 github-actions[bot]

comment or this will be closed in 5 days

leinardi avatar Apr 04 '24 07:04 leinardi

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar May 06 '24 03:05 github-actions[bot]

comment or this will be closed in 5 days

leinardi avatar May 06 '24 09:05 leinardi

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jun 06 '24 03:06 github-actions[bot]

I've updated the PR #13 to update to the latest dependencies, would it be possible to review it, merge it and make a new release of the libraries? The artifacts on Maven Central are still very outdated.

leinardi avatar Jun 06 '24 07:06 leinardi

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jul 08 '24 03:07 github-actions[bot]

comment or this will be closed in 5 days

leinardi avatar Jul 08 '24 07:07 leinardi

.. and does anyone solve this problem :'(

ienground avatar Jul 12 '24 08:07 ienground

@ienground #13

leinardi avatar Jul 12 '24 08:07 leinardi

still not working :'(

ienground avatar Jul 12 '24 08:07 ienground

do you get the same error java.lang.NoSuchMethodError: No static method ModalBottomSheetLayout?

leinardi avatar Jul 12 '24 08:07 leinardi

when I launch GlancePreviewActivity (implements GlanceViewerActivity), it terminated with message:

FATAL EXCEPTION: main (Ask Gemini)
Process: zone.ien.calarm.debug, PID: 31900
java.lang.NoSuchMethodError: No static method ModalBottomSheetLayout-BzaUkTc(Lkotlin/jvm/functions/Function3;Landroidx/compose/ui/Modifier;Landroidx/compose/material/ModalBottomSheetState;Landroidx/compose/ui/graphics/Shape;FJJJLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V in class Landroidx/compose/material/ModalBottomSheetKt; or its super classes (declaration of 'androidx.compose.material.ModalBottomSheetKt' appears in /data/app/~~pVUrzfKR-8_D2u7-Lfzplg==/zone.ien.calarm.debug-dskKyv1EuMRGdwqN8mq4_Q==/base.apk) at com.google.android.glance.tools.viewer.ui.ViewerScreenKt.ViewerScreen-_ngmBi8(ViewerScreen.kt:118)
at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1$1$1.invoke(GlanceViewerActivity.kt:95)
...

my activity:

@OptIn(ExperimentalGlanceRemoteViewsApi::class)
class GlancePreviewActivity: GlanceViewerActivity() {
    @ExperimentalGlanceRemoteViewsApi
    override suspend fun getGlanceSnapshot(receiver: Class<out GlanceAppWidgetReceiver>): GlanceSnapshot {
        return when (receiver) {
            AnalogClockWidgetReceiver::class.java -> GlanceSnapshot(
                instance = AnalogClockWidget(),
//                state = mutablePreferencesOf(intPreferencesKey("state") to value)
            )
            else -> throw IllegalArgumentException()
        }
    }

    @ExperimentalGlanceRemoteViewsApi
    override fun getProviders(): List<Class<out AppWidgetProvider>> {
        return listOf(AnalogClockWidgetReceiver::class.java)
    }
}

ienground avatar Jul 12 '24 08:07 ienground

but are you actually using the code from the PR #13 instead of the Maven Central artifact of this library?

leinardi avatar Jul 12 '24 08:07 leinardi

to be honest, your code works only if I add material (compose material2) library. Without it, It is not compiling.

ienground avatar Jul 12 '24 08:07 ienground

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Aug 12 '24 03:08 github-actions[bot]

comment or this will be closed in 5 days

leinardi avatar Aug 12 '24 07:08 leinardi