Create an Android App using the mTools framework What you need to know before you begin



Download 29.88 Kb.
Date19.06.2017
Size29.88 Kb.
#21052

Create an Android App using the mTools framework

What you need to know before you begin


To use the mTools Framework to build your Android app you need to have someone on your team with competent IT skills. An understanding of coding principles will be of benefit in creating your app.

Installing the SDK Bundle


Because the Software Development Kit (SDK) changes from time to time, (in some cases major changes) this manual won’t go into how to download and setup the SDK for building this app but will link you directly to the Android Developers site where you can get all of the information

http://developer.android.com/sdk/installing/bundle.html



Known Issues: An issue may arise with X64 based operating systems where the Java Runtime environment may not be recognised by the installer and will constantly ask you to download the Java SDK. If you believe that you have installed the Java SDK properly you may have an issue with the environment variable. To fix this issue go to your system properties and click the advanced tab, then click the Environment Variables button. Create a new User Variable and call it JAVA_HOME and the variable value would be something like C:\Program Files\Java\jre7 which is the location of the Java runtime environment.

Open Eclipse


Once you have installed the SDK you will need to run the program called eclipse which manages the Android SDK environment and is usually found in the x:\...\adt-bundle-windows-x86_64\eclipse\ folder. x:\...\ being where you installed the SDK to.

When you run Eclipse for the first time you will be asked to setup a workspace folder. This is the folder where you will have ALL of your projects stored. It is a good idea the store each project in a separate folder in the workspace folder and you can make this folder anywhere on your computer.


Update the SDK


Once you have installed the SDK bundle make sure to update the SDK manager by going to Window -> Android SDK Manager. On first install it’s a good idea to update everything so that you have no problems working with different versions of the Android operating systems. Once updated you may be asked to restart the program or even reboot the system.

Setting up the Project code


Once you have shut down Eclipse you will want to extract the zip file into a folder in the workspace folder. Make sure you don’t bury it in a folder within a folder as this will cause a lot of errors when trying to compile the App later on.

Importing the Project Files


  1. Run Eclipse

  2. Go to New Project


Figure 1 – Start a New Project

  1. Select Android -> Android Project from Existing Code


Figure 2 – Importing the Android application project from existing code

  1. Press Next.

  2. You will see the Import Projects settings


Figure 3 – The Import Projects settings

  1. Click in the Root Directory and select the Browse button to select the folder you unpacked the zip file to.


Figure 4 – Selecting the folder you unpacked the zip file to.

  1. Click Project to Import button and select Finish.


Figure 5 – Importing the Project

  1. Once the project has been successfully imported you will come back to the main screen. It might look something like the screen below.


Figure 6 – The main Eclipse screen

  1. To see the project structure you need to open the Navigator. To do this, go to Windows -> Show View -> Navigator shown below in Figure 7.


Figure 7 – The Project shown in the navigator screen

NOTE: AFTER DOING ANYTHING AS LAID OUT IN THESE NOTES YOU SHOULD ALWAYS AFTER COMPLETING THEM GO TO PROJECT -> CLEAN AND REFRESH THE CONTENT OF THE PROJECT TO ENSURE THAT ANY BUILDS ARE USING THE CORRECT FILES AS SOME MAY BE CACHED BY THE SYSTEM.

Renaming the Project


The next thing you will want to do is rename the project from the previous name to the name of the new project.

  1. In the far left Navigator panel, right click and go rename or press F2 and rename the project. In this case I have used Levelling Secrets.


Figure 8 – Renaming the project

  1. Press Enter and the project will update the information.

  2. Next open the AndroidManifest.xml file and edit the package details


Figure 9 - Renaming the Manifest file

  1. In the package rename com.app.xxxxxxx, xxxxxxx being the current project build to com.app.YOURNEWPROJECT don’t use spaces

  2. Change the version code to the current version, 1 being the 1st build. Also change the version number depending on what version this is that has been released to the Play Store. Then click Save or CTRL + S.

  3. The Launch Configuration Update will appear when saved and ask you to update the Launch Configuration. Click Yes


Figure 10 – The Launch Configuration Update

  1. Next you will have to search the whole project for com.app.xxxxxxxxxxxxxx and replace it with com.app.YOURNEWPROJECT. You find that the files that need changing are in src/com/app/ and sub folders. They will look like Figure 11 below.


Figure 11 – The code that needs changing.

  1. Make the change and save all files.


Changing the text on the front menu


To change the front menu carousel text you will have to edit the strings.xml file in the res/values folder.

DO NOT COPY AND PASTE OUT OF A WORD DOCUMENT INTO THIS FILE, IT WILL CAUSE A VARIETY OF ERRORS.

  1. Click on the Hello (String) the Values will appear on the right as shown in Figure 12 below.


Figure 12 – Changing the variables

  1. Change anything that refers to the old project to the new project. Where spaces are used use spaces, where they aren’t please don’t use a space.

  2. The main menu items are changed from main_menu_item (String Array) the 1st refers to the 1st menu tile and so on.

  3. When finished save and close the xml file.

Changing the front menu images


Unless you are changing the file names of the front menu images all that you have to do is upload the new images into res-> drawable and replace menu_beginners, menu_intermediate and menu_advanced with the new images.

  1. If you wish to change the files you will have to go to src -> com -> app -> adapter -> MainMenuGalleryAdapter.java and open the file.

  2. Find the line
    public final static Integer[] mImageIds = { R.drawable.menu_beginners, R.drawable.menu_intermediate, R.drawable.menu_advanced }; Figure 13 below.


Figure 13 – Changing the menu file names.

  1. Rename menu_beginners, menu_intermediate and menu advanced to the new file names. DO NOT add the JPG file extension as this is handled elsewhere, you just need to change the file name.

  2. Save the file.

Updating the Database


The database that contains all of the information for the app is stored in the folder assets and is called Database.

The database is in SQLite 3 Format and can be opened and edited by using a program such as SQLite browser which can be found at http://sqlitebrowser.sourceforge.net

There are 3 Tables in the database the 1st one LevelThumbnails, holds all of the thumbnails for the 2nd level menus in the application.

Level Thumbnails Table


The level thumbnails table holds the 2nd level menu information for the application. The database fields are:

  • Desc – the text you want to appear in the menu

  • ID – This must following an ascending number sequence as it’s the unique ID number for the record

  • Level ID – this refers to which menu the information will appear in. 1 = Beginner, 2 = Intermediate, 3 = advanced.

  • FolderName refers to the folder where the image referenced in the next field can be found.

  • ImageName – This is the EXACT name of the image that you want to use for the menu item.

Topic Table


The Topic table is all of the content for the app. The table is laid out as follows:

  • ID – This must be a unique ID number and should follow the number above it.

  • LevelThumbnailsID – This refers to which menu item this information falls into. The smallest ID number will be shown first.

  • folderName – This refers to the folder name that the image in FileName will be located.

  • FileName – The EXACT name of the file that will appear at the top of the screen that corresponds to the information in desc.

  • FileType – This is to tell the application if it is dealing with an IMAGE or VIDEO. Text should be all in uppercase.

  • desc – this is the information that will be displayed on the screen under the image listed in FileName.

NOTE: FileName must be exactly as it is named in the file system, getting this wrong may result in the app crashing. This also applies for the folderName, the correct use of upper and lowercase is vitally important for the app to work.

With the desc field DO NOT copy and paste it out of MSWord or any other word processor that might carry over any unusual characters as this may cause the app to crash. The best method is to copy and paste it into a plain text file, such as notepad and then copy out from there if you don’t want to type it all in.


Updating Images


