Android Port Discussion

If you have go vet from the go package then that’s fine, there is no need to install it again. The error from ./build setup can be safely ignored.

Alright. What about a check if go vet is already installed? (to not confuse people). Eg by running go help vet and checking the return value.

Pull requests acceptable. :slight_smile:

I’ll give it a try :wink:

Local discovery works now, great! But there’s a new warning dialog (did you add that or was it not displayed earlier because it already failed at local discovery?), that says “Global discovery: error reading DNS config: open /etc/resolv.conf: no such file or directory; no external announcements”. Do you access that file manually, or is that something Go does?

Btw exiting the Android app (that’s with calling rest/shutdown) gives “Connection to phone closed: unexpected EOF” on the connected node.

I made an android target for build.sh here. Does that look good to you? (I’ll wait for a release before doing a merge request, in case I did anything wrong).

Also, did you see me previous question about global discovery?

Okay I did some digging around about the dns problem:

  • Go reads /etc/resolv.conf in ./pkg/net/dnsconfig_unix.go

  • we can get the dns from shell with getprop net.dns1, but there seems to be no shell command on Android to resolve a host

  • I didn’t find a way to supply our own dns in Go, but maybe go-dns-resolver or godns might do?

Right, so there were a few changes in v0.8.7 to the logging infrastructure. One result of that is that warnings that were previously only shown on the console are now also shown in the GUI. That’s probably the cause for the new DNS warning. The Go DNS resolver does read /etc/resolv.conf, yes. Does this not exist on Android? That will mean no DNS, then…

Edit: If you build the binary on Linux, or perhaps even on Android itself, does the DNS resolver work?

Looking at the android build target, that’s fine by me but I wonder if it’s sufficient and generally useful? I.e. if I download just syncthing and run “./build android”, I don’t actually get something I can run on android, right?

Yeah, this is what happens when a node “disappears”. https://github.com/calmh/syncthing/issues/122 is relevant.

Nope, /etc/resolv.conf does not exist on Android. I looked up some workarounds there, and hoped you might have more insight into using those.

As I said, the filename is hardcoded in /pkg/net/dnsconfig_unix.go (as there is no real way to build Go for Android), and building on another platform won’t change that.

No you don’t get installable apks from that, but I use this target from my own build script. I could use build.sh all, but that would mean building unneeded stuff and unpacking the .tar.gz files, which might be complicated.

Right, looks like DNS won’t work on Android from Go right now at least. Might be worth filing an issue on Go for this, could be that it’s simple to fix. The libraries you linked to are for implementing your own DNS resolver, which would be some amount of work and would not integrate with the existing resolver. Currently though, DNS is only used to look up the global announce server. You could work around that by hardcoding the IP (I’ll let you know if I plan on changing it…).

For building, you could also GOOS=linux GOARCH=386 ./build.sh ; mv syncthing syncthing.x86 etc - that way you get a binary for your platform and can utilize the existing build steps (as they change, if they do). I’m not sure I want to include a build step for something that doesn’t work out of the box.

RIght, I could probably hardcode the ip into the syncthing source (which means maintaining a fork again), maybe I’ll do that if there’s no other way.

I didn’t think about building like that, it’s actually easier and I can change stuff myself. I’ll change it to work that way.

Hello Nutomic, I wanted to thank you for the good work you are doing to bring this to android. Will this port be opensource as well? Please consider it as I would love to see this tool be included into https://f-droid.org.

Thanks!

It is open source (github).

I’m not sure how f-droid handles native libraries, especially as this one is not officially supported by the ndk. I’ll look into that at some point (but I also wouldn’t mind if someone else submitted it).

Just set it in the config?

You’re right, that works :smiley:

I was sure it would still try to open the file, but it seems smart enough not to.

So all we need now is fix the permissions, and we’ve finished porting.

Are there logs or crash info dumped somewhere?

No, you’ll have to use logcat to record them. Here’s some info

Is there a way to start syncthing in android by specifying STTRACE debug options?

Only via shell at this point. But it would be possible to add a preference for STTRACE, feel free to open an issue for that :wink: