Status Update
Comments
sg...@google.com <sg...@google.com> #2
Hello,
I'm only a little familiar with Power Apps. Is your app a mobile app or a web app?
This link
The primary
If your app does not work on Android mobile devices, you can also consider the
to...@gmail.com <to...@gmail.com> #3
ch...@google.com <ch...@google.com> #4
In the above code, is className
defined as a string literal in the same method, or is it an input to the method? Unless it is defined as a string literal in the same method, the above code is only guaranteed to work if there is a keep rule that specifies that className
is instantiated by reflection.
to...@gmail.com <to...@gmail.com> #5
It's s a string param. Can you then give the proper minimal rule they should embed?
The interface is :
public interface ActionCallback {
/**
* Performs the work associated with this action. Called when the action is triggered.
*
* @param context the calling context
* @param glanceId the [GlanceId] that triggered this action
* @param parameters the parameters associated with the action
*/
suspend fun onRun(
context: Context,
glanceId: GlanceId,
parameters: ActionParameters
)
}
ch...@google.com <ch...@google.com> #6
From what I can see, I would expect that -keep,allowobfuscation,allowshrinking class * implements androidx.glance.appwidget.action.ActionCallback { void <init>(); }
should work.
to...@gmail.com <to...@gmail.com> #7
Seems to work, Glance team have all needed to embed the rules now.
For my culture why is the void <init>();
needed? Should not keeping the class and having some usage of the interface in code be enough for R8 to suppose it's instantiated?
And more generally maybe there should be an annotation for this use case? Like there @DoNotInline in androidx.annotation ?
pb...@google.com <pb...@google.com>
za...@google.com <za...@google.com> #8
zak should investigate this further, to see if we can add a more general keep configuration
to...@gmail.com <to...@gmail.com> #9
Updated to R8 3.3-18 dev and the issue is back
java.lang.InstantiationException: java.lang.Class<yb.a> cannot be instantiated
That file that expand the Glance interface
.class public interface abstract Lb3/a;
.super Ljava/lang/Object;
.source "SourceFile"
.class public abstract Lyb/a;
.super Ljava/lang/Object;
.source "SourceFile"
The glance interface is now changed to :
# interfaces
.implements Lb3/a;
That with the previously validated rule:
### Glance:
-keep,allowobfuscation,allowshrinking class * implements androidx.glance.appwidget.action.ActionCallback { void <init>(); }
sg...@google.com <sg...@google.com> #10
Thanks for reporting back. Can you give some more details on the structure of class yb/a
? Is it missing the constructor, or is there some other error leading to the failing instantiation? Is there more information in the exception on why the instantiation failed?
to...@gmail.com <to...@gmail.com> #11
This is the exact same class as OP (ButtonAction)
Using ugly -keep class * implements androidx.glance.appwidget.action.ActionCallback
does fix this.
Description
This is probably an issue with Jetpack Glance missing some rules, but the end result is strange enough so that I report it here first.
This code:
Will fail in R8 full mode
java.lang.InstantiationException: java.lang.Class<ma.a> cannot be instantiated
Mapping:
ButtonAction -> ma.a:
Resulting bytecode:
c3.a is correctly :
androidx.glance.appwidget.action.ActionCallback -> c3.a:
So the real class is now an abstract class without code and obviously can't be instantiated.
Adding a keep will probably workaround this, but asking for advices before reporting to Glance team in case it's a bug on R8 side.