constraintlayout
constraintlayout copied to clipboard
MotionLayout is not compatible with R8 full mode (without proguard rules)
I faced an app crash when using R8 full mode which removes constructors more aggressively.
MotionLayout is using getConstructor() method in the KeyFrames class here :point_down: and it cause the problem.
https://github.com/androidx/constraintlayout/blob/eb540e400fd01d6c4e3f795343a8f548d83aef3f/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyFrames.java#L50
The following proguard rule resolves the issue, but I think this should be bundled in consumerProguard by default.
-keepclassmembers class * extends androidx.constraintlayout.motion.widget.Key {
public <init>();
}
Would this not cause people simply using ConstraintLayout to have their APK increase in size? The majority of people using ConstraintLayout are not using MotionLayout (An argument for it being 2 libraries )
The AndroidStudio should add this to your proguard rules. We am not very familiar with the capabilities of progard.txt and we will be looking into it more
This should be fixed ASAP as since Gradle 8.0 R8 full mode is on per default
https://developer.android.com/build/releases/gradle-plugin
I'm also running into this issue. My KeyFrames do not work - they are ingored, no crashes so far - if R8 full mode is enabled
We will directly link in the future. We will move away from use of Java Reflection APIs.
I had the same issue and I solved the problem by moving <KeyFrame> features to <ConstraintSet>.