Skip to content

ERROR : Sealed classes are not supported as program classes #498

@justin-prabhakaran

Description

@justin-prabhakaran

🐞 Bug Report

Package version
record: ^6.0.0

Environment

OS: Android

Flutter 3.27.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 17025dd882 (5 months ago) • 2024-12-17 03:23:09 +0900
Engine • revision cb4b5fff73
Tools • Dart 3.6.0 • DevTools 2.40.2

Android Gradle Plugin: 7.3.0

Kotlin version: 1.8.x

minSdkVersion: 26

compileSdkVersion: 34

📄 Describe the bug
When building the project using the latest record plugin (^6.0.0), the following build error is thrown:

ERROR:/home/crazyshit/englishbhashi/app-fe/build/record_android/intermediates/runtime_library_classes_dir/debug/com/llfbandit/record/record/format/Format.class: D8: com.android.tools.r8.internal.Hc: Sealed classes are not supported as program classes

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeLibDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform debug (project :record_android) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, com.android.build.api.attributes.AgpVersionAttr=7.3.0, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=26, org.gradle.category=library, org.gradle.jvm.environment=android, org.gradle.libraryelements=classes, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=androidJvm}.
      > Execution failed for DexingNoClasspathTransform: /home/crazyshit/englishbhashi/app-fe/build/record_android/intermediates/runtime_library_classes_dir/debug.
         > Error while dexing.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

⚙️ Configuration
The plugin is initialized with the following:

 RecordConfig(
            encoder: AudioEncoder.wav,
            sampleRate: 16000,
            numChannels: 1,
          ),

🚶 To Reproduce
Steps to reproduce the issue:

Add record: ^6.0.0 to pubspec.yaml

Set minSdkVersion 26 and enable coreLibraryDesugaring in build.gradle

Attempt to build or run the Flutter project on Android

See build error related to sealed class in Format.class

✅ Expected behavior
Build should succeed, or the library should avoid using Kotlin sealed class constructs that break compatibility with D8.

📎 Additional context
Tried both desugar_jdk_libs:1.2.3 and 2.0.3

flutter clean, invalidate caches, and rebuilding didn’t help

Verified the issue comes from record_android native code

If there’s a workaround like downgrading or modifying the sealed class usage, please let me know. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions