Building WordPress for Android
WordPress clients are available for many devices, but since I’m an Android fan I get to use WordPress for Android.
Yesterday, I came across a bug report outside of the developer ecosystem, managed to reproduce the bug using the release version, and, decided to write and submit a patch to fix the bug.
The main WordPress for Android repository is over at GitHub. But as it turns out…
…one does not simply build WordPress for Android.
A very low number of contributors, the low amount of open pull requests and the staggering amount of issues shows that few have been able to actually contribute code.
There’s no room for IDEs, fancy build- and dependency- management systems in my workflow; I don’t have Eclipse, Android Studio or any other monster. I use the standard command line tools that come with the Android SDK. For building, the default and standard – ant
. And while the readme does actually say that building using ant
is possible, it actually isn’t at all straighforward.
Gradle? That didn’t work either, actually. One of the several dozen build tasks failed and since I don’t know gradle
at all I decided to create a simple bash script to get a semi-decent build that works together.
The script may or may not work for you, and depends on how bad you want to build WordPress for Android. I’m assuming a working tree close to 6a2f7dd1b3c44aac7b3efa170506b7e2e835702b, and if you’re reading this later, the developer leads may actually have gotten a decent build process together and actually allow mere mortals to compile the app (let’s hope).
Here’s a complete Bash script to get a build going without any fancy-pants build systems or IDEs (at least for me):
The build file above is riddled with things that need to be done before a sort-of build can be made. Why so hard and complicated? It just isn’t meant to be built, it seems.
WordPress-Android lead developers: fix your build scripts so more people can contribute!
Hey soulseekah, you’re right, we need to update the README. We have this handbook to help people contribute: https://make.wordpress.org/mobile/handbook/pathways/android/tutorials-guides/
What was your issue with gradle ? It should do everything for you, generate files and fetch dependencies. Say hello on IRC: #WordPress-Mobile (freenode)
Maxime,
Thanks for pointing out the Developer Handbook, it does contain useful information.
Never used Gradle before, compiled latest 1.9 from sources, building failed with error about requiring 1.8.
Compiled 1.8 from sources – building failed on
:compileBetagroupAidl
task:failed to find Build Tools revision 19.0.0
, after I updated, I had issues with:#WordPress-Android
on IRC is empty 🙁I decided to screw everything and write a build script for good old ant, old school style. There were obvious issues with not getting my dependencies from maven but from github, so I had to create quick and dirty patches for some of the cases; and I couldn’t figure out how to get BuildConfig to include my fields without having to fork the ant task, and but eventually I managed to get a running version up and submit a patch https://github.com/wordpress-mobile/WordPress-Android/pull/515. That’s all I wanted to do, it was quite a journey 🙂 I don’t like to have to compile several build tools and toolchains in order to build something that should be built with vanilla SDK tools, but that’s just me 😀 I’d rather “bash” out a dirty patch.
I could try opening a discussion on making ant work out of the box, if you want. I like ant.
Hi,
Now, i built Android-wordpress successfully. But only the problem is- i am not being able to add my wordpress site.
Plz, help me out..!!
Please make sure your WordPress site has the XML-RPC API active for the Android application to work.