GithubHelp home page GithubHelp logo

xlab / android-go Goto Github PK

View Code? Open in Web Editor NEW
1.0K 1.0K 81.0 458 KB

The android-go project provides a platform for writing native Android apps in Go programming language.

Home Page: https://developer.android.com/ndk/index.html

License: MIT License

Makefile 0.30% Go 94.39% C 4.38% Assembly 0.11% Smarty 0.58% Shell 0.23%

android-go's People

Contributors

atlazar avatar florianuekermann avatar gmp216 avatar mrjrieke avatar tomas-mraz avatar xlab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-go's Issues

Egl Exemple not compilling

When i try to compile, return this error:

github.com/xlab/android-go/egl

../egl/display_handle.go:112:32: cannot convert unsafe.Pointer(window) (value of type unsafe.Pointer) to type NativeWindowType

I'm using the go 1.21.0

App: Add asset streaming

App should offer something like GetAssetReader(name string) io.ReadCloser to allow streaming large assets. The NDK functions work like that way anyway. See #7 for why this may not be trivial.

Update examples to match new build system

The new build system (the gradle stuff) is actually relatively nice (although it took me a whole day to figure out all of the details) and removes the need for the android tool.

I don't have time to update the examples right now and would also like to reduce some of the ridiculous boilerplate before that. I'll just document the most interesting ingredients here for later/others. I'll have more time in a couple of weeks.
It may be possible to shorten this a bit, but this is the conventional setup. The root (build) folder should contain these files for packing a .so into an apk with a native activity:

/build.gradle - top level build file (boilerplate)
/setting.gradle - this where the actual build file is includes (boilerplate)
/gradlew (boilerplate to make this work on independent of systems gradle version)
/gradle (boilerplate to make this work on independent of systems gradle version)
/app/build.gradle - actual build file
/app/src/main/AndroidManifest.xml
/app/src/main/jniLibs/armeabi-v7a/libexample.so - put the compiled go library here
/app/src/main/assets - put assets here

Running gradle(w) build will produce an apk.

build.gradle

