Home  >  Article  >  Can golang be used for Android development?

Can golang be used for Android development?

百草
百草Original
2023-07-07 11:13:433254browse

golang can be used for Android development. In 2014, go language developers mentioned that the android platform would introduce go development. Go language version 1.5 also released gomobile for the development of mobile applications. Gomobile is a tool for building and running mobile applications written in Go, and is a way of converting Go code bases into Android/iOS libraries.

Can golang be used for Android development?

The operating environment of this tutorial: Windows 10 system, GO version 1.20, Dell G3 computer.

Golang can write Android. There is a new library in golang called go.mobile, which contains Go for Android library tools.

In 2014, the developers of the go language mentioned that the android platform would introduce go development. The GO language version 1.5 also released gomobile for the development of mobile applications. Gomobile is a tool for building and running mobile applications written in Go, and is a way of converting Go code bases into Android/iOS libraries.

Go (also known as Golang) is a statically strongly typed, compiled, concurrent programming language with garbage collection capabilities developed by Google.

Go's syntax is close to C language, but the declaration of variables is different. Go supports garbage collection. Go's parallel model is based on Tony Hall's Communicating Sequential Process (CSP). Other languages ​​that adopt a similar model include Occam and Limbo, but it also has features of Pi operations, such as channel transmission. Plugin support is opened in version 1.8, which means that some functions can now be dynamically loaded from Go.

C language is a process-oriented, abstract, general-purpose programming language that is widely used in low-level development. C language can compile and process low-level memory in a simple way. C language is an efficient programming language that only generates a small amount of machine language and can run without any operating environment support. Although the C language provides many low-level processing functions, it still maintains cross-platform characteristics. C language programs written in a standard specification can be executed on many computer platforms including operating platforms such as embedded processors and supercomputers. Compile.

In the readme of the go.mobile library, there is an introduction to the establishment of a development environment, but it is limited to early versions, and the build system integrated into the IDE is not yet available.

1. First you need Android SDK and NDK.

2. Then you need to add an environment variable: NDK_ROOT=$HOME/android/ndk-toolchain

3. Configure the NDK tool ndk/build/tools/make-standalone-toolchain.sh - platform=android-9 --install-dir=$NDK_ROOT

4. Install Go cross-compiler

hg clone https://code.google.com/p/go
cd go/src
CC_FOR_TARGET=$NDK_CC GOOS=android GOARCH=arm GOARM=7 ./make.bash

Copy after logging in

5. If it has been installed before GO, by default is for the computer platform, so ARM is built here. That's probably what it means.

6. Add go/bin to the path environment variable

Using Go, you can develop two projects, one is the android JAVA code called to go, the other is written in pure Go APP, the second one provides open gl and complete golang development environment.

The above is the detailed content of Can golang be used for Android development?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What software is ingress?Next article:What software is ingress?