Updating the images in your project is simple and straightforward. You can do it in either one of two ways.

  1. Close Eclipse and update the files in the assets -> first, second or third folder through Windows explorer as you would normally do any other file. Do this if you know that you don’t have any file name problems that may occur, Eclipse will let you know if there are problems when you load the project.

  2. The easier and error checked way is to have Eclipse open and drag from Windows Explorer into the appropriate folder. When you do this a dialog box will appear as shown in Figure 14 below.


Figure 14 – The Drag and Drop File Operation box.

  1. Always copy the files into the project and don’t link them as it will cause referencing problems when you try to build the project later on.

  2. Once you have done that, Clean the project to update all files and references.


Exporting the Application Package


You can export the Application as a packaged file in 2 different ways. Signed and Unsigned. You would usually use an unsigned package to test on other phones before submitting to the Google Play store. The signed version will be needed to submit to the Google Play Store.

Exporting an Unsigned Package


To Export an unsigned package open Eclipse and have the Navigator panel open.

  1. Right Click on the package name and select Android Tools -> Export Unsigned Application Package. See Figure 15 below


Figure 15 – Exporting the Unsigned Application Package.

  1. The Save Dialog box will appear asking you the filename and where you’d like to save the file. Choose the location and press save. Figure 16.


Figure 16 – Saving the Unsigned File.

  1. Once Eclipse has compiled the program a dialog box will appear. Figure 17 below.


Figure 17 – The Unsigned application dialog box

  1. You can now send this to any Android phone to be loaded and tested out.

  2. To do this you can either email it to anyone’s Gmail account that they can check on their phone and they can click on the attachment and it will install on their device or they can use a File Browser program on their phone and install it by running it from that program.

Exporting the Signed Application File – creating a new key


To Export a signed package open Eclipse and have the Navigator panel open.

  1. Right Click on the package name and select Android Tools -> Export Signed Application Package. See Figure 18 below


Figure 18 – Exporting the Signed Application Package.

  1. The Project Checks Wizard will then run. You will be asked to select a project, Figure 19. If a project isn’t listed then Click Browse and Select the project name you want to use, Figure 20, and press Ok. Then Click Next.





Figure 19 – Project Checks

Figure 20 – Selecting a project



  1. You will then be asked to select a keystore, Figure 21. You will be asked to make a new key, Figure 22 Creating a new Keystore. Select the password and press next.





    Figure 21 – Selecting a Keystore

    Figure 22 – Creating a new Keystore

  2. You will then be asked to fill in the information about the certificate and the Application, Figure 23. The settings are fairly straight forward:

    1. Alias is the name of the Application.

    2. Password, use a strong password, upper, lower case, numbers and symbols can be used.

    3. Validity is the lifetime of the app in years, anywhere from 1 to 100.

    4. The rest of the information is the distributor’s information; as long as the First and Last Name fields are filled in any other fields can be left blank.

    5. The country code for Australia is 61.

Click next to continue.


Figure 23 – Key Creation

  1. Then select the destination on your computer where you’d like to save the file and press finish. Figure 24.


Figure 24 – Saving the file

Exporting the Signed Application File – Using an Existing Key


To Export a signed package open Eclipse and have the Navigator panel open.

  1. Right Click on the package name and select Android Tools -> Export Signed Application Package. See Figure 25 below


Figure 25 – Exporting the Signed Application Package.

  1. The Project Checks Wizard will then run. You will be asked to select a project, Figure 26. If a project isn’t listed then Click Browse and Select the project name you want to use, Figure 27, and press Ok. Then Click Next.





    Figure 26 – Project Checks

    Figure 27 – Selecting a project

  2. You will then be asked to select a keystore, Figure 28. Browse and select the key. Then enter the password of the key and press Next.


Figure 29 – Using the existing key

  1. The key information will appear and ask you for the destination save file. Choose the location and file name and then press finish. Figure 30.



Figure 30 – Exporting the Application using a saved key.

Download 29.88 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2022
send message

    Main page