gomobile - no stack traces on Android

98 views
Skip to first unread message

Brien Colwell

unread,
Feb 29, 2024, 4:07:10 AM2/29/24
to golang-nuts
With gomobile, I’m not able to see stack traces for errors in the native library. For example:

```
02-29 00:50:16.021 10940 0 E Go : panic: runtime error: invalid memory address or nil pointer dereference
02-29 00:50:16.021 10940 0 E Go : [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x77c124ee40]
```

Is there a way to add stack traces?

My Makefile is below that builds the libs.


```
all: clean build_android build_ios

clean:
rm -rf build

build_android:
mkdir -p build/android
WARP_VERSION=`warpctl ls version`; \
gomobile bind \
-ldflags "-X client.Version=$$WARP_VERSION" \
-target=android -androidapi 19 \
-javapkg com.bringyour \
-trimpath \
-o build/android/BringYourClient.aar \
bringyour.com/client
#...

build_ios:
mkdir -p build/ios
WARP_VERSION=`warpctl ls version`; \
gomobile bind \
-ldflags "-X client.Version=$$WARP_VERSION" \
-target=ios -iosversion 14.0 \
-trimpath \
-o build/ios/BringYourClient.xcframework \
bringyour.com/client

init:
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init

```

On Android the compiled libs are added in Gradle as:

```
dependencies {
compileOnly fileTree(dir: "${System.env.HOME}/bringyour/bringyour/client/build/android", include: ['*-sources.jar'])
implementation fileTree(dir: "${System.env.HOME}/bringyour/bringyour/client/build/android", include: ['*.aar', '*.jar’])
}
```


Best,
Brien

Reply all
Reply to author
Forward
0 new messages