WordPress for Android
If you're just looking to install WordPress for Android, you can find it on Google Play. If you're a developer wanting to contribute, read on.
- Make sure you've installed JDK 8 and Android Studio, a Standard Setup would work.
- Clone this GitHub repository.
- In Android Studio open the project from the local repository as a Gradle project (this will auto-generate
local.propertieswith the SDK location).
- Make sure you have an emulation device setup in AVD Manager (Tools → Android → AVD Manager).
- To use WordPress.com features (login to WordPress.com, access Reader and Stats, etc) you need a WordPress.com OAuth2 ID and secret. Please read the OAuth2 Authentication section.
Once installed, you can now build, install and test the project from the command line:
$ ./gradlew assembleVanillaDebug # assemble the debug .apk $ ./gradlew installVanillaDebug # install the debug .apk if you have an # emulator or an Android device connected $ ./gradlew :WordPress:testVanillaDebugUnitTest # assemble, install and run unit tests $ ./gradlew :WordPress:connectedVanillaDebugAndroidTest # assemble, install and run Android tests
. ├── libs # dependencies used to build debug variants ├── tools # script collection ├── gradle.properties # properties imported by the build script ├── WordPress │ |-- build.gradle # main build script │ └── src │ ├── androidTest # Android test assets, resources and code │ ├── test # Unit tests │ ├── main │ │ ├── assets # main project assets │ │ ├── java # main project java code │ │ └── res # main project resources │ ├── debug # debug variant │ └── wasabi # wasabi variant specific resources and manifest
In order to use WordPress.com functions you will need a client ID and a client secret key. These details will be used to authenticate your application and verify that the API calls being made are valid. You can create an application or view details for your existing applications with our WordPress.com applications manager.
When creating your application, you should select "Native client" for the application type. The applications manager currently requires a "redirect URL", but this isn't used for mobile apps. Just use "https://localhost".
Once you've created your application in the applications manager, you'll
need to edit the
./gradle.properties file and change the
WP.OAUTH.APP_SECRET fields. Then you can compile and
run the app on a device or an emulator and try to login with a WordPress.com
account. Note that authenticating to WordPress.com via Google is not supported in development builds of the app, only in the official release.
Note that credentials created with our WordPress.com applications manager allow login only and not signup. New
accounts must be created using the official app or on the web. Login is restricted
to the WordPress.com account with which the credentials were created. Also, you will be able to interact with sites of
that same WordPress.com account only. In other words, if the credentials were created with email@example.com, you will only
be able to login with firstname.lastname@example.org and access email@example.com sites. Using another account like firstname.lastname@example.org will cause
Client cannot use "password" grant_type error.
Google Sign-In is only available for WordPress.com accounts through the official app. Contributors can build and run the app without issue, but Google Sign-In will always fail. Google Sign-In requires configuration files which contain client and server information that can't be shared publicly. More documentation and guides can be found on the Google Identity Platform website.
How we work
Need help to build or hack?
Say hello on our Slack channel:
- Q: I can't build/test/package the project because of a
- A: Create a
gradle.propertiesfile in the project root directory with the following:
WordPress for Android is an Open Source project covered by the
GNU General Public License version 2. Note: code
libs/ directory comes from external libraries, which might
be covered by a different license compatible with the GPLv2.