mobile

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 7 Imported by: 0

README

bee-lite-java

Go Reference

This repository wraps bee-lite functionality and provides its core functionalities to implement Android applications what are able to use Swarm network. Due to type restriction this implemenentation also acts as an adapter to convert bridge between go and java by using the supported types.

Development for Android platform

Please check the same section in this README.md it all applies here as well.

Type restrictions

Go-to-Android (gomobile) Type Mapping Reference

The following table outlines how Go types are mapped to Java/Kotlin when using gomobile bind.

Go Type Java/Android Equivalent Category
bool boolean Basic Type
string String Basic Type
int, int32 int Numeric
int64 long Numeric
float32 float Numeric
float64 double Numeric
uint8 (byte) byte Numeric
[]byte byte[] Buffer
error java.lang.Exception Error Handling
func interface (Callback) Functional
struct class (with getters/setters) Object
interface interface Object

⚠️ Handling Unsupported Types

If your Go code uses types not listed above (like uint64 or []string), use the following workarounds:

1. Unsigned 64-bit Integers (uint64)

Java does not support unsigned 64-bit integers.

  • Go Side: Cast to int64 before returning.
  • Android Side: Use Long.toUnsignedString(value) to display or Long.compareUnsigned(...) to compare.
2. String Slices ([]string)

gomobile does not support slices.

  • Workaround A (Wrapper): Create a struct with Get(i int) string and Length() int methods.
  • Workaround B (JSON): Serialize the slice to a JSON string in Go and parse it in Android.
  • Workaround C (Join): Use strings.Join(slice, "|") in Go and string.split("\\|") in Kotlin/Java.
3. Maps and Complex Structs

For nested data or maps, it is recommended to use JSON serialization to pass data across the bridge.

Compile with gomobile for Android

Target android api 21 is a nice sweet spot because it is Android Version: 5.0 (Lollipop) which is widely supported.

First you need gomobile and bind

make install

then

make build

OR if you want to do it your own

go install golang.org/x/mobile/cmd/gomobile@latest
go get golang.org/x/mobile/bind

In the root of this project run gomobile init

Run the following:

gomobile bind -target=android -androidapi=21 -o mobile.aar

Documentation

Index

Constants

View Source
const StringSliceDelimiter = "|"

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Name string
	Data []byte
}

type MobileNode

type MobileNode struct {
	// contains filtered or unexported fields
}

func StartNode

func StartNode(options *MobileNodeOptions, password string, verbosity string) (*MobileNode, error)

func (*MobileNode) ConnectedPeerCount

func (a *MobileNode) ConnectedPeerCount() int

func (*MobileNode) Download

func (bl *MobileNode) Download(hash string) (*File, error)

func (*MobileNode) Shutdown

func (a *MobileNode) Shutdown() error

func (*MobileNode) WalletAddress

func (a *MobileNode) WalletAddress() string

type MobileNodeOptions

type MobileNodeOptions struct {
	FullNodeMode             bool
	BootnodeMode             bool
	Bootnodes                string
	StaticNodes              string
	DataDir                  string
	WelcomeMessage           string
	BlockchainRpcEndpoint    string
	SwapInitialDeposit       string
	PaymentThreshold         string
	SwapEnable               bool
	ChequebookEnable         bool
	UsePostageSnapshot       bool
	Mainnet                  bool
	NetworkID                int64
	NATAddr                  string
	CacheCapacity            int64
	DBOpenFilesLimit         int64
	DBWriteBufferSize        int64
	DBBlockCacheCapacity     int64
	DBDisableSeeksCompaction bool
	RetrievalCaching         bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL