Go for Android
Cythoncould do the same thing by convert python to c, then c to binary.
First, you should write a program at ~/go/github/yingshaoxo/hi/main.go
~/go/github/yingshaoxo/hi/main.gopackage greeting
func SayHi() string {
return "Hi!"
}Capitalize the function name, so golang would treat that function as public.
Then, compile it to binary file
go get golang.org/x/mobile/cmd/gomobile
gomobile initgomobile bind -target=androidIf it ask for NDK, install it and make sure the Environmental-Variable was set right.
If everything was right, you'll get two files: greeting.aar and greeting-sources.jar
Let's import it to Android Studio Project
Let's assume you have a project which was named
ABI_Testmkdir ABI_Test/app/libsmv greeting.aar ABI_Test/app/libs/andmv greeting-sources.jar ABI_Test/app/libs/add
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])toABI_Test/app/build.gradlerebuild the project
Let's use it with the following codes
The real codes
Last updated
Was this helpful?