Kevin
03/13/2023, 2:39 PMKevin
03/13/2023, 2:39 PMError in Glance App Widget
java.lang.AbstractMethodError: abstract method "void androidx.glance.appwidget.GlanceAppWidget.Content(androidx.compose.runtime.Composer, int)"
which to me seems weird cause it looks like the Content function now expects two parameters, but I can’t find those parameters being defined anywhere (also not really in the documentation)… So it looked to me like I had some sort of dependency mismatch or something…
In my project’s build.gradle I’ve got implementation "androidx.glance:glance-appwidget:1.0.0-alpha05"
in my dependencies section,
Using kotlin_version = "1.8.0"
and
classpath('com.android.tools.build:gradle:7.4.1')
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
I’ve got a widget:
package com.delta.widgets
import androidx.compose.runtime.Composable
import androidx.glance.appwidget.GlanceAppWidget
import androidx.glance.appwidget.GlanceAppWidgetReceiver
import androidx.glance.text.Text
class BiggestMoversAppWidgetReceiver: GlanceAppWidgetReceiver() {
override val glanceAppWidget: GlanceAppWidget
get() = BiggestMoversWidget();
private class BiggestMoversWidget: GlanceAppWidget() {
@Composable
override fun Content() {
Text(text = "Hello World")
}
}
}
with app_widget_info.xml resource file:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="<http://schemas.android.com/apk/res/android>"
android:minWidth="72dp"
android:minHeight="36dp"
android:resizeMode="none"
android:minResizeWidth="72dp"
android:minResizeHeight="36dp"
android:updatePeriodMillis="999999999"
/>
with AndroidManifest
<receiver android:name=".widgets.BiggestMoversAppWidgetReceiver" android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/app_widget_info" />
</receiver>
Marcel Pinto
03/14/2023, 9:48 AMKevin
03/14/2023, 12:00 PMkotlinOptions
with jvmTarget = "1.8"
as described in the docs, but had an error Could not find method kotlinOptions() for arguments ...
, I think I fixed this with the missing line apply plugin: 'kotlin-android'
.
I added compose = true
in buildFeatures
and also
composeOptions {
kotlinCompilerExtensionVersion = "1.4.3"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
I also added (not sure if required)
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
and next to the already present implementation "androidx.glance:glance-appwidget:1.0.0-alpha05"
I added implementation "androidx.glance:glance:1.0.0-alpha05"
. Seems logical to add for me
And also added
apply plugin: 'org.jetbrains.kotlin.android'
So not sure what exactly was the culprit here, but I can finally try out Glance 😍
Thanks anyway for checking out the issue and trying to pass it on, glad I was able to get it running.Marcel Pinto
03/14/2023, 12:03 PMKevin
03/14/2023, 2:59 PM