github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/mobile/example/libhello/README (about)

     1  The libhello app demonstrates calling Go code from a primarily Java app.
     2  
     3  Starting in Java lets you program against Android's extensive UI
     4  libraries in their native language and call into Go for library code
     5  (business logic, code shared with a Go server, portable code).
     6  
     7  The Java entry point to the program is the file
     8  src/com/example/hello/MainActivity.java, where the statement
     9  
    10  	Hi.Hello("world");
    11  
    12  is a call into Go code.
    13  
    14  The Go code is in a package called hi, the file is hi/hi.go, and it
    15  contains the function Hello:
    16  
    17  	func Hello(name string) {
    18  		fmt.Printf("Hello, %s!\n", name)
    19  	}
    20  
    21  Java language bindings are generated for this package using the gobind
    22  tool. There is a user guide for gobind at 
    23  
    24  	http://golang.org/x/mobile/cmd/gobind
    25  
    26  The generated source has been included in the distribution. If you
    27  modify the exported interface of package hi, you have to run gobind
    28  manually before calling all.bash.
    29  
    30  Along with the gobind generated source, the app includes a main.go file
    31  to define the app entry point.
    32  
    33  make.bash builds the app, all.bash deploys it.
    34  
    35  The first step in building the app is to build the native shared
    36  library out of the Go code, and place it in
    37  libs/armeabi-v7a/libgojni.so.
    38  
    39  The second step is building the app with the standard Android build
    40  system by calling ant debug (also done in make.bash). Two extra Java
    41  files are included in the build by make.bash to support the language
    42  bindings. This produces an apk ready for running on a device.