I'm building a PhoneGap app which needs to play AAC audio. It works well using the native WebView, but I would like to use Crosswalk on a build targeting APIs 16-20 because some CSS features in my app do not work at all on Android 4.x.
When I make a copy of the project to add Crosswalk Lite, I can see that the app works except for the <audio> element pointing to a AAC file. This is because Crosswalk does not ship with proprietary codecs by default.
The linked page says:
To build Crosswalk with these codecs, a developer must run the build with the “must accept a EULA” switch turned on:
$ xwalk/gyp_xwalk -Dmediacodecs_EULA=1Then build Crosswalk. The ffmpegsumo.dll or libffmpegsumo.so in the build output directory will contain the proprietary codecs.
Refer to Crosswalk Build Instruction for more details.
However, I am adding Crosswalk using the suggested plug-in, thus I get pre-built libraries without proprietary codecs:
phonegap plugin add cordova-plugin-crosswalk-webview --variable XWALK_MODE="lite" --save
How can I integrate proprietary codecs in the Cordova Crosswalk plug-in?
I managed to understand the (convoluted) process of building everything. This answer deals with the process of compiling a custom build of the full Crosswalk (not the lite version).
Actually, I decided to finally use the standard build and replace AAC audio with MP3s, but I thought this answer could be useful for future reference.
Environment
I compiled Crosswalk in a Ubuntu 16.04 Docker container to avoid "polluting" my system and to ensure I had the right Linux version. The standard image is pretty barebones so I installed some dependencies. I also set up a shared folder to access the compiled files:
Finally, it is necessary to add the multiverse repositories:
Requirements
Install the
depot_toolsas outlined in the documentation:Initialize a working directory with:
Then edit the config file with
nano .gclientand add the following line:Save the file.
Fetching the source
Attempt a first sync with:
This command will fail but it's OK. The instructions say:
Adjust the
install-build-deps.shfile and then run it:Run
gclient syncagain and wait until it finishes correctly.Building
By inspecting the files
src/xwalk/build/common.gypiandsrc/tools/mb/mb_config.pyl, we can see that we need to addffmpeg_branding="Chrome"in the build arguments.To prevent an error later on, install the development package related to libnotify:
Move to the
srcdirectory and open the configuration:Ensure the content is as follows:
The parameters
use_sysroot = falseprevents yet another error. When saving the file, you should see something like this:Issue
cd ..and rungclient syncagain.Finally, to build the core library do:
This will build the library for ARM, producing an AAR file located at:
Copy this file in a safe place.
Building for x86
Get back to the args with:
Add the following line:
Save the file, run
gclient syncagain and then repeat theninjacommand. Make a copy of the new AAR file which now contains the x86 libraries.Using the AAR files
The standard Cordova Crosswalk plug-in uses a single AAR file with libraries for both platforms. This message by Raphael Kubo da Costa suggests how to produce this single archive:
Finally, to use the custom built AAR file in the Cordova plug-in, see How to change the Crosswalk version used by the Cordova Crosswalk Webview plugin.