Wiki- 2022-03-12 18:19
浏览 28
已结题

gomobile bind 包含结构体和接口的方法丢失

测试代码
package hello

import (
    "TestGoMobile/model"
    "fmt"
)

func Test(string) int {
    return 0
}

func Greetings(test model.Test) string {
    return test.Name
}

func Hello(base model.Base) {
    fmt.Println("hello world!")
}
package model

type Test struct {
    Name string
}

type Base interface {
    OnError(errCode int32, errMsg string)
    OnSuccess(data string)
}
执行命令:gomobile bind -target=android ./hello,得到下面.arr文件结果
package hello;

import go.Seq;

public abstract class Hello {
    private Hello() {
    }

    public static void touch() {
    }

    private static native void _init();

    public static native long test(String var0);

    static {
        Seq.touch();
        _init();
    }
}
生成的arr文件内仅有Test方法,另外两个没有了

猜测和方法参数为结构体和接口有关,但是不知道怎么处理才能得到正确的结果。

gomobile支持的类型:https://pkg.go.dev/golang.org/x/mobile/cmd/gobind#hdr-Type_restrictions

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 3月20日
    • 创建了问题 3月12日

    悬赏问题

    • ¥20 python忆阻器数字识别
    • ¥15 无法输出helloworld
    • ¥15 高通uboot 打印ubi init err 22
    • ¥20 PDF元数据中的XMP媒体管理属性
    • ¥15 R语言中lasso回归报错
    • ¥15 网站突然不能访问了,上午还好好的
    • ¥15 有没有dl可以帮弄”我去图书馆”秒选道具和积分
    • ¥15 semrush,SEO,内嵌网站,api
    • ¥15 Stata:为什么reghdfe后的因变量没有被发现识别啊
    • ¥15 振荡电路,ADS仿真