buildscript {
    repositories {
       jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

/settings.gradle

include ':app'

/app/build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion = 24
    buildToolsVersion = '25.0.0'

    defaultConfig {
        applicationId = 'com.example.native_activity'
        minSdkVersion 24
        targetSdkVersion  24
        ndk {
            abiFilters 'armeabi-v7a'
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            jniDebuggable true
        }
    }
}

EGL bug. Opengl ES version Mismatch

I am trying to Port Nanovgo example to Android using andrioid-go and EGL

I modified Nanovgo to support GLES2 library from https://github.com/xlab/android-go/tree/master/gles2 , see modified version here nanovgo-gles

func init() {
	app.SetLogTag("GolangExample")
	// Initialise gl bindings using the current context.
	// err := gl.Init()
	// if err != nil {
	// 	log.Fatalln("gl.Init:", err)
	// }
}

func main() {
	log.Println("NativeActivity has started ^_^")
	log.Printf("Platform: %s %s", runtime.GOOS, runtime.GOARCH)
	nativeWindowEvents := make(chan app.NativeWindowEvent)
	var displayHandle *egl.DisplayHandle
	ctx, err := nanovgo.NewContext(0)
	if err != nil {
		panic(err)
	}

	//demoData = LoadDemo(ctx)
	app.Main(func(a app.NativeActivity) {
		a.HandleNativeWindowEvents(nativeWindowEvents)
		a.InitDone()
		for {
			select {
			case event := <-a.LifecycleEvents():
				switch event.Kind {
				case app.OnCreate:
					log.Println(event.Kind, "handled")
				default:
					log.Println(event.Kind, "event ignored")
				}
			case event := <-nativeWindowEvents:
				switch event.Kind {
				case app.NativeWindowRedrawNeeded:
					a.NativeWindowRedrawDone()
					draw(displayHandle, ctx)
					log.Println(event.Kind, "handled")
				case app.NativeWindowCreated:
					expectedSurface := map[int32]int32{
						egl.SurfaceType: egl.WindowBit,
						egl.RedSize:     8,
						egl.GreenSize:   8,
						egl.BlueSize:    8,
					}
					if handle, err := egl.NewDisplayHandle(event.Window, expectedSurface); err != nil {
						log.Fatalln("EGL error:", err)
					} else {
						displayHandle = handle
						log.Printf("EGL display res: %dx%d", handle.Width, handle.Height)
					}
					initGL()
				case app.NativeWindowDestroyed:
					displayHandle.Destroy()
				default:
					log.Println(event.Kind, "event ignored")
					//demoData.FreeData(ctx)
				}
			}
		}
	})
}

func initGL() {
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.Enable(gl.CULL_FACE)
	gl.Disable(gl.DEPTH_TEST)
}

func draw(handle *egl.DisplayHandle, ctx *nanovgo.Context) {
	fmt.Println("draw")
	//fps := perfgraph.NewPerfGraph("Frame Time", "sans")

	//t, _ := fps.UpdateGraph()

	pixelRatio := float32(handle.Width) / float32(handle.Height)

	gl.Viewport(0, 0, int32(handle.Width), int32(handle.Height))
	fmt.Println("view port")

	gl.ClearColor(0, 0, 0, 0)
	fmt.Println("clear color")

	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	ctx.BeginFrame(int32(handle.Width), int32(handle.Height), pixelRatio)
	fmt.Println("begin frame")

	demo.RenderDemo(ctx, 0, 0, 300, 600, 0, false, &demo.DemoData{})

	//fps.RenderGraph(ctx, 5, 5)

	ctx.EndFrame()

	//gl.Enable(gl.DEPTH_TEST)

	//glfw.PollEvents()

	handle.SwapBuffers()

}

demo.go :

func RenderDemo(ctx *nanovgo.Context, mx, my, width, height, t float32, blowup bool, data *DemoData) {
	// Widgets
	drawWindow(ctx, "Widgets `n Stuff", 50, 50, 300, 400)
	var x float32 = 60.0
	var y float32 = 95.0
	fmt.Println("Draw Window")
	drawSearchBox(ctx, "Search", x, y, 280, 25)
	y += 40
	fmt.Println("Draw Search")
	drawDropDown(ctx, "Effects", x, y, 280, 28)
	//popy := y + 14
	y += 45
	fmt.Println("Draw DropDown")
	// Form
	drawLabel(ctx, "Login", x, y, 280, 20)
	y += 25
	fmt.Println("Draw Label")
	drawEditBox(ctx, "Email", x, y, 280, 28)
	y += 35
	fmt.Println("Draw Edit Box")
	drawEditBox(ctx, "Password", x, y, 280, 28)
	y += 38
	fmt.Println("Draw Password")
	drawCheckBox(ctx, "Remember me", x, y, 140, 28)
	fmt.Println("Draw  Checkbox")
	drawButton(ctx, IconLOGIN, "Sign in", x+138, y, 140, 28, nanovgo.RGBA(0, 96, 128, 255))
	y += 45
	fmt.Println("Draw Button")

	// Slider
	drawLabel(ctx, "Diameter", x, y, 280, 20)
	y += 25
	drawEditBoxNum(ctx, "123.00", "px", x+180, y, 100, 28)
	drawSlider(ctx, 0.4, x, y, 170, 28)
	y += 55

	drawButton(ctx, IconTRASH, "Delete", x, y, 160, 28, nanovgo.RGBA(128, 16, 8, 255))
	drawButton(ctx, 0, "Cancel", x+170, y, 110, 28, nanovgo.RGBA(0, 0, 0, 0))

	fmt.Println("finished rendering")
	// Thumbnails box
	//drawThumbnails(ctx, 365, popy-30, 160, 300, data.Images, t)
}

BUG:

i am getting a blank screen with these errors

06-08 11:37:00.885 23648-23666/? I/GolangExample: NativeActivity has started ^_^
06-08 11:37:00.885 23648-23666/? I/GolangExample: Platform: android arm
06-08 11:37:00.887 23648-23666/? I/GolangExample: Shader shader/vert error:
06-08 11:37:00.888 23648-23667/? I/GolangExample: onCreate handled
06-08 11:37:00.890 23648-23666/? I/GolangExample: onStart event ignored
06-08 11:37:00.893 23648-23666/? I/GolangExample: onResume event ignored
06-08 11:37:00.894 23648-23648/? D/ActivityThread: EYE startEyeVerifyBroadcast packagename=com.go_android.minimal; ClassName=android.app.NativeActivity
06-08 11:37:00.903 23648-23648/? V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = null, this = DecorView@2359018[],statusBarBackground visible =false,statusColor: 0xff000000->
06-08 11:37:00.919 23648-23648/? D/WindowClient: Add to mViews: DecorView@2359018[NativeActivity], this = android.view.WindowManagerGlobal@4cddbcf
06-08 11:37:00.934 23648-23648/? V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = ViewRoot{5b9d95c com.go_android.minimal/android.app.NativeActivity,ident = 0}, this = DecorView@2359018[NativeActivity],statusBarBackground visible =false,statusColor: 0xff000000->
06-08 11:37:00.968 23648-23648/? I/lulingjie--screenshot--observer--: observer is rigistedDecorView@2359018[NativeActivity]
06-08 11:37:00.994 23648-23648/? V/InputMethodManager: onWindowFocus: null softInputMode=272 first=true flags=#10100
06-08 11:37:01.027 23648-23666/? D/Surface: Surface::setBuffersUserDimensions(this=0xe663a000,w=0,h=0)
06-08 11:37:01.040 23648-23666/? D/Surface: Surface::connect(this=0xe663a000,api=1)
06-08 11:37:01.042 23648-23666/? W/libEGL: [ANDROID_RECORDABLE] format: 2
06-08 11:37:01.047 23648-23666/? D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000
06-08 11:37:01.051 23648-23666/? I/GolangExample: EGL display res: 640x1070
06-08 11:37:01.052 23648-23664/? I/GolangExample: draw
06-08 11:37:01.052 23648-23664/? I/GolangExample: view port
06-08 11:37:01.052 23648-23664/? I/GolangExample: clear color
06-08 11:37:01.066 23648-23666/? D/GraphicBuffer: register, handle(0xe91913c0) (w:640 h:1070 s:640 f:0x2 u:0x000b00)
06-08 11:37:01.068 23648-23664/? I/GolangExample: begin frame
06-08 11:37:01.068 23648-23664/? I/GolangExample: Draw Window
06-08 11:37:01.068 23648-23664/? I/GolangExample: Draw Search
06-08 11:37:01.069 23648-23664/? I/GolangExample: Draw DropDown
06-08 11:37:01.069 23648-23664/? I/GolangExample: Draw Label
06-08 11:37:01.069 23648-23664/? I/GolangExample: Draw Edit Box
06-08 11:37:01.069 23648-23664/? I/GolangExample: Draw Password
06-08 11:37:01.069 23648-23664/? I/GolangExample: Draw  Checkbox
06-08 11:37:01.070 23648-23664/? I/GolangExample: Draw Button
06-08 11:37:01.070 23648-23666/? D/MALI: gles_state_set_error_internal:75: [MALI] GLES ctx: 0xa6680008, error code:0x502
06-08 11:37:01.070 23648-23666/? D/MALI: gles_state_set_error_internal:76: [MALI] GLES error info: OpenGL ES API version mismatch

Building Android-go in Android Open Source Project (AOSP)

How can we build android-go in Android Open Source Project (AOSP) for android marshmallow 6.0. Can you please help me with the steps for it. And after building Android-Go, will it generate JAR file so that other application can use this?

Error stdlib.h trying to build example directory

I'm getting an error when I try to build the example directory using ../build-android.sh

_cgo_export.c:2:20: fatal error: stdlib.h: No such file or directory
Anyone have any ideas?

The full log is

../build-android.sh 
+ : 26
+ : /home/jsper/Downloads
+ : /home/jsper/Downloads/ndk-bundle
+ export ANDROID_API ANDROID_HOME ANDROID_NDK_HOME
+ /home/jsper/Downloads/tools/bin/sdkmanager --update
[=======================================] 100% Computing updates...             
+ /home/jsper/Downloads/tools/bin/sdkmanager ndk-bundle
[=======================================] 100% Computing updates...             
+ rm -rf android/toolchain
+ /home/jsper/Downloads/ndk-bundle/build/tools/make_standalone_toolchain.py --install-dir=android/toolchain --arch=arm --api=26 --stl=libc++
+ rm -rf android/toolchain/sysroot/usr
+ cp -r /home/jsper/Downloads/ndk-bundle/platforms/android-26/arch-arm/usr android/toolchain/sysroot/usr
+ mkdir -p android/app/src/main/jniLibs/armeabi-v7a
+ GOOS=android
+ GOARCH=arm
+ GOARM=7
+ go get -d
+ CC=/home/jsper/go/src/github.com/xlab/android-go/examples/minimal/android/toolchain/bin/arm-linux-androideabi-gcc
+ CXX=/home/jsper/go/src/github.com/xlab/android-go/examples/minimal/android/toolchain/bin/arm-linux-androideabi-g++
+ CGO_ENABLED=1
+ CGO_CFLAGS=-march=armv7-a
+ GOOS=android
+ GOARCH=arm
+ GOARM=7
+ go build -i -buildmode=c-shared -o android/app/src/main/jniLibs/armeabi-v7a/libgomain.so
# runtime/cgo
_cgo_export.c:2:20: fatal error: stdlib.h: No such file or directory
 #include <stdlib.h>
                    ^
compilation terminated.

Thanks

https://stackoverflow.com/questions/48813751/building-android-go-stdlib-h-no-such-file-or-directory

error callfn

Maybe I make someting wrong , I got this error:

C:\Users\catafest\go\src\github.com\xlab\android-go\app\app.go:20:2: build constraints exclude all Go files in C:\Users\catafest\go\src\github.com\xlab\android-go\app\internal\callfn

Exposing golang direct to Flutter

Its all explained here:
flutter/flutter#7053

Basically at the moment if you want to use golang with flutter so need to write Java and Objective C wrappers. I have been doing it this way using gomobile bind and then writing wrappers. Quite painful and high latency.

So many cpp programmers have been asking the Flutter Team for direct calls between cpp and flutter, and the Flutter team are have listened and are exposing it.

SO i think think that maybe android-go and ios-go would fit in their well.

Also i noticed that already have FlatBuffers exposed between Dart and cpp and golang.
https://github.com/dnfield/flatbuffers/blob/master/samples/sample_binary.go.

android project update is not working on debian

  1. I create go workspace.
  2. Install go 1.10.2 version.
  3. Dowload Android SDK (Command line tools only) for linux.
  4. Extract archive
  5. Set ANDROID_HOME variable in bashrc file.
  6. Run go get github.com/xlab/android-go/cmd/android-project
  7. Run android project update

Got:

screenshot at 2018-05-31 14-22-55

Please HELP!

App: Add getting asset directory contents

The NDK implements exploration of asset directories via the AAssetDir iterator. I suspect AAssetDir is not thread-safe, so it may be bad idea to copy the iterator model that the NDK uses. Something like app.NativeActivity.GetAssetDirContents(name string) []string should be relatively safe and is much nicer to use anyway (like ioutil.ReadDir(dirname string) ([]os.FileInfo, error)).

Android Service

Is there anyway by which one can build and interact with an Android Service or IntentService? So long-running background apps can be built without the Android Runtime killing and restarting at will.

gles2 runtime error: cgo argument has Go pointer to Go pointer

I am trying to port nanovgo to android using android-go

I am trying to pass vertices []float32 data into gl.BufferData but I am getting a runtime error.

gl.BufferData(gl.ARRAY_BUFFER, len(b), unsafe.Pointer(&vertexes), gl.STREAM_DRAW)

06-05 12:22:17.041 32181-0/com.go_android.minimal E/Go: panic: runtime error: cgo argument has Go pointer to Go pointer
06-05 12:22:17.041 32181-0/com.go_android.minimal E/Go: goroutine 7 [running]:
06-05 12:22:17.041 32181-0/com.go_android.minimal E/Go: github.com/xlab/android-go/gles3.BufferData.func1(0x8892, 0x3940, 0xb7ae2258, 0x88e0)
06-05 12:22:17.041 32181-0/com.go_android.minimal E/Go: 	/Users/damilare/go/src/github.com/xlab/android-go/gles3/gles3.go:110 +0x3c
06-05 12:22:17.041 32181-0/com.go_android.minimal E/Go: github.com/xlab/android-go/gles3.BufferData(0x8892, 0x3940, 0xb7ae2258, 0x88e0)
06-05 12:22:17.041 32181-0/com.go_android.minimal E/Go: 	/Users/damilare/go/src/github.com/xlab/android-go/gles3/gles3.go:110 +0x34
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: github.com/shibukawa/nanovgo.(*glParams).renderFlush(0xb7a5e258)
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: 	/Users/damilare/go/src/github.com/shibukawa/nanovgo/gl_backend.go:584 +0x188
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: github.com/shibukawa/nanovgo.(*Context).EndFrame(0xb7abe090)
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: 	/Users/damilare/go/src/github.com/shibukawa/nanovgo/nanovgo.go:169 +0x28
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: main.draw(0xb7abe090)
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: 	/Users/damilare/go/src/github.com/darmie/nanovg-android/main.go:86 +0x180
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: main.main.func1(0xd7cf0f00, 0xd7d602a8)
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: 	/Users/damilare/go/src/github.com/darmie/nanovg-android/main.go:53 +0x35c
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: github.com/xlab/android-go/app.Main(0xb7a7ffc4)
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: 	/Users/damilare/go/src/github.com/xlab/android-go/app/app.go:86 +0x38
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: main.main()
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: 	/Users/damilare/go/src/github.com/darmie/nanovg-android/main.go:37 +0x17c
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: github.com/xlab/android-go/app/internal/callfn.CallFn(0xd7c6d39c)
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: 	/Users/damilare/go/src/github.com/xlab/android-go/app/internal/callfn/callfn_arm.s:10 +0x18
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: created by github.com/xlab/android-go/app.callMain
06-05 12:22:17.042 32181-0/com.go_android.minimal E/Go: 	/Users/damilare/go/src/github.com/xlab/android-go/app/app.go:50 +0x2e4
06-05 12:22:17.043 32181-32208/com.go_android.minimal A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 32208 (android.minimal)

404 to example in readme

The readme links to the minimal example application, however the link https://github.com/xlab/android-go/tree/master/example results in a 404. Note that other projects, such as https://github.com/golang-ui/nuklear, also refer to the old example app at that link. Thus is would be preferable either to restore the location of the minimal example such that the old link works, or update the link in both android-go, golang-ui/nuklear (and other repos referring to the old link).

Pointer type uint32 is too small for 64bit compilation (*_Ctype_ulong)

Hi, I made new build scripts for the android vulkandraw app in the forked repo https://github.com/tomas-mraz/vulkan-go_demos.
And it works in minimum configuration for 32bit arm architecture.
But for arm64 (aarch64) arch during compilation "so" library occurs error:

app.c:44:44: warning: incompatible function pointer types assigning to 'void (*)(ANativeActivity *, int)' (aka 'void (*)(struct ANativeActivity *, int)') from 'void (ANativeActivity *, GoInt)' (aka 'void (struct ANativeActivity *, long long)') [-Wincompatible-function-pointer-types]
# github.com/xlab/android-go/app
C:\Go\pkg\mod\github.com\xlab\[email protected]\app\events.go:116:38: cannot convert outSize (variable of type *_Ctype_ulong) to type *uint32
make: *** [Makefile:14: build64] Error 2

I understand the pointer to memory must be in a 64bit world much bigger. OK.

I changed in events.go lines

104 type SaveStateFunc func(activity *android.NativeActivity, size *uint64) unsafe.Pointer
116	result := fn(activityRef, (*uint64)(outSize))
126 func onWindowFocusChanged(activity *C.ANativeActivity, hasFocus int64) {

but the compilation is still not satisfied... and incompatible with 'void (*)(ANativeActivity *, int)' ... where does it come from?
Can someone point me in the right direction, please? Thanks.

Question about integration.

Sorry to ask general questions but I have been using gomobile and noticed the android and iOS projects your working on.
It looks like a great approach and I want to ask a few questions in relation to my needs.

My GUI is web based using gopherjs with golang backend. The backend also goes on the mobiles with a websockets RPC between the GUI and backend all fully strongly typed due to gopherjs.

So here is what I would need.

  1. Need webview. To boot the GUI.

  2. Need RPC over web sockets.

When I use gomobile, i have to write all the RPC code in java and objective C, and then the golang code & web code uses them as a conduit.

But perhaps with the xlab approach I can write more in golang ?

Take photo

How can I open the camera intent to take a photo and save it?

Can't build example project

I am reading guidelines from:
https://github.com/xlab/android-go/tree/master/example

I hit this:

everton@homeubu:~/go/src/github.com/xlab/android-go/example/android$ make project
# (optional) android list targets
android update project --target android-23 --name GolangExample --path .
make: android: Command not found
Makefile:12: recipe for target 'project' failed
make: *** [project] Error 127
everton@homeubu:~/go/src/github.com/xlab/android-go/example/android$

I noticed the need for the 'android' tool. However:

everton@homeubu:~/go/src/github.com/xlab/android-go/example/android$ ~/Android/Sdk/tools/android 
The android command is no longer available.
For manual SDK and AVD management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
everton@homeubu:~/go/src/github.com/xlab/android-go/example/android$ 

How can I get past such a point?

llvm/prebuilt/darwin-x86_64/bin/clang: No such file or directory

I'm a Go developer and new to Android and I'm trying to find out whether I can use android-go to build an Android Things app. I am trying to build the minimal example with go1.11 on macOS 10.14 (Mojave) for API version 27.

I'm getting the following output. Any help is greatly appreciated :)

$ ANDROID_HOME=~/android-sdk ../build-android.sh
+ : 27
+ : /Users/frank/android-sdk
+ : /Users/frank/android-sdk//ndk-bundle
+ export ANDROID_API ANDROID_HOME ANDROID_NDK_HOME
+ /Users/frank/android-sdk/tools/bin/sdkmanager --update
[=======================================] 100% Computing updates...
+ /Users/frank/android-sdk/tools/bin/sdkmanager ndk-bundle
[=======================================] 100% Computing updates...
+ rm -rf android/toolchain
+ /Users/frank/android-sdk//ndk-bundle/build/tools/make_standalone_toolchain.py --install-dir=android/toolchain --arch=arm --api=27 --stl=libc++
+ mkdir -p android/app/src/main/jniLibs/armeabi-v7a
+ GOOS=android
+ GOARCH=arm
+ GOARM=7
+ go get -d
+ CC=/Users/frank/src/github.com/xlab/android-go/examples/minimal/android/toolchain/bin/arm-linux-androideabi-gcc
+ CXX=/Users/frank/src/github.com/xlab/android-go/examples/minimal/android/toolchain/bin/arm-linux-androideabi-g++
+ CGO_ENABLED=1
+ CGO_CFLAGS=-march=armv7-a
+ GOOS=android
+ GOARCH=arm
+ GOARM=7
+ go build -i -buildmode=c-shared -o android/app/src/main/jniLibs/armeabi-v7a/libgomain.so
# runtime/cgo
/Users/frank/src/github.com/xlab/android-go/examples/minimal/android/toolchain/bin/arm-linux-androideabi-gcc: line 2: /Users/frank/src/github.com/xlab/android-go/examples/minimal/android/toolchain/bin/../../../../llvm/prebuilt/darwin-x86_64/bin/clang: No such file or directory
/Users/frank/src/github.com/xlab/android-go/examples/minimal/android/toolchain/bin/arm-linux-androideabi-gcc: line 2: exec: /Users/frank/src/github.com/xlab/android-go/examples/minimal/android/toolchain/bin/../../../../llvm/prebuilt/darwin-x86_64/bin/clang: cannot execute: No such file or directory

example-egl build fails

I have followed the instructions as per the readme, but I can't build the example app.

I also am having problems building the nk-android example. I must have something missing in my environment. Any help appreciated.

The CompileOptions.bootClasspath property has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the CompileOptions.bootstrapClasspath property instead.
:android:prepareToolchain
Preparing toolchains for ABIs: armeabi-v7a x86 Android API: 26
Using existing standalone toolchain for arch: x86
Using existing standalone toolchain for arch: arm
:android:buildGo
Build Go sources using ABIs: armeabi-v7a x86 Android API: 26
Cleaning output dir build_go/output
++ pwd
+ CURRENT_DIR=/home/simulator/go/src/github.com/xlab/android-go/example-egl
+ CC=/home/simulator/go/src/github.com/xlab/android-go/example-egl/android/build_go/toolchain/arm/bin/arm-linux-androideabi-gcc
+ CXX=/home/simulator/go/src/github.com/xlab/android-go/example-egl/android/build_go/toolchain/arm/bin/arm-linux-androideabi-g++
+ CGO_ENABLED=1
+ CGO_CFLAGS=-march=armv7-a
+ GOOS=android
+ GOARCH=arm
+ GOARM=7
+ go build -i -pkgdir /home/simulator/go/src/github.com/xlab/android-go/example-egl/android/build_go/output/armeabi-v7a -buildmode=c-shared -o android/src/main/jniLibs/armeabi-v7a/libgomain.so
# runtime/cgo
_cgo_export.c:2:20: fatal error: stdlib.h: No such file or directory
 #include <stdlib.h>
                    ^
compilation terminated.
:android:buildGo FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android:buildGo'.
> Process 'command '../bash_script/build_go.sh'' finished with non-zero exit value 2

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
2 actionable tasks: 2 executed


Any help appreciated. I have written a nuklear app, and it runs on Linux/FreeBSD I am trying to get it to run on Android.

NativeActivity.AssetManager is nil

The AssetManager field of the android.NativeActivity returned by app.NativeActivity.NativeActivity() is nil.

I'm building for API 24 with:
export CGO_CFLAGS="-march=armv7-a"
export GOOS=android
export GOARCH=arm
export GOARM=7

The device is a Pixel XL

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.