Introduction

If you haven't noticed already, the MaaXBoard Mini supports Android 9 out of box! One thing that developers are probably wondering is how do I go through the process of actually developing my own application and deploying it on the MaaXBoard Mini? Well look no further, I have gone through the process of documenting everything required to get you started with your application development!

 

Version

Date

Version

Revision

26 October 2001Initial Release

 

  1. Required Hardware
  2. Required Development Software
    • Download and Install Android Studio
      • Do a quick google search and it will take you right there
    • Download and install adb platform tools
      • Do a quick google search of "adb platform tools" and you should find them fairly easy. Install them for the OS you are using on your PC.
  3. SD Card Setup
    1. Place your 16GB microSD Card into your PC
    2. Go to http://avnet.me/maaxboard-mini -> Reference Designs tab -> MaaXBoard Mini -> Anrdoid 9 Out of Box Image.
      • Download the Android 9 Out of Box Image for the MaaXBoard Mini
    3. Use a flash program such as Win32DiskImager or Etcher to flash the Android 9 Out of Box Image .img image onto the 16GB microSD Card
  4. Hardware Setup
    1. Connect the MaaXBoard Mini with the MaaXBoard 7in LPC panel.
      • Connect the ribbon cable from the display to J7 on the MaaXBoard Mini
    2. Place the microSD card you just flashed with Android 9.0 out of box image into the microSD slot (J9) on the MaaXBoard Mini
    3. Connect the USB Type A plug to Type A plug cable into USB hub J2 on the MaaXBoard Mini bottom port. Plug the other end of the cable into your PC
    4. Plug the USB Type C Power Supply into J11 USB Type C socket on the MaaXBoard Mini. Plug the other end into the wall.
      • Note: if you are using a different USB Type C cable plugged into your PC, you will encounter power issues when working with the LCD panel. Please us a 3A/5V power supply
    5. The board should now power on
  5. Verify your adb platform tools setup.
    1. Open up command line prompt
    2. Traverse in the command line prompt to the adb tools you setup. Go to the platform-tools directory
    3. In the command line type adb devices
      • It will show your device ID
    4. Type adb shell and a terminal shell will open to your MaaXBoard Mini
    5. You can now run shell commands directly on the MaaXBoard Mini. Lets control some leds!
      • type su - This will give you root privlidges
      • type echo 0 | tee /sys/class/leds/usr_led/brightness - This will turn an led off
      • type - This will turn the other led off
      • type echo 1 | tee /sys/class/leds/usr_led/brightness - This will turn an led on
      • type echo 1 | tee /sys/class/leds/sys_led/brightness - This will turn the other led
    6. Type Exit to exit the shell terminal
    7. You have verified your adb platform tools setup.
  6. Open Android Studio and explore the environment
    1. Create a new project File -> New -> New Project
    2. Select Empty Application -> Next
    3. Make sure the Lanugage is set to Jave and select Finish
    4. You have now created your first project! Lets dig into the layout design and java application portion of creating an app.
    5. Go to Android -> app -> res -> layout -> activity_main.xml
    6. This is where you design the layout of your app. You can drag and drop multiple buttons/tesxt/widgets etc into your application
    7. If you go to the Code portion you will see the .xml code that was created when you dropped your button. You will notice here is where we can rename the button id that our java application will call when a event occurs.
    8. Now go to Android -> app -> java -> com.example.myapplication -> Main activity
    9. Here is where we will write the main java portion of our example application.
  7. Example Addition Application
    1. I have gone through the process of creating a simple addition application we will run on the MaaXBoard Mini.
    2. Open the activity_main.xml, go to the code section. Copy and paste below. You will see how this layout will look on the MaaXBoard Mini by going back to design.
      • <?xml version="1.0" encoding="utf-8"?>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="match_parent">
          <TextView
        android:id="@+id/fstTxt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="100dp"
        android:layout_marginTop="150dp"
        android:text="First Number" />
          <EditText
        android:id="@+id/firstNum"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="100dp"
        android:ems="10" />
          <TextView
        android:id="@+id/secTxt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Second Number"
        android:layout_marginLeft="100dp" />
          <EditText
        android:id="@+id/secondNum"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="100dp"
        android:ems="10" />
          <Button
        android:id="@+id/addBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="100dp"
        android:text="Add" />
        </LinearLayout>
        
        
    3. Open the MainActivity File again, Copy and past the below application code. This will add two numbers we enter together.
      • package com.example.myapplication;
        import android.os.Bundle;
        import android.view.View;
        import android.widget.Button;
        import android.widget.EditText;
        import android.widget.Toast;
        import android.app.Activity;
        
        
        public class MainActivity extends Activity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
        final EditText firstNum = (EditText)findViewById(R.id.firstNum);
        final EditText secNum = (EditText)findViewById(R.id.secondNum);
          Button btnAdd = (Button)findViewById(R.id.addBtn);
          btnAdd.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
        if(firstNum.getText().toString().isEmpty() || secNum.getText().toString().isEmpty())
          {
          Toast.makeText(getApplicationContext(), "Please fill all the fields", Toast.LENGTH_SHORT).show();
          }
        else {
        int num1 = Integer.parseInt(firstNum.getText().toString());
        int num2 = Integer.parseInt(secNum.getText().toString());
          Toast.makeText(getApplicationContext(), "SUM = " + (num1 + num2), Toast.LENGTH_SHORT).show();
          }
          }
          });
          }
        }
        
        
    4. Our example application is now created
  8. Run the application on the MaaXBoard Mini
    1. Make sure in Android Studio the target selected is freescale EVK_8MM
      • If you don't see freescale EVK_8MM make sure your MaaXBoard Mini is powered up and you can communicate with it using the adb tools.
    2. In the Android Studio menu select Run -> Run...
    3. You will see this output on your MaaXBoard Mini
      • Play and explore the application, try and compare it to the code we just added into our application to see how it works
  9. Deploying your end application
    1. Now that we have designed a basic application, how do we deploy this? From my experience an easy way to share the desing file is by builiding it as an apk
    2. In the Android Studio go Build -> Build Bundle(s) / APK(s) -> Build APK(s)
    3. In the bottom right you will see when the APK has been build, select locate to open the directory
    4. You will see the APK has a default name, rename it to whatever you wish.
    5. Now that we have geneated the APK, i'll quickly show you how to use the adb tools to install the application.
    6. Open up the command line we were working in again with the adb tools.
    7. type adb install path to .apk for example
    8. You can verify the package has been installed by typing adb shell pm list packages
      • You will be given a list of installed packages, search for the one you installed!

 

Please let me know if you have any questions, i'm always interested in hearing about your latest designs and activities around the MaaXBoard or MaaXBoard Mini!

 

-Josh