How to build syncthing for Android (Android Studio in Windows)


(Boris Brakhin) #1

Hi ! I don’t understand how to build syncthing for Android (Android Studio in Windows) according given instructions at https://github.com/syncthing/syncthing-android :

Building on Windows To build the Syncthing app on Windows we need to have cygwin installed.

From a cygwin shell in the project directory, build Syncthing using ./syncthing/build-syncthing.bash

Lastly, use ./gradlew assembleDebug in the project directory to compile the APK, or use Android Studio to build/deploy the APK.

When I try to buid it in Android Studio i get such error :

Error:Please run ./build-syncthing.bash via cygwin/MinGW manually

Please explain me how I can buld synching for Android Studio in details.

Thanks a lot.


(Catfriend1) #2

I also got this problem and ,et did not find a solution. Installing github desktop containing a bash under windows is a starting stick but no solution. Try installing Virtualbox and setup e.g. debian build environment there. That is much easier. You can then share your code dirrctory via samba to windows and use android studio remotely on the files.


(Audrius Butkevicius) #3

It’s a convoluted process. You need to run the bash script manually once, and you need to make sure you have windows python on the path rather than cygwin python.


(Boris Brakhin) #4

What for I need pyton here ? I have deal with android


(Boris Brakhin) #5

Are there some clear ways else without dancing with a tambourine ? Мy brain is boiling …


(Audrius Butkevicius) #6

You need python to compile the android NDK, as build scripts for that are written in python.


(Boris Brakhin) #7

I have installed Python 3.7 for Windows, set Path environment but there were some errors :

w:\Syncthing\syncthing-android>W:\cygwin64\bin\bash.exe./syncthing/build-syncthing.bash ./syncthing/build-syncthing.bash: line 2: $’\r’: command not found : invalid optiond-syncthing.bash: line 3: set: - set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [–] [arg …] ./syncthing/build-syncthing.bash: line 4: $’\r’: command not found ./syncthing/build-syncthing.bash: line 29: syntax error near unexpected token $** **'do\r''** **./syncthing/build-syncthing.bash: line 29:for ANDROID_ARCH in arm x86 arm64; d

What did I do wrong ?


(Audrius Butkevicius) #8

It seems you checkout converted line endings to windows, you nees to check that file out with linux line endings. Or convert it for the one-off build.


(Boris Brakhin) #9

Ok, but there are become such errors :

./syncthing/build-syncthing_.bash: line 10: dirname: command not found

./syncthing/build-syncthing_.bash: line 12: grep: command not found

./syncthing/build-syncthing_.bash: line 12: awk: command not found

And I used bush.exe under the Windows. What is wrong ?


(Audrius Butkevicius) #10

Not sure what bush.exe is, but you need aa fully fledged bash shell, perhaps try installing cygwin.


(Boris Brakhin) #11

I have used bash.exe from a cygwin bin directory. How to run this bash-script under cygwin terminal (c:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -) ? What command I must use ? Please help !!!


(Boris Brakhin) #12

Alleluia! I managed to start the script, but there was a snag using Python.

I believe that the cygwin does not see the python installed on the computer.

How to correctly configure its use?

$ ./test_5 remote: Counting objects: 107, done. remote: Compressing objects: 100% (20/20), done. remote: Total 107 (delta 84), reused 92 (delta 83), pack-reused 4 Obtaining the objects: 100% (107/107), 62.03 KiB | 4.13 MiB / s, it’s ready. Definition of changes: 100% (84/84), completed with 69 local objects. From https://github.com/syncthing/syncthing 9f254df0…9f87fd1f master -> origin / master 21035b0c…6b82538e release -> origin / release

  • [new label] v0.14.49-rc.4 -> v0.14.49-rc.4 Starting build for arm

Can not build NDK with Python provided by an unsupported system: CYGWIN_NT-6.3 Please make sure that python is available on the Internet (Windows / Linux / Darwin)


(Audrius Butkevicius) #13

You need tomove cygwin python out of the way by renaming /usr/bin/python to something else temporarily.


(Boris Brakhin) #14

there is no such path in my cygwin enveronment.

$ cd /usr/bin/python -bash: cd: /usr/bin/python: Not a directory

But there are directories :

/usr/lib/python2.6

/usr/lib/python2.7

/usr/lib/python3.6

What other solutions are possible ?


(Audrius Butkevicius) #15

Do “which python” and rename that not to be something that is provided by cygwin.


(Boris Brakhin) #16

Ok, we have :

$ which python

/usr/bin/python

I have deinstalled the Python from the Windows system, but the error does not disappear :

Cannot build NDK with Python provided by an unsupported system: CYGWIN_NT-6.3 Please make sure that python that is available on the path is native to your host platform (Windows/Linux/Darwin)


(Audrius Butkevicius) #17

You don’t needto uninstall python from windows, you need to make sure that we do not pick up the cygwin python, but pick up windows python instead, which I’ve explained how to do.


(Boris Brakhin) #18

ok, I did so :

  1. $ mv /usr/bin/python /usr/bin/python_

  2. I have installed Python 3.7 on my Windows system, add it’s folder to %PATH

And now I have :

$ which python

/cygdrive/f/Users/Boris/AppData/Local/Programs/Python/Python37/python

So we have some another thing :

$ ./test_5

Starting build for arm

File “string”, line 1

import platform; print platform.system()
                              ^

SyntaxError: invalid syntax Cannot build NDK with Python provided by an unsupported system: Please make sure that python that is available on the path is native to your host platform (Windows/Linux/Darwin)

Are there neсessary to use some old versions of Python, not 3.7 ?


(Audrius Butkevicius) #19

You need python 2


(Boris Brakhin) #20

I installed python 2.7 So, we have the following :

Boris@Main ~ $ cd /cygdrive/w/Android_Projects

Boris@Main /cygdrive/w/Android_Projects $ ./test_5

Starting build for arm

Building standalone NDK

HOST_OS=cygwin

HOST_EXE=.exe

HOST_ARCH=x86_64

HOST_TAG=windows-x86_64

HOST_NUM_CPUS=8

BUILD_NUM_CPUS=16

ERROR: Failed to create toolchain.

What is the way to fix the error?