Moodle Mobile Building the app for Android
- Moodle Mobile Customization
- Setting up your development environment for Moodle Mobile 2
- Moodle Mobile development using Chrome or Chromium
- Moodle Mobile Plugins Development
- Moodle Mobile Themes
- Moodle Mobile Developing a plugin tutorial
- Moodle Mobile Developing a plugin tutorial part 2
- Moodle Mobile Remote add-ons
- Moodle Desktop
- Moodle Mobile FAQ
- Moodle Mobile End To End Testing
Remember that you can also build the app using an external system called Phonegap Build, see Moodle_Mobile_Customization#Building
|Warning: This page is no longer in use. The information contained on the page should NOT be seen as relevant or reliable.|
Installing the Android SDK
Building the app for Android is easy once you have successfully installed all the required software.
Since we are using Phonegap as framework for creating the app, the documentation you have to follow is just in this link plus additional steps for installing plugins: http://docs.phonegap.com/en/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android
Notice the following:
- You must read carefully the document and not use white spaces in some names and ids. (It's adviced in the document)
- You can optionally not use Eclipse and instead use adb command line or cordova script tools
- In the "4. Setup New Project" The package_name is the app id that your app will have in the Android Market (Play Store), so it must be unique. If you are going to develop for the official app you have to use com.moodle.moodlemobile, if you are going to develop a custom app, you will have to add your own unique id.
- If you want to connect a Device to your Eclipse and you are using Windows, you must install the Android USB Drivers, see http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver
Add the Mobile app HTML5 files
Go to your project folder, assets/www and add just there all the files from https://github.com/moodlehq/moodlemobile
Installing additional Phonegap plugins
The Android app requires two additional Phonegap plugins to be installed:
For opening files according their mime type: https://github.com/phonegap/phonegap-plugins/tree/DEPRECATED/Android/WebIntent
For installing the plugin follow this instructions: https://github.com/phonegap/phonegap-plugins/blob/DEPRECATED/Android/WebIntent/README.md#adding-the-plugin-to-your-project
Build, compile, test your app
We suggest you to use Eclipse tools for testing, deploying the app
In any case, you can allways use the Cordova command line tools, see: http://docs.phonegap.com/en/2.5.0/guide_command-line_index.md.html#Command-Line%20Usage
The cli tools are in your project folder, directory cordova
Signing your app
The Android system requires that all installed applications be digitally signed with a certificate whose private key is held by the application's developer. The Android system uses the certificate as a means of identifying the author of an application and establishing trust relationships between applications. The certificate is not used to control which applications the user can install. The certificate does not need to be signed by a certificate authority: it is perfectly allowable, and typical, for Android applications to use self-signed certificates. See: http://developer.android.com/tools/publishing/app-signing.html
And also for Eclipse: http://developer.android.com/tools/publishing/app-signing.html#ExportWizard
Uploading your custom app to the Google Play Store
Build the official Moodle Mobile app on a Mac
- Install SDK
- http://developer.android.com/sdk/index.html#download - it will install Eclipse / ADT plugin / Android SDK
- Add the SDK tools/platform-tools folders to your PATH
- Install NodeJs
- Install cordova-cli
- sudo npm install -g cordova - it will install cordova. Note that on my machine I have some warnings about the android bootstrap process being skipped but all the following steps seem to work ok anyway...
- Create a Android project
- /usr/local/lib/node_modules/cordova/bin/cordova create ~/Apps/moodlemobile_android_cordova com.moodle.moodlemobile MoodleMobileBeta
- cd ~/Apps/moodlemobile_android_cordova
- sudo /usr/local/lib/node_modules/cordova/bin/cordova platform add android
- sudo /usr/local/lib/node_modules/cordova/bin/cordova build - not necessary, just check the build works.
- In Finder change the permission on ~/Apps/moodlemobile_android_cordova folder: Read + Write to everyone
- Open eclipse, add a new Android project from existing source pointing to /Users/jerome/Apps/moodlemobile_android_cordova/platforms/android. Test you can build the default Cordova app on your phone.
- Copy the Moodle mobile app into assests/www folder
- git clone git://github.com/moodlehq/moodlemobile.git ./moodlemobile
- mv platforms/android/assets/www/ platforms/android/assets/www_old/
- mv ./moodlemobile/ platforms/android/assets/www/
- cp platforms/android/assets/www_old/cordova.js platforms/android/assets/www/
- Add the cordova plugins
- git clone git://github.com/alunny/ChildBrowser.git ./ChildBrowser - we are now going to install cordova compatible plugin with the plugin install command line.
- sudo /usr/local/lib/node_modules/cordova/bin/cordova plugin add ChildBrowser/
- Add manually phonegap plugins
- git clone git://github.com/phonegap/phonegap-plugins.git ./phonegap-plugins
- cp phonegap-plugins/Android/WebIntent/webintent.js platforms/android/assets/www/
- mkdir platforms/android/src/com/borismus
- mkdir platforms/android/src/com/borismus/webintent
- cp phonegap-plugins/Android/WebIntent/WebIntent.java platforms/android/src/com/borismus/webintent
- In Eclipse, add a package to src folder. The value should be com.borismus.webintent
- In your res/xml/config.xml file, add <plugin name="WebIntent" value="com.borismus.webintent.WebIntent" /> where you define the plugins.
- copy the icons
- cp platforms/android/assets/www/img/icon/android/icon-36-ldpi.png platforms/android/res/drawable-ldpi/icon.png
- cp platforms/android/assets/www/img/icon/android/icon-48-mdpi.png platforms/android/res/drawable-mdpi/icon.png
- cp platforms/android/assets/www/img/icon/android/icon-72-hdpi.png platforms/android/res/drawable-hdpi/icon.png
- cp platforms/android/assets/www/img/icon/android/icon-96-xhdpi.png platforms/android/res/drawable-xhdpi/icon.png
- Edit the AndroidManifest.xml
- increment android:versionCode="359" android:versionName="22.214.171.124"
- keep the following permissions: INTERNET, RECORD_AUDIO, RECORD_VIDEO, READ_CONTACTS, WRITE_CONTACTS, WRITE_EXTERNAL_STORAGE, ACCESS_NETWORK_STATE
- android:debuggable="false" - this reduce the apk size file from 7M to less than 1M!
- Edit res/values/strings.xml and change the app name for "Moodle mobile" - this app name appears on your Android phone dashboard. The Google Play Store app name comes from the Google Play publisher console.
- Clean up the app to reduce apk file size
- rm -rf platforms/android/assets/www_old/
- rm -rf platforms/android/assets/www/img/splash
- rm -rf platforms/android/assets/www/img/icon
- In Eclispe, build and test the app.
- In Eclipse, File > Export the app with the Moodle HQ Google Play keystore. Then upload the APK to Google Play.
- if you previously installed a different platform then you'll get an error when adding the cordova plugin. It's advised to install both platforms at the same time. Then add the cordova plugin(s), then copy the app content into www. Don't forget cordova.js and plugin js/files. Then you can manually install phonegap plugins.