fyne-cross icon indicating copy to clipboard operation
fyne-cross copied to clipboard

Compile to andriod error

Open xfengw opened this issue 3 years ago • 18 comments

go 1.16 windows10 64 D:\project\mygosoft\src\urlPreciseBlockingWithLoginV2>fyne-cross android -app-id cn.xfeng [i] Target: android [i] Cleaning target directories... [✓] "temp" dir cleaned: D:\project\mygosoft\src\urlPreciseBlockingWithLoginV2\fyne-cross\tmp\android [✓] "bin" dir cleaned: D:\project\mygosoft\src\urlPreciseBlockingWithLoginV2\fyne-cross\bin\android [✓] "dist" dir cleaned: D:\project\mygosoft\src\urlPreciseBlockingWithLoginV2\fyne-cross\dist\android [i] Checking for go.mod: D:\project\mygosoft\src\urlPreciseBlockingWithLoginV2\go.mod [✓] go.mod found [i] Packaging app... go build -buildmode=c-shared -o /tmp/gomobile-work-422684388/lib/armeabi-v7a/liburlPreciseBlockingWithLoginV2.so urlPreciseBlockingWithLoginV2 failed: exit status 1 go: downloading github.com/fyne-io/mobile v0.1.2 /go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/gomobile/clipboard_android.go:17:2: github.com/fyne-io/[email protected]: Get "https://proxy.golang.org/github.com/fyne-io/mobile/@v/v0.1.2.zip": dial tcp 172.217.24.17:443: connect: connection refused /go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/gomobile/driver.go:9:2: github.com/fyne-io/[email protected]: Get "https://proxy.golang.org/github.com/fyne-io/mobile/@v/v0.1.2.zip": dial tcp 172.217.24.17:443: connect: connection refused /go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/gomobile/driver.go:10:2: github.com/fyne-io/[email protected]: Get "https://proxy.golang.org/github.com/fyne-io/mobile/@v/v0.1.2.zip": dial tcp 172.217.24.17:443: connect: connection refused /go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/gomobile/driver.go:11:2: github.com/fyne-io/[email protected]: Get "https://proxy.golang.org/github.com/fyne-io/mobile/@v/v0.1.2.zip": dial tcp 172.217.24.17:443: connect: connection refused /go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/gomobile/device.go:5:2: github.com/fyne-io/[email protected]: Get "https://proxy.golang.org/github.com/fyne-io/mobile/@v/v0.1.2.zip": dial tcp 172.217.24.17:443: connect: connection refused /go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/gomobile/driver.go:13:2: github.com/fyne-io/[email protected]: Get "https://proxy.golang.org/github.com/fyne-io/mobile/@v/v0.1.2.zip": dial tcp 172.217.24.17:443: connect: connection refused /go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/gl/gl_gomobile.go:11:2: github.com/fyne-io/[email protected]: Get "https://proxy.golang.org/github.com/fyne-io/mobile/@v/v0.1.2.zip": dial tcp 172.217.24.17:443: connect: connection refused /go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/gl/gl_gomobile.go:12:2: github.com/fyne-io/[email protected]: Get "https://proxy.golang.org/github.com/fyne-io/mobile/@v/v0.1.2.zip": dial tcp 172.217.24.17:443: connect: connection refused

[✗] could not package the Fyne app: could not package the Fyne app: exit status 1

xfengw avatar Jul 13 '21 06:07 xfengw

