fyne-io/fyne · error

encountered empty values slice

Error message

encountered empty values slice

What it means

While encoding an android:-namespace attribute, addAttributeNamespace looks the name up in the vendored Android framework table ('attr/' + Local) and resolves its type spec. If that spec exists but its values slice is empty, the encoder has no data type to derive from and panics. It means the attribute name matched a table entry that ships in fyne's bundled bootstrap data without value definitions.

Source

Thrown at cmd/fyne/internal/mobile/binres/binres.go:662

	}
	return nil
}

// addAttributeNamespace encodes attr based on its namespace
// The encoded value is stored in nattr.
// If the value was not already present in pool, it is added.
func addAttributeNamespace(attr xml.Attr, nattr *Attribute, tbl *Table, pool *Pool) error {
	// get type spec and value data type
	ref, err := tbl.RefByName("attr/" + attr.Name.Local)
	if err != nil {
		return err
	}
	nt, err := ref.Resolve(tbl)
	if err != nil {
		return err
	}
	if len(nt.values) == 0 {
		panic("encountered empty values slice")
	}

	if len(nt.values) == 1 {
		val := nt.values[0]
		if val.data.Type != DataIntDec {
			panic("TODO only know how to handle DataIntDec type here")
		}

		t := DataType(val.data.Value)
		switch t {
		case DataString, DataAttribute, DataType(0x3e):
			// TODO identify 0x3e, in bootstrap.xml this is the native lib name
			nattr.RawValue = pool.ref(attr.Value)
			nattr.TypedValue.Type = DataString
			nattr.TypedValue.Value = uint32(nattr.RawValue)
		case DataIntBool, DataType(0x08):
			nattr.TypedValue.Type = DataIntBool
			switch attr.Value {

View on GitHub (pinned to 8860ee95c3)

Solutions

  1. Bisect the custom manifest attributes and remove the offending one (re-run packaging after each removal)
  2. Update fyne so the vendored framework tables match your target SDK
  3. If the attribute is required, file an upstream issue with the exact attribute name or patch the vendored table data

Example fix

// before (AndroidManifest.xml, built with an older fyne)
<application android:requestLegacyExternalStorage="true" ...>

// after - drop the attribute the old tables cannot resolve
<application ...>
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight: whitelist manifest attributes against what your fyne version is known to encode.
allowed := map[string]bool{
    "allowBackup": true, "icon": true, "label": true, "theme": true,
    "name": true, "minSdkVersion": true, "targetSdkVersion": true, "versionCode": true, "versionName": true,
}
for _, a := range manifestAttributes {
    if !allowed[a] {
        log.Printf("attribute %q is not vetted for this fyne release; verify before packaging", a)
    }
}

Prevention

When it happens

Trigger: A custom AndroidManifest.xml containing an attribute whose framework type spec resolves with zero values - typically newer-SDK attributes that fyne's vendored binres tables define (or partially define) without any value entries.

Common situations: Adding modern manifest attributes (android:requestLegacyExternalStorage, android:appComponentFactory, network security config keys) to a manifest built by an older fyne; SDK templates copied from newer Android Studio; vendored tables lagging the Android SDK.

Related errors


AI-assisted analysis of fyne-io/fyne@8860ee95c3 (2026-08-15). Data as JSON: /api/errors/62fb74710ef60004. Report an issue: GitHub.