2015-03-26 14:21:54 -04:00
|
|
|
// Copyright 2015 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2015-07-10 16:47:46 -06:00
|
|
|
// DO NOT EDIT. GENERATED BY 'gomobile help documentation doc.go'.
|
2015-03-26 14:21:54 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
Gomobile is a tool for building and running mobile apps written in Go.
|
|
|
|
|
2015-06-29 14:37:57 -04:00
|
|
|
To install:
|
2015-03-26 14:21:54 -04:00
|
|
|
|
|
|
|
$ go get golang.org/x/mobile/cmd/gomobile
|
|
|
|
$ gomobile init
|
|
|
|
|
2015-08-12 12:04:03 -04:00
|
|
|
At least Go 1.5 is required.
|
|
|
|
For detailed instructions, see https://golang.org/wiki/Mobile.
|
2015-03-26 14:21:54 -04:00
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
gomobile command [arguments]
|
|
|
|
|
|
|
|
Commands:
|
|
|
|
|
2015-08-29 16:27:39 -07:00
|
|
|
bind build a library for Android and iOS
|
2015-03-26 14:21:54 -04:00
|
|
|
build compile android APK and iOS app
|
2016-07-07 11:36:51 -04:00
|
|
|
clean remove object files and cached gomobile files
|
2015-03-26 14:21:54 -04:00
|
|
|
init install android compiler toolchain
|
2015-07-11 11:55:10 -07:00
|
|
|
install compile android APK and install on device
|
2015-07-30 09:59:04 -04:00
|
|
|
version print version
|
2015-03-26 14:21:54 -04:00
|
|
|
|
|
|
|
Use 'gomobile help [command]' for more information about that command.
|
|
|
|
|
|
|
|
|
2015-08-29 16:27:39 -07:00
|
|
|
Build a library for Android and iOS
|
2015-03-26 14:21:54 -04:00
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
2015-06-29 14:37:57 -04:00
|
|
|
gomobile bind [-target android|ios] [-o output] [build flags] [package]
|
2015-03-26 14:21:54 -04:00
|
|
|
|
2015-06-29 14:37:57 -04:00
|
|
|
Bind generates language bindings for the package named by the import
|
|
|
|
path, and compiles a library for the named target system.
|
2015-03-26 14:21:54 -04:00
|
|
|
|
2015-06-29 14:37:57 -04:00
|
|
|
The -target flag takes a target system name, either android (the
|
|
|
|
default) or ios.
|
2015-03-25 19:09:35 -04:00
|
|
|
|
2015-06-29 14:37:57 -04:00
|
|
|
For -target android, the bind command produces an AAR (Android ARchive)
|
|
|
|
file that archives the precompiled Java API stub classes, the compiled
|
|
|
|
shared libraries, and all asset files in the /assets subdirectory under
|
|
|
|
the package directory. The output is named '<package_name>.aar' by
|
|
|
|
default. This AAR file is commonly used for binary distribution of an
|
|
|
|
Android library project and most Android IDEs support AAR import. For
|
|
|
|
example, in Android Studio (1.2+), an AAR file can be imported using
|
|
|
|
the module import wizard (File > New > New Module > Import .JAR or
|
|
|
|
.AAR package), and setting it as a new dependency
|
|
|
|
(File > Project Structure > Dependencies). This requires 'javac'
|
2016-07-07 11:36:51 -04:00
|
|
|
(version 1.7+) and Android SDK (API level 15 or newer) to build the
|
2015-06-29 14:37:57 -04:00
|
|
|
library for Android. The environment variable ANDROID_HOME must be set
|
2015-11-04 15:25:32 -05:00
|
|
|
to the path to Android SDK. The generated Java class is in the java
|
2017-01-01 22:43:46 +01:00
|
|
|
package '<package_name>' unless -javapkg flag is specified.
|
2015-03-25 19:09:35 -04:00
|
|
|
|
2016-06-14 10:43:25 -04:00
|
|
|
By default, -target=android builds shared libraries for all supported
|
|
|
|
instruction sets (arm, arm64, 386, amd64). A subset of instruction sets
|
|
|
|
can be selected by specifying target type with the architecture name. E.g.,
|
|
|
|
-target=android/arm,android/386.
|
|
|
|
|
2015-06-29 14:37:57 -04:00
|
|
|
For -target ios, gomobile must be run on an OS X machine with Xcode
|
2017-01-01 22:43:46 +01:00
|
|
|
installed. Support is not complete. The -prefix flag can be used to prefix
|
|
|
|
the names of generated Objective-C types.
|
2015-03-26 14:21:54 -04:00
|
|
|
|
|
|
|
The -v flag provides verbose output, including the list of packages built.
|
|
|
|
|
2016-02-18 05:25:39 -05:00
|
|
|
The build flags -a, -n, -x, -gcflags, -ldflags, -tags, and -work
|
2015-07-30 09:59:04 -04:00
|
|
|
are shared with the build command. For documentation, see 'go help build'.
|
2015-03-26 14:21:54 -04:00
|
|
|
|
|
|
|
|
|
|
|
Compile android APK and iOS app
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
2015-06-29 14:37:57 -04:00
|
|
|
gomobile build [-target android|ios] [-o output] [build flags] [package]
|
2015-03-26 14:21:54 -04:00
|
|
|
|
|
|
|
Build compiles and encodes the app named by the import path.
|
|
|
|
|
|
|
|
The named package must define a main function.
|
|
|
|
|
2015-06-29 14:37:57 -04:00
|
|
|
The -target flag takes a target system name, either android (the
|
|
|
|
default) or ios.
|
|
|
|
|
|
|
|
For -target android, if an AndroidManifest.xml is defined in the
|
|
|
|
package directory, it is added to the APK output. Otherwise, a default
|
2016-02-18 05:25:39 -05:00
|
|
|
manifest is generated. By default, this builds a fat APK for all supported
|
2016-03-15 12:20:10 -04:00
|
|
|
instruction sets (arm, 386, amd64, arm64). A subset of instruction sets can
|
|
|
|
be selected by specifying target type with the architecture name. E.g.
|
2016-02-18 05:25:39 -05:00
|
|
|
-target=android/arm,android/386.
|
2015-06-29 14:37:57 -04:00
|
|
|
|
|
|
|
For -target ios, gomobile must be run on an OS X machine with Xcode
|
|
|
|
installed. Support is not complete.
|
2015-03-26 14:21:54 -04:00
|
|
|
|
|
|
|
If the package directory contains an assets subdirectory, its contents
|
2015-06-29 14:37:57 -04:00
|
|
|
are copied into the output.
|
2015-03-26 14:21:54 -04:00
|
|
|
|
|
|
|
The -o flag specifies the output file name. If not specified, the
|
2015-06-29 14:37:57 -04:00
|
|
|
output file name depends on the package built.
|
2015-03-26 14:21:54 -04:00
|
|
|
|
|
|
|
The -v flag provides verbose output, including the list of packages built.
|
|
|
|
|
2015-07-30 09:59:04 -04:00
|
|
|
The build flags -a, -i, -n, -x, -gcflags, -ldflags, -tags, and -work are
|
|
|
|
shared with the build command. For documentation, see 'go help build'.
|
2015-03-26 14:21:54 -04:00
|
|
|
|
|
|
|
|
2016-07-07 11:36:51 -04:00
|
|
|
Remove object files and cached gomobile files
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
gomobile clean
|
|
|
|
|
|
|
|
Clean removes object files and cached NDK files downloaded by gomobile init
|
|
|
|
|
|
|
|
|
2015-03-26 14:21:54 -04:00
|
|
|
Install android compiler toolchain
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
gomobile init [-u]
|
|
|
|
|
2015-08-12 12:04:03 -04:00
|
|
|
Init installs the Android C++ compiler toolchain and builds copies
|
|
|
|
of the Go standard library for mobile devices.
|
2015-03-26 14:21:54 -04:00
|
|
|
|
2015-08-12 12:04:03 -04:00
|
|
|
When first run, it downloads part of the Android NDK.
|
2015-03-26 14:21:54 -04:00
|
|
|
The toolchain is installed in $GOPATH/pkg/gomobile.
|
|
|
|
|
|
|
|
The -u option forces download and installation of the new toolchain
|
|
|
|
even when the toolchain exists.
|
|
|
|
|
|
|
|
|
2015-07-11 11:55:10 -07:00
|
|
|
Compile android APK and install on device
|
2015-03-26 14:21:54 -04:00
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
2015-06-29 14:37:57 -04:00
|
|
|
gomobile install [-target android] [build flags] [package]
|
2015-03-26 14:21:54 -04:00
|
|
|
|
|
|
|
Install compiles and installs the app named by the import path on the
|
|
|
|
attached mobile device.
|
|
|
|
|
2015-06-29 14:37:57 -04:00
|
|
|
Only -target android is supported. The 'adb' tool must be on the PATH.
|
2015-03-26 14:21:54 -04:00
|
|
|
|
2015-07-30 09:59:04 -04:00
|
|
|
The build flags -a, -i, -n, -x, -gcflags, -ldflags, -tags, and -work are
|
|
|
|
shared with the build command.
|
2015-06-29 14:37:57 -04:00
|
|
|
For documentation, see 'go help build'.
|
2015-07-30 09:59:04 -04:00
|
|
|
|
|
|
|
|
|
|
|
Print version
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
gomobile version
|
|
|
|
|
2016-10-14 15:58:39 +02:00
|
|
|
Version prints versions of the gomobile binary and tools.
|
|
|
|
|
|
|
|
|
|
|
|
Gobind gradle plugin
|
|
|
|
|
|
|
|
The gobind gradle plugin integrates gomobile (and gobind) with the Android gradle
|
|
|
|
build system. The plugin supports two modes, library project and direct integration.
|
|
|
|
|
|
|
|
The library project mode is suitable for exporting Go packages to Android apps. To activate it,
|
|
|
|
create a gradle subproject and configure the gobind plugin in the build.gradle file:
|
|
|
|
|
|
|
|
apply plugin: "org.golang.mobile.bind"
|
|
|
|
|
|
|
|
gobind {
|
|
|
|
// The Go package path; must be under one of the GOPATH elements or
|
|
|
|
// a relative to the current directory (e.g. ../../hello)
|
|
|
|
pkg = "golang.org/x/mobile/example/bind/hello"
|
|
|
|
|
|
|
|
// Optional GOPATH.
|
|
|
|
// GOPATH = "/YOUR/GOPATH"
|
|
|
|
|
|
|
|
// Optional path to the go executable.
|
|
|
|
// GO = "/path/to/go"
|
|
|
|
|
|
|
|
// Optionally, set the absolute path to the gomobile binary.
|
|
|
|
// GOMOBILE = "/path/to/gomobile"
|
|
|
|
}
|
|
|
|
|
|
|
|
The direct integration mode is suitable for Go packages that import Java API, Android API,
|
|
|
|
project dependencies as well as generated R.* and Android databinding classes. In the
|
|
|
|
main Android project build.gradle, apply the gobind plugin after the android plugin:
|
|
|
|
|
|
|
|
apply plugin: 'com.android.application'
|
|
|
|
|
|
|
|
...
|
|
|
|
|
|
|
|
apply plugin: "org.golang.mobile.bind"
|
|
|
|
|
|
|
|
gobind {
|
|
|
|
pkg = "golang.org/x/mobile/example/bind/reverse"
|
|
|
|
}
|
|
|
|
|
2015-03-26 14:21:54 -04:00
|
|
|
*/
|
2015-11-04 15:25:32 -05:00
|
|
|
package main // import "golang.org/x/mobile/cmd/gomobile"
|