Actually, we can build GeckoView on WSL and VMs. but since Android Studio runs under Windows, not WSL, if using WSL, you cannot use Android Studio to debug GeckoView. We have limited support to build GV on the mozilla-build environment.
Same as Linux. But,
- You cannot use Android Studio to debug GV
- WSL doesn't support USB. So
./mach install
or./mach run
doesn't work. But this has workaround (see using ADB). - WSL2 (comming in Windows 10 20H1)'s filesystem is fast, but if using NTFS filesystem's directory, it will be too slow (microsoft/WSL#4197).
- WSL2 may have limited USB support, but I don't know about
adb
(microsoft/WSL#2195)
- Although WSL has no USB support, adb command on WSL can communicate to another adb process on Windows native. Before using adb command on WSL or running
./mach install
, we should run adb command on windows version. (ex.~/.mozbuild/android-sdk-windows/platform-tools/adb device
).
- See Using ADB with WSL2. platform-tools path in our
mach
environment is$env:USERPROFILE + "\.mozbuild\android-sdk-windows\platform-tools"
Yes, you can use Linux image on your VMs, but
- VMWare and VirtualBox support USB.
- Hyper-V doesn't support USB. So
adb
command doesn't work to install APK. Also, WSL2 (coming in Windows 10 20H1) might not support non-Hyper-V VMs such as VMWare and VirtualBox (microsoft/WSL#4112 and etc). If you want to enable/use WSL2 for some situations, we may not be able to choose VMWare and etc.
This is a sample of mozconfig
.
mk_add_options AUTOCLOBBER=1
ac_add_options --enable-application=mobile/android
ac_add_options --enable-debug
ac_add_options --enable-tests
ac_add_options --target=x86_64
ac_add_options --enable-artifact-builds
This is a sample of mozconfig
.
mk_add_options AUTOCLOBBER=1
ac_add_options --enable-application=mobile/android
ac_add_options --enable-debug
ac_add_options --enable-debug-symbols
ac_add_options --enable-optimize
ac_add_options --enable-tests
ac_add_options --target=x86_64
# Since our lld isn't built with zlib, so some cpu type requires --enable-linker to use bfd or gold.
# ac_add_options --enable-linker=bfd
# Host compiler has to use clang-cl.
HOST_CC=clang-cl.exe
HOST_CXX=clang-cl.exe
NOTES: you have to use same drive for source path and NDK path. If different drive, generating moz.build phase is failed. It means that Gecko's source code has to be on C: drive. (bug 1600541)
Now, gradle script of GV requires some environment variables from mozilla-build setting. So if you want to use Android Studio, you have to set the following environment variables.
- Set
MOZILLABUILD
environment variable (C:\mozilla-build\
as default install path. You must set\
as tail) to detect mozilla-build.
You have to apply the patch from https://raw.githubusercontent.com/makotokato/gecko-mq/master/windows-ndk-build.
This Python bug (NamedTemporaryFile
doesn't use share mode. https://bugs.python.org/issue14243 etc and https://developercommunity.visualstudio.com/idea/880630/support-file-share-delete-for-open-and-sopen.html for VC++).
- If gradle runs as deamon mode,
./mach build
may not be finished. So it is better to addorg.gradle.daemon=false
line to$HOME/.gradle/gradle.properties
to avoid this. - When re-building GeckoView, some environments will be failure during gradle phase. If so, you have to modify
"${mozillabuild}/python3/python3.exe"
to"python3.exe"
in https://searchfox.org/mozilla-central/source/settings.gradle#14. - gradle task will be failed due to stack overflow. If occured, you have to upgrade build tools to 33.0.1 (Modify android-packages.txt and android-sdk.configure.
FYI I think the JDK step is no longer needed anymore :)