Skip to content

android: extract GgufMetadataReader factory to break cyclic dependency#22763

Open
Juste-Leo2 wants to merge 1 commit intoggml-org:masterfrom
Juste-Leo2:dev1
Open

android: extract GgufMetadataReader factory to break cyclic dependency#22763
Juste-Leo2 wants to merge 1 commit intoggml-org:masterfrom
Juste-Leo2:dev1

Conversation

@Juste-Leo2
Copy link
Copy Markdown
Contributor

Overview

This PR fixes a dependency cycle between GgufMetadataReader.kt and GgufMetadataReaderImpl.kt by creating the GgufMetadataReaderFactory.kt file.

Additional Information

The Sentrux software was used to find the cycle via their algorithm.

This PR simply moves a portion of the code into a new file to break the cycle. There are no internal logic modifications.
The change required adding import com.arm.aichat.gguf.create in MainActivity.kt.
In GgufMetadataReader.kt (line 45), the private modifier was removed in favor of val DEFAULT_SKIP_KEYS = setOf( so that GgufMetadataReaderFactory.kt can access GgufMetadataReader.DEFAULT_SKIP_KEYS.

Here is more information about the mutual import between the two files:

In GgufMetadataReader.kt, line 5:

import com.arm.aichat.internal.gguf.GgufMetadataReaderImpl

To use it at line 55:

fun create(): GgufMetadataReader = GgufMetadataReaderImpl(
    skipKeys = DEFAULT_SKIP_KEYS,
    arraySummariseThreshold = 1_000
)

In GgufMetadataReaderImpl.kt, line 6:

import com.arm.aichat.gguf.GgufMetadataReader

To use it at line 20:

internal class GgufMetadataReaderImpl(...) : GgufMetadataReader {...

I performed the tests by compiling it myself. The compilation was successful:

:~/github/llama.cpp/examples/llama.android$ ./gradlew :lib:compileDebugKotlin :app:compileDebugKotlin
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

> Configure project :app
WARNING: BuildType 'debug' is both debuggable and has 'isMinifyEnabled' set to true.
All code optimizations and obfuscation are disabled for debuggable builds.

BUILD SUCCESSFUL in 47s
28 actionable tasks: 1 executed, 27 up-to-date

Requirements

@Juste-Leo2 Juste-Leo2 requested a review from ggerganov as a code owner May 6, 2026 14:12
@github-actions github-actions Bot added android Issues specific to Android examples labels May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

android Issues specific to Android examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant