App Crashing when trying to retrieve MetaWear MotionR

I am trying to connect to the board with the tutorial in Android Studio. I followed the tutorial exactly the way it was in the videos on this webpage. I am using the FreeFall app tutorial. It seems to crash right when it gets to retrieveBoard method.

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import bolts.Continuation;
import bolts.Task;

import com.mbientlab.metawear.MetaWearBoard;

public class MainActivity extends AppCompatActivity implements ServiceConnection {
private MetaWearBoard board;
private BtleService.LocalBinder localBinder;
private final String MAC_ADDRESS = "CB:42:F6:6E:2C:7A";
BluetoothAdapter bluetoothAdapter;

protected void onCreate(Bundle savedInstanceState) {
    bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    getApplicationContext().bindService(new Intent(this, BtleService.class),
            this, Context.BIND_AUTO_CREATE);


public void onDestroy() {

    // Unbind the service when the activity is destroyed

public void onServiceConnected(ComponentName name, IBinder binder) {
    localBinder = (BtleService.LocalBinder) binder;

public void onServiceDisconnected(ComponentName name) {


//This is where the app fails. It keeps saying the bluetooth is null*******
public void retrieveBoard() {
final BluetoothManager btManager =
(BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
final BluetoothDevice remoteDevice =

    // Create a MetaWear board object for the Bluetooth Device
    board = localBinder.getMetaWearBoard(remoteDevice);
    board.connectAsync().continueWith(new Continuation<Void, Void>() {
        public Void then(Task<Void> task) throws Exception {
            if (task.isFaulted()) {
                Log.i("freefall", "Failed to connect");
            } else {
                Log.i("freefall", "Connected");
            return null;

My manifest does have the service in there. This line.

Also, i do have the repo in the gradle file and i have the implementation dependency in my gradle file too.

I was wondering what to do. I have been stuck on this for about a month. It seems to work perfectly in the tutorial but not on my computer. I have tried 2 phones on a mac and pc. I don't know if there's an update to this tutorial or if i am missing something small.

Thank you for the help


    • Wrap code blocks with ```
    • Remove unnecessary code from your post. If your code blocks are more than ~20 lines, put it on a copy/paste site like Pastebin
    • Refer to the full the code on GitHub.
      Are there any differences between that code vs. what you have? Does the GitHub code work as is?
  • I got the starter app to work. I will be using this for now. Thankyou.

  • Resolved

This discussion has been closed.