I wrote a simple Wear OS app which shows a tile and when clicked opens custom app list.

Tile uses androidx.glance:glance-wear-tiles:1.0.0-alpha05 and the rest of the app uses androidx.wear.compose.

When minification is disabled everything works just fine, but after enabling it, app crashes when activity is launched through tile. This doesn't happen when activity is launched from system app launcher.

code for the Tile:

package nodomain.pacjo.wear.anotherapplist.tile

import android.content.ComponentName
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.glance.Button
import androidx.glance.ButtonColors
import androidx.glance.GlanceComposable
import androidx.glance.GlanceModifier
import androidx.glance.LocalContext
import androidx.glance.action.actionStartActivity
import androidx.glance.action.clickable
import androidx.glance.layout.Alignment
import androidx.glance.layout.Box
import androidx.glance.layout.Column
import androidx.glance.layout.Spacer
import androidx.glance.layout.fillMaxSize
import androidx.glance.layout.fillMaxWidth
import androidx.glance.layout.height
import androidx.glance.text.Text
import androidx.glance.unit.ColorProvider
import androidx.glance.wear.tiles.GlanceTileService
import androidx.wear.compose.material.Icon
import com.google.accompanist.drawablepainter.rememberDrawablePainter
import nodomain.pacjo.wear.anotherapplist.presentation.MainActivity
import nodomain.pacjo.wear.anotherapplist.utils.AppInfo
import nodomain.pacjo.wear.anotherapplist.utils.getLaunchableApps

class LauncherTileService : GlanceTileService() {

    @Composable
    @GlanceComposable
    override fun Content() {
        Column(
            modifier = GlanceModifier
                .fillMaxSize(),
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalAlignment = Alignment.CenterVertically
        ) {
            Button(
                text = "Open\napp list",
                onClick = actionStartActivity(MainActivity::class.java),
                modifier = GlanceModifier
                    .height(64.dp)
                    .fillMaxWidth(),
                colors = ButtonColors(
                    contentColor = ColorProvider(Color.White),
                    backgroundColor = ColorProvider(Color.Black)
                )
            )
        }
    }
}

full error:

Process: nodomain.pacjo.wear.anotherapplist, PID: 23213
java.lang.RuntimeException: Unable to stop service nodomain.pacjo.wear.anotherapplist.tile.LauncherTileService@e31f21a: java.lang.IllegalStateException: LifecycleOwner of this LifecycleRegistry is already garbage collected. It is too late to change lifecycle state.
    at android.app.ActivityThread.handleStopService(ActivityThread.java:3718)
    at android.app.ActivityThread.access$1700(ActivityThread.java:200)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1687)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6680)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.IllegalStateException: LifecycleOwner of this LifecycleRegistry is already garbage collected. It is too late to change lifecycle state.
    at androidx.lifecycle.v.g(Unknown Source:385)
    at androidx.lifecycle.v.f(Unknown Source:68)
    at androidx.lifecycle.v.e(Unknown Source:14)
    at androidx.lifecycle.M.run(Unknown Source:8)
    at q0.k.b(Unknown Source:6)
    at Q0.m.onDestroy(Unknown Source:9)
    at android.app.ActivityThread.handleStopService(ActivityThread.java:3698)
    at android.app.ActivityThread.access$1700(ActivityThread.java:200) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1687) 
    at android.os.Handler.dispatchMessage(Handler.java:106) 
    at android.os.Looper.loop(Looper.java:193) 
    at android.app.ActivityThread.main(ActivityThread.java:6680) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
0

There are 0 answers