Unfortunately, MetaWear has stopped

 
Recently I downloaded the MetawearSampleAndroidApp2 and trying to install and run the App.
I got as far as installing the App on my Droid MAXX phone. The android phone is linked to the
metawear module on bluetooth settings.
 
When I run the app, the message "Unfortunately, MetaWear has stopped" pops up. I
understand from your on line comment, that there is still some instability in this App.
 
Q1. Please send me links to updated docs etc to figure out how to fix this instability?
 
Also in the Getting started guide, chapter 5 you have "You can update your MetaWear board
using the Bluetooth link at any time using Over the Air Updates (OAD)." . Further read in this
part indicates I could update firmware using the DFU tab. 
 
Q2. Does the SampleApp2 need to be running for DFU tab to be visible? Or is that a different App?

Attached log from Eclipse:
(HK : First line ...) below is my debug statement to make sure ModuleListActivity fires..


08-25 09:57:21.068: I/HK(18302): First line of onCreate in ModuleListActivity
08-25 09:57:21.249: I/Adreno-EGL(18302): <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_KK_2.7_RB1.04.04.02.007.040_msm8960_KK_2.7_RB1_CL3869936_release_AU (CL3869936)
08-25 09:57:21.249: I/Adreno-EGL(18302): OpenGL ES Shader Compiler Version: 17.01.11.SPL
08-25 09:57:21.249: I/Adreno-EGL(18302): Build Date: 02/26/14 Wed
08-25 09:57:21.249: I/Adreno-EGL(18302): Local Branch: 
08-25 09:57:21.249: I/Adreno-EGL(18302): Remote Branch: quic/kk_2.7_rb1.29
08-25 09:57:21.249: I/Adreno-EGL(18302): Local Patches: NONE
08-25 09:57:21.249: I/Adreno-EGL(18302): Reconstruct Branch: NOTHING
08-25 09:57:21.298: D/OpenGLRenderer(18302): Enabling debug mode 0
08-25 09:57:21.320: D/AndroidRuntime(18302): Shutting down VM
08-25 09:57:21.320: W/dalvikvm(18302): threadid=1: thread exiting with uncaught exception (group=0x4178fd40)
08-25 09:57:21.322: E/AndroidRuntime(18302): FATAL EXCEPTION: main
08-25 09:57:21.322: E/AndroidRuntime(18302): Process: com.mbientlab.metawear.app, PID: 18302
08-25 09:57:21.322: E/AndroidRuntime(18302): java.lang.NullPointerException
08-25 09:57:21.322: E/AndroidRuntime(18302): at com.mbientlab.metawear.app.ModuleActivity.onCreateOptionsMenu(ModuleActivity.java:217)
08-25 09:57:21.322: E/AndroidRuntime(18302): at android.app.Activity.onCreatePanelMenu(Activity.java:2546)
08-25 09:57:21.322: E/AndroidRuntime(18302): at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:224)
08-25 09:57:21.322: E/AndroidRuntime(18302): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:436)
08-25 09:57:21.322: E/AndroidRuntime(18302): at com.android.internal.policy.impl.PhoneWindow.doInvalidatePanelMenu(PhoneWindow.java:800)
08-25 09:57:21.322: E/AndroidRuntime(18302): at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:221)
08-25 09:57:21.322: E/AndroidRuntime(18302): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
08-25 09:57:21.322: E/AndroidRuntime(18302): at android.view.Choreographer.doCallbacks(Choreographer.java:574)
08-25 09:57:21.322: E/AndroidRuntime(18302): at android.view.Choreographer.doFrame(Choreographer.java:543)
08-25 09:57:21.322: E/AndroidRuntime(18302): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
08-25 09:57:21.322: E/AndroidRuntime(18302): at android.os.Handler.handleCallback(Handler.java:733)
08-25 09:57:21.322: E/AndroidRuntime(18302): at android.os.Handler.dispatchMessage(Handler.java:95)
08-25 09:57:21.322: E/AndroidRuntime(18302): at android.os.Looper.loop(Looper.java:136)
08-25 09:57:21.322: E/AndroidRuntime(18302): at android.app.ActivityThread.main(ActivityThread.java:5086)
08-25 09:57:21.322: E/AndroidRuntime(18302): at java.lang.reflect.Method.invokeNative(Native Method)
08-25 09:57:21.322: E/AndroidRuntime(18302): at java.lang.reflect.Method.invoke(Method.java:515)
08-25 09:57:21.322: E/AndroidRuntime(18302): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
08-25 09:57:21.322: E/AndroidRuntime(18302): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
08-25 09:57:21.322: E/AndroidRuntime(18302): at dalvik.system.NativeStart.main(Native Method)
08-25 09:57:37.960: I/Process(18302): Sending signal. PID: 18302 SIG: 9

Comments

  • How to test if Android or Metawear is actually responding to "getSystemService"?
    I put the following code into ModuleActivity.java, and the output is listed below code.
    Appears either Android or Metawear is not providing : "getSystemService"

    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            Log.i("HK", " At ModuleActivity.onCreate");
            final BluetoothManager bluetoothManager =
                    (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
            if (!bluetoothManager.getAdapter().isEnabled()) {
                final Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
                startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
            } else {
            Log.i("HK", " At ModuleActivity.onCreate  is not enabled");
            }
            
            getApplicationContext().bindService(new Intent(this,MetaWearBLEService.class), 
                    this, Context.BIND_AUTO_CREATE);
            
            if (savedInstanceState != null) {
                device= (BluetoothDevice) savedInstanceState.getParcelable(EXTRA_BLE_DEVICE);
                moduleFragment= (ModuleFragment) getSupportFragmentManager().getFragment(savedInstanceState, "mContent");
            }else {
            Log.i("HK", " At ModuleActivity.onCreate  savedInstanceState is null");
            }
        }

    Produces:

    08-25 15:52:01.252: I/HK(27475):  At ModuleActivity.onCreate
    08-25 15:52:01.257: I/HK(27475):  At ModuleActivity.onCreate  is not enabled
    08-25 15:52:01.258: I/HK(27475):  At ModuleActivity.onCreate  savedInstanceState is null

  • What kind of documentation are you looking for?  Documentation on the API and getting started is on the MbientLab webpage: https://mbientlab.com/docs/.

    DFU is part of the Android App not the API.  I would like to have it on the API side but the Nordic code is designed to work with a specific activity layout and it is currently not worth the trouble to try to separate the code.

    As for the null pointer exception, the line in question (217) suggests the mwController variable is not being set which means the onServiceConnected function is not being called.  I would put a breakpoint in the onServiceConnected function to see if that is the case.
  • Yes, the onServiceConnected is not being called. 
    Do I insert this code/call -- in ModuleListActivity?
  • Following code in ModuleActivity.java (inserted onServiceConnected) -->
       
     public boolean onCreateOptionsMenu(final Menu menu) {
            getMenuInflater().inflate(R.menu.bledevice, menu);
            onServiceConnected(null, null); // force a call!
            Log.i("Entering ->", "ModuleActivity.onCreateOptionsMenu");

    Generated:

    08-27 17:01:05.785: I/Adreno-EGL(13874): Reconstruct Branch: NOTHING
    08-27 17:01:05.829: D/OpenGLRenderer(13874): Enabling debug mode 0
    08-27 17:01:05.854: I/Entering ->(13874): ModuleActivity.onCreateOptionsMenu
    08-27 17:01:05.855: D/AndroidRuntime(13874): Shutting down VM
    08-27 17:01:05.855: W/dalvikvm(13874): threadid=1: thread exiting with uncaught exception (group=0x4178fd40)
    08-27 17:01:05.856: E/AndroidRuntime(13874): FATAL EXCEPTION: main
    08-27 17:01:05.856: E/AndroidRuntime(13874): Process: com.mbientlab.metawear.app, PID: 13874
    08-27 17:01:05.856: E/AndroidRuntime(13874): java.lang.NullPointerException
    08-27 17:01:05.856: E/AndroidRuntime(13874): at com.mbientlab.metawear.app.ModuleActivity.onCreateOptionsMenu(ModuleActivity.java:243)
    08-27 17:01:05.856: E/AndroidRuntime(13874): at android.app.Activity.onCreatePanelMenu(Activity.java:2546)
    08-27 17:01:05.856: E/AndroidRuntime(13874): at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:225)
    08-27 17:01:05.856: E/AndroidRuntime(13874): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:436)

  • If I use the NordicSemi's DFU will I be unable to use metawear app?

  • Out of curiosity, are you building the app from the GitHub source code or using the prebuilt apk file?  If you are using the source code, there was a file naming issue stemming from Windows being case insensitive.  The problem is fixed in the latest release but it is possible you have MetaWearBLEService.java rather than MetaWearBleService.java.  I would double check the AndroidManifest.xml file and the service file name to be sure.  Other than this, I can't think of why the the service is not connecting in your activity.  The sample app works just fine on my 2013 Nexus 7.

    The Android app uses a slightly modified version of the Nordic DFU code.  The Nordic app will work but requires some slight modifications.
  • Thank you. 
    I changed MetaWearBleService.java in manifest to MetaWearBLEService.java ( since I
    had changed Ble to BLE everywhere else). Sample 2.0 now works with some issues stil:
    1. Pressing the button kicks up the "Unfortunately metaware has stopped"
    2. Entering LED values for G,R,B 
         ON intensity = 128, OFF intensity 1, Pulse {rise, on, fall, period, offset} = {128,1,1,128,1} , repeat 100
       does not light on board LED
    3. Pressing button "Button" in LED menu also stops the program and disconnects 
    4. Haptic : RunMotor ( not RunBuzzer, buzzer attached to high drive GPIO) works for a while, but repeated runmotor kills app.
    5. Accelerometer: After turining ON the three buttons, there is no display , if metawear is moved.

    If you could please update the app to:
    1. Have default values for LED
    2. Graceful exit for button "Button" pressed on LED menu
    3. Graceful exit for actual button pressed on hardware
    4. Accelerometer display Motion, Freefall, Orientation.. 

    That would be a great help!
    Thanks once again for the help so far

  • Tried the APP at the link, with DFU. It is much much better. Trying to compile the src .. running into errors due to my environment  (target sdk version is 20, MetawearAPI compiles fine with this version) :

    Description Resource Path Location Type
    ArrayFormat cannot be resolved to a variable AccelerometerFragment.java /MetaWearApp/src/com/mbientlab/metawear/app line 190 Java Problem
    DialogFragment cannot be resolved to a type AppHelpFragment.java /MetaWearApp/src/no/nordicsemi/android/nrftoolbox line 89 Java Problem
    CursorLoader cannot be resolved to a type DfuActivity.java /MetaWearApp/src/no/nordicsemi/android/nrftoolbox/dfu line 466 Java Problem

  • How odd.... the app is compiled for target SDK 19.  I don't see why changing it to 20 would cause build errors. Both DialogFragment and CursorLoader class are using the version from the android.support.v4 package and ArrayFormat is an enum from the AndroidPlot library.

    Have you tried cleaning the project?
  • Yes, clean and rebuild .. but still issues related to environment.
    When I unzip the sample app 2.1, and (using SDK 19 for MetawearAPI also) and add :
    Project->Properties->Android (check Android 4.4) MetawearAPI
    then
    Project->Properties->Java Build Path->metawearap.jar
    then 
    Project->Properties->Java Build Path->JRE System Library [jre8]

    I see (100 of 434 items) errors like:
    =========================
    '<>' operator is not allowed for source level below 1.7 AccelerometerFragment.java /MetaWearApp/src/com/mbientlab/metawear/app line 87 Java Problem
    ===================
    which eclipse is saying about the following Hashmap<> in AccelerometerFragment.java file:
    private HashMap<Integer, Boolean> values= new HashMap<>();

    Then I position curson on HashMap, one of the suggested corrections that eclipse pop up window shows is:
    "Change project compliance to JRE 1.7".

    This change makes the HashMap problems go away. But still the ArrayFormat errors remain.

    So: 
    Why is jre8 in library not compatible with JRE 1.7?
    When I look for:
    Project->Properties->Java Build Path-> (here select JRE system Library [jre8] -> edit
    New pop up window JRE System Library, select execution environment 
    then click environment button, another pop up window "Execution environments" shows(among others)
    JavaSE-1.7 which when selected shows jre8.

    Does this have anything to do with the errors I am seeing? I.e. jre 8 is not compatible with JRE 1.7
    (Note that jre 8 is lower case and JRE 1.7 is upper case etc)





  • Android does not support Java 8. 
  • OK, finally cleaned up my environment. Now I can compile and load and run. So I download
    the latest API, SampleApp 2.2.

    The .apk from github works on the droid and the metawear for Accelerometer, to record->stop->plot 

    However when I compile the source code for sampleapp 2.2. and download apk via eclipse 
    and run on my droid phone, the accelerometer record does not seem to record any 
    data from the module.

    Saw the same behavior with SampleApp 2.1 as well.

    I think it is failing to invoke onNotice...
    Is something still missing in my env? How to fix?


  • Pl. look at the code and log cat outputs below. Appears there is no data collection in 
    accelerometer code in the first pass. 
    Is there some code missing?  Should there be an output stream data collector first pass record?
    Attempted following debug:
    Accelerometer code excerpt begin ->
    -
                    if (!recording) { // Line 151
                    Log.i("Mbient:HK","Accelerometer: not Recording earlier, will Record now");
    -
                    } else {
                    Log.i("Mbient:HK","Accelerometer: Done Recording");
                        -
                            public void run() {
                                try {
                                    -
                                            Log.i("Mbient:HK","Accelerometer: BEGIN XYZ Processing");       
                                    //fos= ,...Context.MODE_WORLD_READABLE); <- deprecated
                                    fos= ....Context.MODE_PRIVATE); <- replaced 
                                    -
                                    fos= null;
                                    Log.i("Mbient:HK","Accelerometer: END XYZ Processing");
    -
            ((Button) view.findViewById(R.id.button2)).setOnClickListener(new OnClickListener() {
    -
                public void onClick(View v) {
                Log.i("Mbient:HK","Accelerometer: onClickListner->OnClickView ");
    -
                    } else if (accelHistoryPlot != null) {
                    Log.i("Mbient:HK","Accelerometer: onClickListner->OnClickView->ToPlot ");
                        accelHistoryPlot.redraw();
    -
    code end <-
    logcat begin ->
    09-12 14:42:42.225: I/Mbient:HK(10997): Accelerometer: In Record
    09-12 14:42:42.225: I/Mbient:HK(10997): Accelerometer: not Recording earlier, will Record now
    09-12 14:42:46.421: I/Mbient:HK(10997): Accelerometer: In Record
    09-12 14:42:46.421: I/Mbient:HK(10997): Accelerometer: Done Recording
    09-12 14:42:46.426: I/Mbient:HK(10997): Accelerometer: BEGIN XYZ Processing
    09-12 14:42:46.427: I/Mbient:HK(10997): Accelerometer: END XYZ Processing
    09-12 14:42:49.642: I/Mbient:HK(10997): Accelerometer: onClickListner->OnClickView 
    09-12 14:42:49.642: I/Mbient:HK(10997): Accelerometer: onClickListner->OnClickView->ToPlot 
  • Acclerometer data is stored into a temp variable, polledData, which is populated when the metawear is receiving data (receivedDataValue fn).  If no data is being collected then that variable is never fill up.  Trying getting the size of polledData / dump a few values out to see what's in there.
  • For whatever reason Accelerometer callback is NOT being executed.
    I have uploaded latest firmware using DFU. (your compiled .apk still works)
    I have used Metawear-AndroidAPI-1.0.8. 

    What next?

    Code:
    Inserted following code after line 81  in accelerometer:
    private Accelerometer.Callbacks mCallback= new Accelerometer.Callbacks() {
            public void receivedDataValue(short x, short y, short z) {
            Log.i("Mbient:HK","Accelerometer: Entering receivedDataValue Callback. PolledData " + polledData);
                if (polledData != null) {
                    polledData.add(new AxisData(System.currentTimeMillis() - start, x, y, z));
                }
                Log.i("Mbient:HK","Accelerometer: Exiting receivedDataValue Callback. PolledData " + polledData);
                
            }
        };

    Inserted following code after line 165 in accelerometer:

    Log.i("Mbient:HK","polledData Size is " + polledData.size() );
                        for(int i=0 ; (i<10 && i<polledData.size()) ; i++){
                        AxisData a = (AxisData) polledData.toArray()[i];
                        short x = a.data[0];
                        short y = a.data[1];
                        short z = a.data[2];
                        Log.i("Mbient:HK-AxisData","tick:" + a.tick + " x:" + x + " y:" + y + " z:" + z);
                        } 


    Logcat:
    09-12 23:01:48.377: I/Mbient:HK(10446): Accelerometer: In Record
    09-12 23:01:48.377: I/Mbient:HK(10446): Accelerometer: not Recording earlier, will Record now
    09-12 23:01:48.380: I/Mbient:HK(10446): polledData Size is 0
    09-12 23:02:00.163: I/Mbient:HK(10446): Accelerometer: In Record
    09-12 23:02:00.163: I/Mbient:HK(10446): Accelerometer: Done Recording
    09-12 23:02:00.167: I/Mbient:HK(10446): Accelerometer: BEGIN XYZ Processing
    09-12 23:02:00.168: I/Mbient:HK(10446): Accelerometer: END XYZ Processing
    09-12 23:02:01.225: I/Mbient:HK(10446): Accelerometer: onClickListner->OnClickView 
    09-12 23:02:01.225: I/Mbient:HK(10446): Accelerometer: onClickListner->OnClickView->ToPlot 


  • Is the accelerometer callback the only function that's not working?  If that is true, then I cannot think of why that would be only callback not being triggered.

    Also, it does not appear that you put the polledData checking code inside the thread, the time stamps don't match up for the red entries.  They should be very close to each other not 12 seconds apart.

    Logcat:
    09-12 23:01:48.377: I/Mbient:HK(10446): Accelerometer: In Record
    09-12 23:01:48.377: I/Mbient:HK(10446): Accelerometer: not Recording earlier, will Record now
    09-12 23:01:48.380: I/Mbient:HK(10446): polledData Size is 0
    09-12 23:02:00.163: I/Mbient:HK(10446): Accelerometer: In Record
    09-12 23:02:00.163: I/Mbient:HK(10446): Accelerometer: Done Recording
    09-12 23:02:00.167: I/Mbient:HK(10446): Accelerometer: BEGIN XYZ Processing
    09-12 23:02:00.168: I/Mbient:HK(10446): Accelerometer: END XYZ Processing
    09-12 23:02:01.225: I/Mbient:HK(10446): Accelerometer: onClickListner->OnClickView 
    09-12 23:02:01.225: I/Mbient:HK(10446): Accelerometer: onClickListner->OnClickView->ToPlot 
  • At least the accelerometer call back does not seem to be working. ( not sure if NeoPixels also has call backs, but neopixels is also crashing ..still testing .. will post more detail later).

    The reason there is a 12 sec delay in the first part (.377 to .380 in prev post) is because I use this time to move the metawear and then click on stop. Sometimes it is more than 12 secs.
    The Log. is placed as shown below. Is it the wrong place? If so, pl. indicate where to place.

    public void onClick(View v) {
                Log.i("Mbient:HK","Accelerometer: In Record");
                    if (!recording) {
                    Log.i("Mbient:HK","Accelerometer: not Recording earlier, will Record now");
                    accelController.setComponentConfiguration(Component.DATA, 
                                new byte[] {0, 0, 0x20, 0, 0});
                    polledData= new ConcurrentLinkedQueue<AxisData>();
                        start= System.currentTimeMillis();
                        accelController.enableNotification(Component.DATA);
                        recording= true;
                        recordButton.setText(R.string.label_accelerometer_data_stop);
                    Log.i("Mbient:HK","polledData Size is " + polledData.size() );
                        for(int i=0 ; (i<10 && i<polledData.size()) ; i++){
                        AxisData a = (AxisData) polledData.toArray()[i];
                        short x = a.data[0];
                        short y = a.data[1];
                        short z = a.data[2];
                        Log.i("Mbient:HK-AxisData","tick:" + a.tick + " x:" + x + " y:" + y + " z:" + z);
                        }
                        
                    } else { 
  • OK, problem solved:
    The API I had downloaded was older version. Downloaded latest version, compiled and it is working same as the apk released in github -- with occasional "unfortunately..." crashes.

    Thanks for all the help. Your comment above " Is the accelerometer callback the only function that's not working? " provided direction to detect this failure.


This discussion has been closed.