PS D:\project\mygosoft\src\urlPreciseBlockingWithLoginV2> fyne-cross android -app-id cn.xfeng -env GOPROXY=https://goproxy.io [i] Target: android [i] Cleaning target directories... [✓] "bin" dir cleaned: D:\project\mygosoft\src\urlPreciseBlockingWithLoginV2\fyne-cross\bin\android [✓] "dist" dir cleaned: D:\project\mygosoft\src\urlPreciseBlockingWithLoginV2\fyne-cross\dist\android [✓] "temp" dir cleaned: D:\project\mygosoft\src\urlPreciseBlockingWithLoginV2\fyne-cross\tmp\android [i] Checking for go.mod: D:\project\mygosoft\src\urlPreciseBlockingWithLoginV2\go.mod [✓] go.mod found [i] Packaging app... go build -buildmode=c-shared -o /tmp/gomobile-work-230436260/lib/armeabi-v7a/liburlPreciseBlockingWithLoginV2.so urlPreciseBlockingWithLoginV2 failed: exit status 2

github.com/fyne-io/mobile/app

ld: error: duplicate symbol: display

defined at android.go:38 $WORK/b175/_x001.o:(display) defined at android.go:38 (/go/pkg/mod/github.com/fyne-io/[email protected]/app/android.go:38) $WORK/b175/_x002.o:(.bss+0x0)

ld: error: duplicate symbol: surface

defined at android.go:39 $WORK/b175/_x001.o:(surface) defined at android.go:39 (/go/pkg/mod/github.com/fyne-io/[email protected]/app/android.go:39) $WORK/b175/_x002.o:(.bss+0x4)

ld: error: duplicate symbol: display

defined at android.go:38 $WORK/b175/_x001.o:(display) defined at android.c:146 $WORK/b175/_x004.o:(.bss+0x18)

ld: error: duplicate symbol: surface

defined at android.go:39 $WORK/b175/_x001.o:(surface) defined at android.c:147 $WORK/b175/_x004.o:(.bss+0x1C) clang: error: linker command failed with exit code 1 (use -v to see invocation)

[✗] could not package the Fyne app: could not package the Fyne app: exit status 1

xfengw avatar Jul 13 '21 07:07 xfengw

It looks like a network connection issue with the proxy:

dial tcp 172.217.24.17:443: connect: connection refused

Setting the GOPROXY env var should fix:

fyne-cross android -app-id cn.xfeng -env GOPROXY=<your_proxy>

lucor avatar Jul 13 '21 07:07 lucor

D:\project\mygosoft\src\urlPreciseBlockingWithLoginV2>fyne-cross android -app-id cn.xfeng -env GOPROXY=https://goproxy.io [i] Target: android [i] Cleaning target directories... [✓] "bin" dir cleaned: D:\project\mygosoft\src\urlPreciseBlockingWithLoginV2\fyne-cross\bin\android [✓] "dist" dir cleaned: D:\project\mygosoft\src\urlPreciseBlockingWithLoginV2\fyne-cross\dist\android [✓] "temp" dir cleaned: D:\project\mygosoft\src\urlPreciseBlockingWithLoginV2\fyne-cross\tmp\android [i] Checking for go.mod: D:\project\mygosoft\src\urlPreciseBlockingWithLoginV2\go.mod [✓] go.mod found [i] Packaging app... docker: error during connect: In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect.: Post "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/create": open //./pipe/docker_engine: The system cannot find the file specified. See 'docker run --help'. [✗] could not package the Fyne app: could not package the Fyne app: exit status 127

C:\Users\xfeng>docker run --help

Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container

Options: --add-host list Add a custom host-to-IP mapping (host:ip) -a, --attach list Attach to STDIN, STDOUT or STDERR --blkio-weight uint16 Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0) --blkio-weight-device list Block IO weight (relative device

xfengw avatar Jul 13 '21 23:07 xfengw

it looks like related to user privileges. Could you please make sure you are running from a terminal with same privileges the docker daemon is running?

lucor avatar Jul 14 '21 05:07 lucor

D:\project\mygosoft\src\fyne-examples-develop>fyne-cross android -app-id cn.xfeng -env GOPROXY=https://goproxy.io [i] Target: android [i] Cleaning target directories... [✓] "bin" dir cleaned: D:\project\mygosoft\src\fyne-examples-develop\fyne-cross\bin\android [✓] "dist" dir cleaned: D:\project\mygosoft\src\fyne-examples-develop\fyne-cross\dist\android [✓] "temp" dir cleaned: D:\project\mygosoft\src\fyne-examples-develop\fyne-cross\tmp\android [i] Checking for go.mod: D:\project\mygosoft\src\fyne-examples-develop\go.mod [✓] go.mod found [i] Packaging app... Unable to find image 'fyneio/fyne-cross:1.1-android' locally 1.1-android: Pulling from fyneio/fyne-cross d960726af2be: Already exists e8d62473a22d: Already exists 8962bc0fad55: Already exists 65d943ee54c1: Already exists f2253e6fbefa: Already exists 186c77a2a533: Pull complete db807893dccf: Pull complete 292f24f0ff89: Pull complete 974bf8135e20: Pull complete 6f6e9bee4d1e: Pull complete 566c48a9b3d8: Pull complete 9019a4581f1b: Pull complete 282dd26a693f: Pull complete Digest: sha256:b3d36509c011277176432d6faf5548437922146b7522c93360238c60aa70e1aa Status: Downloaded newer image for fyneio/fyne-cross:1.1-android go build -buildmode=c-shared -o /tmp/gomobile-work-971235108/lib/armeabi-v7a/libfyne_examples_develop.so github.com/fyne-io/examples failed: exit status 2

github.com/fyne-io/mobile/app

ld: error: duplicate symbol: display

defined at android.go:38 $WORK/b175/_x001.o:(display) defined at android.go:38 (/go/pkg/mod/github.com/fyne-io/[email protected]/app/android.go:38) $WORK/b175/_x002.o:(.bss+0x0)

ld: error: duplicate symbol: surface

defined at android.go:39 $WORK/b175/_x001.o:(surface) defined at android.go:39 (/go/pkg/mod/github.com/fyne-io/[email protected]/app/android.go:39) $WORK/b175/_x002.o:(.bss+0x4)

ld: error: duplicate symbol: display

defined at android.go:38 $WORK/b175/_x001.o:(display) defined at android.c:146 $WORK/b175/_x004.o:(.bss+0x18)

ld: error: duplicate symbol: surface

defined at android.go:39 $WORK/b175/_x001.o:(surface) defined at android.c:147 $WORK/b175/_x004.o:(.bss+0x1C) clang: error: linker command failed with exit code 1 (use -v to see invocation)

[✗] could not package the Fyne app: could not package the Fyne app: exit status 1

xfengw avatar Jul 14 '21 06:07 xfengw

oh it seems we're almost there ... Do you mind to test with a minimal hello world app using the latest version fyne?

lucor avatar Jul 14 '21 06:07 lucor

useing fyne v2.03

xfengw avatar Jul 14 '21 08:07 xfengw

package main

import (
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
)

func main() {
	a := app.New()
	w := a.NewWindow("Hello")

	hello := widget.NewLabel("Hello Fyne!")
	w.SetContent(container.NewVBox(
		hello,
		widget.NewButton("Hi!", func() {
			hello.SetText("Welcome :)")
		}),
	))

	w.ShowAndRun()
}

xfengw avatar Jul 14 '21 09:07 xfengw

is ok Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

xfengw avatar Jul 14 '21 09:07 xfengw

this is ok Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

xfengw avatar Jul 14 '21 09:07 xfengw

However, other software that can be compiled and run under windows cannot be compiled to android.

D:\project\mygosoft\src\riskExcel2021>fyne-cross android -app-id cn.xfeng -env GOPROXY=https://goproxy.io
[i] Target: android
[i] Cleaning target directories...
[✓] "bin" dir cleaned: D:\project\mygosoft\src\riskExcel2021\fyne-cross\bin\android
[✓] "dist" dir cleaned: D:\project\mygosoft\src\riskExcel2021\fyne-cross\dist\android
[✓] "temp" dir cleaned: D:\project\mygosoft\src\riskExcel2021\fyne-cross\tmp\android
[i] Checking for go.mod: D:\project\mygosoft\src\riskExcel2021\go.mod
[✓] go.mod found
[i] Packaging app...
go build -buildmode=c-shared -o /tmp/gomobile-work-189930580/lib/armeabi-v7a/libriskExcel2021.so riskExcel2021 failed: exit status 2
# fyne.io/fyne/v2/internal/driver/gomobile
android.c:50:9: warning: returning 'const char *' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
android.c:67:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
android.c:71:55: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
android.c:122:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
android.c:125:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
android.c:181:50: warning: passing 'char *' to parameter of type 'jbyte *' (aka 'signed char *') converts between pointers to integer types with different sign [-Wpointer-sign]
android.c:191:48: warning: passing 'char *' to parameter of type 'const jbyte *' (aka 'const signed char *') converts between pointers to integer types with different sign [-Wpointer-sign]
# fyne.io/fyne/v2/app
app_mobile_and.c:46:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
app_mobile_and.c:49:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
app_mobile_and.c:72:33: warning: incompatible pointer to integer conversion passing 'JNIEnv *' (aka 'const struct JNINativeInterface **') to parameter of type 'uintptr_t' (aka 'unsigned int') [-Wint-conversion]
app_mobile_and.c:42:36: note: passing argument to parameter 'jni_env' here
# riskExcel2021
/usr/local/go/pkg/tool/linux_amd64/link: running /usr/local/android_sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi16-clang failed: exit status 1
ld: error: /tmp/go-link-968878995/000000.o: unknown file type
clang: error: linker command failed with exit code 1 (use -v to see invocation)


[✗] could not package the Fyne app: could not package the Fyne app: exit status 1

xfengw avatar Jul 14 '21 09:07 xfengw

This normally means a stale cache:

ld: error: /tmp/go-link-968878995/000000.o: unknown file type

Try cleaning everything and trying again.

andydotxyz avatar Jul 14 '21 09:07 andydotxyz

The same code, compiled successfully on my other computer, I don't know why this happens.

xfengw avatar Jul 15 '21 00:07 xfengw

It is difficult to debug with these info. Could you please provide a minimal example that reproduces the problem? Additionally are you by any chance using a third party lib ? If so, please double check if that lib is compatible with android.

lucor avatar Aug 20 '21 09:08 lucor

Are you certain that you cleaned all caches after compiling for a different architecture? It is worth checking

andydotxyz avatar Aug 21 '21 10:08 andydotxyz

It is difficult to debug with these info. Could you please provide a minimal example that reproduces the problem? Additionally are you by any chance using a third party lib ? If so, please double check if that lib is compatible with android.

I think he pasted the code above

andydotxyz avatar Aug 21 '21 10:08 andydotxyz

It was my understanding that the code provided above was working correctly, hence my question. @xfengw could you please confirm and in case share the code along with the steps to reproduce the issue ?

lucor avatar Sep 17 '21 07:09 lucor

Oh. My reading of it was that the pasted code worked on Windows but not Android. Hopefully @xfengw can clarify

andydotxyz avatar Sep 21 '21 16:09 andydotxyz

Just updated fyne/mobile to 0.1.2 now I get this error:

[i] Target: android/multiple
[i] Cleaning target directories...
[✓] "dist" dir cleaned: /home/apollo/dev/go/fyne/Timey/fyne-cross/dist/android
[✓] "temp" dir cleaned: /home/apollo/dev/go/fyne/Timey/fyne-cross/tmp/android
[✓] "bin" dir cleaned: /home/apollo/dev/go/fyne/Timey/fyne-cross/bin/android
[i] Checking for go.mod: /home/apollo/dev/go/fyne/Timey/go.mod
[✓] go.mod found
[i] Packaging app...
2022/09/26 21:59:52 Unable to remove temporary build file /app/timey
go build -buildmode=c-shared -o /tmp/fyne-work-2401083611/lib/armeabi-v7a/libTimey.so red-green.com/timey failed: exit status 2
# github.com/fyne-io/mobile/app
ld: error: duplicate symbol: display
>>> defined at android.go:38
>>>            $WORK/b183/_x001.o:(display)
>>> defined at android.go:38 (/go/pkg/mod/github.com/fyne-io/[email protected]/app/android.go:38)
>>>            $WORK/b183/_x002.o:(.bss+0x0)

ld: error: duplicate symbol: surface
>>> defined at android.go:39
>>>            $WORK/b183/_x001.o:(surface)
>>> defined at android.go:39 (/go/pkg/mod/github.com/fyne-io/[email protected]/app/android.go:39)
>>>            $WORK/b183/_x002.o:(.bss+0x4)

ld: error: duplicate symbol: display
>>> defined at android.go:38
>>>            $WORK/b183/_x001.o:(display)
>>> defined at android.c:146
>>>            $WORK/b183/_x004.o:(.bss+0x18)

ld: error: duplicate symbol: surface
>>> defined at android.go:39
>>>            $WORK/b183/_x001.o:(surface)
>>> defined at android.c:147
>>>            $WORK/b183/_x004.o:(.bss+0x1C)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
# fyne.io/fyne/v2/internal/driver/mobile
android.c:51:9: warning: returning 'const char *' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
android.c:68:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
android.c:72:55: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
android.c:123:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
android.c:126:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
android.c:182:50: warning: passing 'char *' to parameter of type 'jbyte *' (aka 'signed char *') converts between pointers to integer types with different sign [-Wpointer-sign]
android.c:192:48: warning: passing 'char *' to parameter of type 'const jbyte *' (aka 'const signed char *') converts between pointers to integer types with different sign [-Wpointer-sign]
# fyne.io/fyne/v2/app
app_mobile_and.c:45:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
app_mobile_and.c:48:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
app_mobile_and.c:84:30: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
app_mobile_and.c:97:33: warning: incompatible pointer to integer conversion passing 'JNIEnv *' (aka 'const struct JNINativeInterface **') to parameter of type 'uintptr_t' (aka 'unsigned int') [-Wint-conversion]
app_mobile_and.c:41:36: note: passing argument to parameter 'jni_env' here

[✗] could not package the Fyne app: could not package the Fyne app: exit status 1

Things I've done:

  • [x] Blown away ~/.cache/fyne-cross/
  • [x] Blown away fyne-cross in the build/project directory
  • [x] Built the project with fyne-cross for under native Linux amd64
  • [x] Read this issue and some other issues in attempt to find a solution. (None found, as of yet, I hope)

Things I'm doing:

  • [x] Building a good simple example for comparison (It appears all my attempts do not succeed in reproducing my possible error, I was thinking it was the storage in fyne but nope, or maybe apptabs but nope, so not sure what causing it, My test code https://github.com/Beanzilla/fyne_breaker_53)

Beanzilla avatar Sep 26 '22 22:09 Beanzilla

You should not need to include fyne/mobile in a Fyne app, it will be included for you. The error is due to you having multiple libraries add the same code, so either you have fyne.io/fyne plus the mobile project, or you are mixing fyne.io/fyne and fyne.io/fyne/v2.

andydotxyz avatar Sep 27 '22 16:09 andydotxyz

I think that the original error was resolved above, and indeed the new question answered as well. Closing before we get more questions on the same ticket ;).

andydotxyz avatar Sep 27 '22 16:09 andydotxyz

Ok, Thank you for the help.

That would explain why the example works just fine, because I don't mix fyne and fyne/v2.

Just confirmed yup, I had fyne.io/fyne/dialog while everything else was using fyne/v2/<something>, (simple fix fyne.io/fyne/v2/dialog and we successfully built)

Beanzilla avatar Sep 27 '22 18:09 Beanzilla