Closed vboehr closed 1 year ago
Does the library support android? I'm not sure this ticket belongs in the toolkit bug tracker...
Apparently the library does run on android: https://github.com/anacrolix/torrent/issues/808
If so, would you mind creating a minimal example application to make it easier to test? Also, FYI, I agree with @andydotxyz that this might not be the right place to put it. Does not necessarily seem to be a Fyne issue.
There is a high chance your code is initialising the torrent library to use file storage you don't have access to. As you'll see in our docs the general Go file libraries won't necessarily work and we encourage our "storage" package for the cross-platform guarantees.
I used "adb logcat" to get the runtime error and I got +1 java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
I asked chatgpt to explain this runtime error and here its answer:
CHATGPT answer: Based on the error message you provided, it seems that the libc++_shared.so library is missing. This library is required by the libwetorrent_rebirth.so library, which is used by your app.
To fix this issue, you should make sure that you have included the libc++_shared.so library in your project and that it is being properly loaded by your app.
Here are some steps you can try to resolve this issue:
Check that you have included the libc++_shared.so library in your project. You can do this by looking for the library in your project's libs directory. If the library is missing, you may need to download it from the Android NDK and include it in your project.
If the libc++_shared.so library is present in your project, you should check that it is being properly loaded by your app. You can do this by checking your app's Android.mk or CMakeLists.txt file to ensure that the library is included in the LOCAL_LDLIBS variable.
If you are still having issues, you may want to try building your app with a different version of the Android NDK, as the version you are using may not be compatible with your project.
I hope this helps! Let me know if you have any further questions or concerns.
Based on anacrolix recommendation described here (https://github.com/anacrolix/torrent/issues/809). I tried disabling the part that uses c++ (which is called "libutp") with the following command:
./fyne-cmd package -os android -appID com.test.myapp -icon ./Icons/appicon.png --tags=disable_libutp
Yet I still have the same error.
Is my command correctly passing tags to fyne?
I think you have found a short coming of our iOS and Android build. I don't think we are currently passing the tags when building for those mobile OS. I will do a PR to cover this shortly.
In the mean time, you can verify, if you are on Linux, that this will do what you want. You can build for Linux and then use the ldd
to list all the library used by your application. If there is no reference to that shared C++ library, it means that with a fix for propagating tags when building for Android and iOS, you will be good.
If you can also test the branch of PR #3674 by doing a go install fyne.io/fyne/cmd/fyne@e33124d67edd0cda23b2b1745fb73dff0e1be5c5
and then using the newly installed fyne
command to build for android.
It is now in develop, so you can just check after doing go install fyne.io/fyne/cmd/fyne@develop
.
Thanks for the help provided. I tested "fyne.io/fyne/cmd/fyne@develop" and now it passing "disable_libutp" tag to the build, which solved the issue. Now I can use "anacrolix/torrent" in a fyne app !
Thanks again !
Fantastic, thanks for checking :)
Checklist
Describe the bug
I am trying to package an android fyne app that uses the following torrent library: github.com/anacrolix/torrent
Yet after installing the app on android and running it I get a black screen and app stops.
How to reproduce
create a new go mod go mod init fynetorrentguiapp
go get fyne.io/fyne/v2
go get github.com/anacrolix/torrent
touch main.go
add the example code include below
package the app as follow: ./fyne-cmd package -os android -appID com.fynetorrentguiapp.myapp
install the app on android and run it.
Screenshots
No response
Example code
'''go package main import ( "log" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/widget" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/data/binding" "fyne.io/fyne/v2/canvas" "image/color" "time"
"fmt" "github.com/anacrolix/torrent" ) var mainapp fyne.App var AppLocation string var MainTorrent string//magnet var MainFile string//filepath var AppIsClosing bool func main() { mainapp= app.New() AppIsClosing=false AppLocation=mainapp.Storage().RootURI().String() fmt.Println("AppLocation :",AppLocation) mainwin := mainapp.NewWindow("wetorrent") mainwin.Resize(fyne.NewSize(400, 710)) go initmainclient() tabs := container.NewAppTabs( container.NewTabItem("Home", homeScreen(mainwin)), ) tabs.SetTabLocation(container.TabLocationTop) mainwin.SetContent(tabs)
mainwin.ShowAndRun() AppIsClosing=true } func homeScreen(win fyne.Window) fyne.CanvasObject { data := binding.BindStringList( //&[]string{"Item 1", "Item 2", "Item 3"}, &[]string{}, ) list := widget.NewListWithData(data, func() fyne.CanvasObject { return widget.NewLabel("template") }, func(i binding.DataItem, o fyne.CanvasObject) { o.(widget.Label).Bind(i.(binding.String)) }) text := canvas.NewText("Text Object"+AppLocation, color.Black) add := widget.NewButton("Open New Webapp Tab", func() { //val := fmt.Sprintf("Item %d", data.Length()+1) //data.Append(val) fmt.Println("coool") }) return container.NewBorder( text,add, nil, nil, list)
} var mainclient torrent.Client func initmainclient() { cfg := torrent.NewDefaultClientConfig() //cfg.Seed = true cfg.DataDir=AppLocation// //cfg.NoDHT = true //cfg.DisableTCP = true //cfg.DisableUTP = true //cfg.DisableAggressiveUpload = false //cfg.DisableWebtorrent = false //cfg.DisableWebseeds = false var err error mainclient, err = torrent.NewClient(cfg) if err != nil { log.Print("new torrent client: %w", err) return //fmt.Errorf("new torrent client: %w", err) } log.Print("new torrent client INITIATED") defer mainclient.Close() for { if AppIsClosing { log.Print("closing mainclient") break } time.Sleep(1 * time.Second) } // } ''''
Fyne version
v2.3.0
Go compiler version
go1.20 linux/amd64
Operating system
Linux
Operating system version
Ubuntu 18.04.6 LTS (Bionic Beaver)
Additional Information
./fyne-cmd env
Go module info
cli_version="(devel)" go_mod="true" go_path="false" imported="true" path="***" version="v2.3.0"
Go version info
version="go1.20 linux/amd64"
Go environment info
CGO_ENABLED="1" GO111MODULE="" GOARCH="amd64" GOOS="linux"
OS info
architecture="x86_64" home_url="https://www.ubuntu.com/" kernel="Linux 5.4.0-137-generic #154~18.04.1-Ubuntu SMP Tue Jan 10 16:58:20 UTC 2023" name="Ubuntu" version="18.04.6 LTS (Bionic Beaver)"