Skip to content

Method too large: XMTPModule.definition fails to compile on Android #777

Open

Description

@felixkamau

Description

Building the Android app with @xmtp/react-native-sdk fails during compileDebugKotlin with a MethodTooLargeException. The generated definition { ... } method in XMTPModule.kt exceeds the JVM's 64KB bytecode-per-method limit.

Error

exception: exception: java.lang.RuntimeException: Error generating class file expo/modules/xmtpreactnativesdk/XMTPModule.class
(compiled from [...\node_modules@xmtp\react-native-sdk\android\src\main\java\expo\modules\xmtpreactnativesdk\XMTPModule.kt]):
Method too large: expo/modules/xmtpreactnativesdk/XMTPModule.definition ()Lexpo/modules/kotlin/modules/ModuleDefinitionData;

caused by: org.jetbrains.org.objectweb.asm.MethodTooLargeException:
Method too large: expo/modules/xmtpreactnativesdk/XMTPModule.definition ()Lexpo/modules/kotlin/modules/ModuleDefinitionData;
at org.jetbrains.org.objectweb.asm.MethodWriter.computeMethodInfoSize(MethodWriter.java:2088)
at org.jetbrains.org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:512)

Environment

  • @xmtp/react-native-sdk: 5.7.0
  • Kotlin: 2.1.20
  • KSP: 2.1.20-2.0.1
  • Android buildTools: 36.0.0
  • compileSdk / targetSdk: 36
  • minSdk: 24
  • NDK: 27.1.12297006
  • Expo SDK: 57.0.16
  • React Native: 0.86.2
  • OS: Windows
  • Build command: npx expo run:android

Steps to reproduce

  1. Install @xmtp/react-native-sdk@5.7.0 in an Expo project.
  2. Run npx expo run:android.
  3. Build fails at :xmtp-react-native-sdk:compileDebugKotlin with the above error.

Expected behavior

The module should compile successfully.

Additional notes

The definition { } block in XMTPModule.kt appears to have grown large enough (with the full set of exported functions/events across client, conversations, groups, messages, streaming, etc.) that the compiled definition() method now exceeds the JVM's 64KB method size limit. Splitting the exported functions into multiple smaller registered Function(...) blocks, or delegating each function body to a separate private method (rather than inlining logic directly in the DSL), would likely resolve this.

Ran ./gradlew clean and ./gradlew --stop before retrying — same failure.

Activity

  1. felixkamau commented on Aug 20, 2026

    @felixkamau
    Author

    @nplasterer hi am facing an issue with the react native package

  2. nplasterer commented on Aug 20, 2026

    @nplasterer
    Contributor

    Thanks for the ping @felixkamau I no longer maintain this package but maybe @cameronvoell or @neekolas could help out. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions