MatsuriDayo / NekoBoxForAndroid

NekoBox for Android / sing-box / universal proxy toolchain for Android
https://matsuridayo.github.io/
Other
11.68k stars 985 forks source link

求求了,谁能告诉我为什么import go.Seq import libcore.Libcore报错啊,有偿啊 #720

Closed victorliuboom closed 1 month ago

victorliuboom commented 3 months ago

描述建议

根本运行不起来啊,怎么让go也能在android项目中,怎么编译啊

建议的必要性

maskedeken commented 3 months ago

你要用gomobile编译,参考libcore/build.sh这个脚本。把编译出来的aar文件放到app/libs下,再用gradlew编译

dou23 commented 3 months ago

在Ubuntu中,你需要搭建完成的go环境,go最好是1.20以上,然后go要安装gomobile。 编译的命令是./run lib core。 先把环境弄好,然后跑一下这个命令,有啥问题不懂的再回复我

dou23 commented 3 months ago

补充一下,记得把libcore下的build.sh代码修改一下,以免提示-cache或者-trimpath找不到 把下面这段代码注释

gomobile bind -v -androidapi 21 -cache $(realpath $BUILD) -trimpath -ldflags='-s -w' -tags='with_conntrack,with_gvisor,with_quic,with_wireguard,with_utls,with_clash_api,with_ech' . || exit 1

修改为 gomobile bind -v -androidapi 21 -tags='with_conntrack,with_gvisor,with_quic,with_wireguard,with_utls,with_clash_api,with_ech' . || exit 1

NicodeLee commented 2 months ago

这边在win下编译到最后一步提示 C:\Go\bin\gomobile.exe: go build -tags with_conntrack,with_gvisor,with_quic,with_wireguard,with_utls,with_clash_api,with_ech -v -buildmode=c-shared -o=C:\Users\NICODE~1\AppData\Local\Temp\gomobile-work-3241027813\android\src\main\jniLibs\x86\libgojni.so ./gobind failed: exit status 1 build.sh已经修改。

dou23 commented 2 months ago

你看看和项目同级的目录下,sing-box和libneko这两个库有拉下来吗 @NicodeLee

NicodeLee commented 2 months ago

@dou23 没有下到sing-box和libneko这两个库 更前面的提示信息是这样:

write C:\Users\NICODE~1\AppData\Local\Temp\gomobile-work-364689451\src-android-386\go.mod
write C:\Users\NICODE~1\AppData\Local\Temp\gomobile-work-364689451\src-android-arm\go.mod
write C:\Users\NICODE~1\AppData\Local\Temp\gomobile-work-364689451\src-android-amd64\go.mod
write C:\Users\NICODE~1\AppData\Local\Temp\gomobile-work-364689451\src-android-arm64\go.mod
go: found libcore in libcore v0.0.0-00010101000000-000000000000
go: found libcore in libcore v0.0.0-00010101000000-000000000000
go: found libcore in libcore v0.0.0-00010101000000-000000000000
go: found libcore in libcore v0.0.0-00010101000000-000000000000
unused cloud.google.com/go/compute
unused cloud.google.com/go/compute/metadata
unused github.com/BurntSushi/toml
unused github.com/bwesterb/go-ristretto
unused github.com/census-instrumentation/opencensus-proto
unused github.com/cespare/xxhash/v2
unused github.com/chromedp/cdproto
省略其他

C:\GOPATH\pkg\mod\github.com\sagernet\quic-go@v0.45.1-beta.2\internal\qtls_ech\go_oldversion.go:5:13: cannot use "ECH can't be built using outdated Go versions." (untyped string constant) as int value in variable declaration
# github.com/sagernet/quic-go/internal/qtls_ech
C:\GOPATH\pkg\mod\github.com\sagernet\quic-go@v0.45.1-beta.2\internal\qtls_ech\go_oldversion.go:5:13: cannot use "ECH can't be built using outdated Go versions." (untyped string constant) as int value in variable declaration
github.com/sagernet/quic-go/internal/qtls_ech
# github.com/sagernet/quic-go/internal/qtls_ech
C:\GOPATH\pkg\mod\github.com\sagernet\quic-go@v0.45.1-beta.2\internal\qtls_ech\go_oldversion.go:5:13: cannot use "ECH can't be built using outdated Go versions." (untyped string constant) as int value in variable declaration
github.com/sagernet/quic-go/internal/qtls_ech
# github.com/sagernet/quic-go/internal/qtls_ech
C:\GOPATH\pkg\mod\github.com\sagernet\quic-go@v0.45.1-beta.2\internal\qtls_ech\go_oldversion.go:5:13: cannot use "ECH can't be built using outdated Go versions." (untyped string constant) as int value in variable declaration
C:\Go\bin\gomobile.exe: go build -tags with_conntrack,with_gvisor,with_quic,with_wireguard,with_utls,with_clash_api,with_ech -v -buildmode=c-shared -o=C:\Users\NICODE~1\AppData\Local\Temp\gomobile-work-364689451\android\src\main\jniLibs\x86\libgojni.so ./gobind failed: exit status 1
maskedeken commented 2 months ago

Go版本太旧了

NicodeLee commented 2 months ago

那更新一下go,这还是上次编译frpc的时候弄完就好久没用了

NicodeLee commented 2 months ago
可以了,感谢 @dou23  @maskedeken  。Android home路径还要点问题这个换下就好了。
NicodeLee commented 2 months ago

aar现在编译有70m不知道你们打吧是怎样优化apk体积的 @dou23 @maskedeken