connectAsync() crashing app

Greetings

I am trying to develop an Android app for my MetaWear C board that makes use of the Sensor Fusion data.
Reading the documentation, it says that before I can make use of any of the sensors, I need to make a call to connectAsync() , nevertheless, the app crashes right after the method is called, and I still don't understand why.

This is what I get on Logcat on Android Studio:
2019-01-07 21:46:11.166 13465-16502/? E/AudioProvider: AudioRecord is null, can't start recording
2019-01-07 21:46:11.186 13465-13465/? E/HotwordDetector: Invalid or incompatible speaker models. Silent enrollment required.
java.lang.IllegalArgumentException: Invalid speaker model provided
at com.google.speech.micro.GoogleHotwordRecognizer.nativeNew(Native Method)
at com.google.speech.micro.GoogleHotwordRecognizer.(SourceFile:6)
at com.google.android.libraries.assistant.hotword.k.a(SourceFile:66)
at com.google.android.libraries.assistant.hotword.k.at(SourceFile:35)
at com.google.android.apps.gsa.voiceinteraction.hotword.a.dIB(SourceFile:48)
at com.google.android.apps.gsa.voiceinteraction.hotword.b.handleMessage(SourceFile:4)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6753)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:482)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

This is the all the code I have so far on my MainActivity, which is the only Activity I have on this project:
package com.example.pedro.metaweartest3;

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.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import bolts.Continuation;
import bolts.Task;

import com.mbientlab.metawear.MetaWearBoard;
import com.mbientlab.metawear.android.BtleService;

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";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


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

@Override
public void onDestroy() {
super.onDestroy();

    // Unbind the service when the activity is destroyed
    getApplicationContext().unbindService(this);
}




@Override
public void onServiceConnected(ComponentName name, IBinder binder){
    localBinder = (BtleService.LocalBinder) binder;
    retrieveBoard();
}
@Override
public void onServiceDisconnected(ComponentName name){

}


public void retrieveBoard() {
    final BluetoothManager btManager=
            (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
    final BluetoothDevice remoteDevice=
            btManager.getAdapter().getRemoteDevice(MAC_ADDRESS);

    // Create a MetaWear board object for the Bluetooth Device
    board= localBinder.getMetaWearBoard(remoteDevice);
}




public void onClickTry(View view){
 board.connectAsync().continueWith(new Continuation<Void, Void>() {
     @Override
     public Void then(Task<Void> task) throws Exception {
         if (task.isFaulted()) {
             Log.i("MainActivity", "Failed to connect");
         } else {
             Log.i("MainActivity", "Connected");
         }
         return null;
     }
 });

}

}

I still cannot figure what could be causing the problem. Your help will be greatly appreciated. Thank you

Comments

  • That error doesn't appear relevant to any MetaWear code.

    Use the debugger to check that your variables aren't null and make sure you have declared the MetaWear service in your manifest file.

  • This is my AndroidManifest.xml :

    <?xml version="1.0" encoding="utf-8"?>




    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.intent.action.VIEW"/>
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service android:name="com.mbientlab.metawear.android.BtleService" />
    </application>
    

    Also, I have been using the debugger to check my variables, and at the moment I invoke the onClickTry() method by pressing a button, the board variable has a value of JseMetaWearBoard@5583

    public void onClickTry(View view){
    board.connectAsync().continueWith(new Continuation<Void, Void>() { // board: JseMetaWearBoard@5583
    @Override
    public Void then(Task task) throws Exception {
    if (task.isFaulted()) {
    Log.i("MainActivity", "Failed to connect");
    } else {
    Log.i("MainActivity", "Connected");
    }
    return null;
    }
    });
    }

    If I let the program continue running with the next line, which is where connectAsync() is called, the program crashes and the only error I get on the Logcat is what I posted earlier.

    What else can I try to make this work?

  • edited January 2019

    Wrap code blocks with ```

    Step though the conectAsync method with the debugger. There isn't much that can be done without knowing where the crash occurs.

    You can also try uisng the starter app template from the tutorial project.
    https://github.com/mbientlab/MetaWear-Tutorial-Android

  • 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";
    private  BluetoothManager  btManager;
    private  BluetoothDevice remoteDevice;
    private BluetoothLeScanner scanner;
    private TextView connectText;
    private TextView successText;
    
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btManager= (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
        remoteDevice= btManager.getAdapter().getRemoteDevice(MAC_ADDRESS);
        scanner = btManager.getAdapter().getBluetoothLeScanner();
        connectText = findViewById(R.id.connect_text);
        successText = findViewById(R.id.board_connected_text);
    
        getApplicationContext().bindService(new Intent(this, BtleService.class),
                this, Context.BIND_AUTO_CREATE);
    }
    

    @Override
    public void onDestroy() {
    super.onDestroy();
    // Unbind the service when the activity is destroyed
    getApplicationContext().unbindService(this);
    }

    @Override
    public void onServiceConnected(ComponentName name, IBinder binder){
        localBinder = (BtleService.LocalBinder) binder;
    
    }
    @Override
    public void onServiceDisconnected(ComponentName name){
    
    }
    
    
    
    
    
    
    public void onClickTry(View view){
     board.connectAsync().continueWith(new Continuation<Void, Void>() {
         @Override
         public Void then(Task<Void> task) throws Exception {
             if (task.isFaulted()) {
                 runOnUiThread(new Runnable() {
                     @Override
                     public void run() {
                         connectText.setText("Board is connected and ready to be used");
                     }
                 });
             } else {
                 runOnUiThread(new Runnable() {
                     @Override
                     public void run() {
                         connectText.setText("Board is not ready to be used");
                     }
                 });
             }
             return null;
         }
     });
    

    }

    public void onClickConnect(View view){
    startScan();
    }

    ScanCallback callback = new ScanCallback() {
    @Override
    public void onScanResult(int callbackType, final ScanResult result) {
    super.onScanResult(callbackType, result);

         runOnUiThread(new Runnable() {
             @Override
             public void run() {
                 remoteDevice =  result.getDevice();
                 board = localBinder.getMetaWearBoard(remoteDevice);
                 connectText.setText("The board was successfully found!");
    
             }
         });
    
    
    
     }
    

    };
    public void startScan(){
    List filters = new ArrayList<>();
    ScanFilter filter = new ScanFilter.Builder()
    .setDeviceAddress(MAC_ADDRESS)
    .build();

    filters.add(filter);
    
    ScanSettings settings = new ScanSettings.Builder().build();
    
    scanner.startScan(filters,settings,callback);
    

    }

    error:

    E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.pedro.metaweartest3, PID: 20419
    java.lang.IllegalStateException: Could not execute method for android:onClick
    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390)
    at android.view.View.performClick(View.java:6597)
    at android.view.View.performClickInternal(View.java:6574)
    at android.view.View.access$3100(View.java:778)
    at android.view.View$PerformClick.run(View.java:25885)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6718)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
    at android.view.View.performClick(View.java:6597)
    at android.view.View.performClickInternal(View.java:6574)
    at android.view.View.access$3100(View.java:778)
    at android.view.View$PerformClick.run(View.java:25885)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6718)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    Caused by: java.lang.BootstrapMethodError: Exception from call site #1 bootstrap method
    at com.mbientlab.metawear.android.BtleService$AndroidPlatform.connectAsync(BtleService.java:475)
    at com.mbientlab.metawear.impl.JseMetaWearBoard.connectAsync(JseMetaWearBoard.java:752)
    at com.example.pedro.metaweartest3.MainActivity.onClickTry(MainActivity.java:88)
    at java.lang.reflect.Method.invoke(Native Method)
    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
    at android.view.View.performClick(View.java:6597)
    at android.view.View.performClickInternal(View.java:6574)
    at android.view.View.access$3100(View.java:778)
    at android.view.View$PerformClick.run(View.java:25885)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6718)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    Caused by: java.lang.ClassCastException: Bootstrap method returned null
    at com.mbientlab.metawear.android.BtleService$AndroidPlatform.connectAsync(BtleService.java:475)
    at com.mbientlab.metawear.impl.JseMetaWearBoard.connectAsync(JseMetaWearBoard.java:752)
    at com.example.pedro.metaweartest3.MainActivity.onClickTry(MainActivity.java:88)
    at java.lang.reflect.Method.invoke(Native Method)
    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
    at android.view.View.performClick(View.java:6597)
    at android.view.View.performClickInternal(View.java:6574)
    at android.view.View.access$3100(View.java:778)
    at android.view.View$PerformClick.run(View.java:25885)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6718)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

  • This is how I modified my code so it makes a Bluetooth scan to retrieve the board instead of passing it the mac address to create the object.

    The second part is the exception I get in the debugger.

    Why is this happening? Thank you

  • Quoting myself

    @Eric said:
    Wrap code blocks with ```

  • @Eric said:
    Quoting myself

    @Eric said:
    Wrap code blocks with ```

    I'm sorry but I don't understand, what do you mean to use ```?

  • Exactly what it says. Wrap your code with 3 backticks, otherwise it will not render correctly on the page.

  • My app doesn't connect to Meta Motion Sensor R+. It keeps going to Update Firmware Screen. Tries to upload new firmware and then fails to connect. Tried all the steps listed numerous times with same results. Using Android phone. Last connection was this morning.

  • @PrakashDesai said:
    My app doesn't connect to Meta Motion Sensor R+. It keeps going to Update Firmware Screen. Tries to upload new firmware and then fails to connect. Tried all the steps listed numerous times with same results.

    Post unrelated issues in their own thread. Do not hijack existing threads.

  • 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";
    private  BluetoothManager  btManager;
    private  BluetoothDevice remoteDevice;
    private BluetoothLeScanner scanner;
    private TextView connectText;
    private TextView successText;
    
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btManager= (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
        remoteDevice= btManager.getAdapter().getRemoteDevice(MAC_ADDRESS);
        scanner = btManager.getAdapter().getBluetoothLeScanner();
        connectText = findViewById(R.id.connect_text);
        successText = findViewById(R.id.board_connected_text);
    
        getApplicationContext().bindService(new Intent(this, BtleService.class),
                this, Context.BIND_AUTO_CREATE);
    }
    @Override
    public void onDestroy() {
    super.onDestroy();
    // Unbind the service when the activity is destroyed
    getApplicationContext().unbindService(this);
    }
    
    @Override
    public void onServiceConnected(ComponentName name, IBinder binder){
        localBinder = (BtleService.LocalBinder) binder;
    
    }
    @Override
    public void onServiceDisconnected(ComponentName name){
    
    }
    
    
    
    
    
    
    public void onClickTry(View view){
     board.connectAsync().continueWith(new Continuation<Void, Void>() {
         @Override
         public Void then(Task<Void> task) throws Exception {
             if (task.isFaulted()) {
                 runOnUiThread(new Runnable() {
                     @Override
                     public void run() {
                         connectText.setText("Board is connected and ready to be used");
                     }
                 });
             } else {
                 runOnUiThread(new Runnable() {
                     @Override
                     public void run() {
                         connectText.setText("Board is not ready to be used");
                     }
                 });
             }
             return null;
         }
     });
    }
    
    public void onClickConnect(View view){
    startScan();
    }
    
    ScanCallback callback = new ScanCallback() {
    @Override
    public void onScanResult(int callbackType, final ScanResult result) {
    super.onScanResult(callbackType, result);
    
         runOnUiThread(new Runnable() {
             @Override
             public void run() {
                 remoteDevice =  result.getDevice();
                 board = localBinder.getMetaWearBoard(remoteDevice);
                 connectText.setText("The board was successfully found!");
    
             }
         });
    
    
    
     }
    };
    public void startScan(){
    List filters = new ArrayList<>();
    ScanFilter filter = new ScanFilter.Builder()
    .setDeviceAddress(MAC_ADDRESS)
    .build();
    
    filters.add(filter);
    
    ScanSettings settings = new ScanSettings.Builder().build();
    
    scanner.startScan(filters,settings,callback);
    }
    
    
  • error:

    E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.pedro.metaweartest3, PID: 20419
    java.lang.IllegalStateException: Could not execute method for android:onClick
    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390)
    at android.view.View.performClick(View.java:6597)
    at android.view.View.performClickInternal(View.java:6574)
    at android.view.View.access$3100(View.java:778)
    at android.view.View$PerformClick.run(View.java:25885)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6718)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
    at android.view.View.performClick(View.java:6597)
    at android.view.View.performClickInternal(View.java:6574)
    at android.view.View.access$3100(View.java:778)
    at android.view.View$PerformClick.run(View.java:25885)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6718)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    Caused by: java.lang.BootstrapMethodError: Exception from call site #1 bootstrap method
    at com.mbientlab.metawear.android.BtleService$AndroidPlatform.connectAsync(BtleService.java:475)
    at com.mbientlab.metawear.impl.JseMetaWearBoard.connectAsync(JseMetaWearBoard.java:752)
    at com.example.pedro.metaweartest3.MainActivity.onClickTry(MainActivity.java:88)
    at java.lang.reflect.Method.invoke(Native Method)
    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
    at android.view.View.performClick(View.java:6597)
    at android.view.View.performClickInternal(View.java:6574)
    at android.view.View.access$3100(View.java:778)
    at android.view.View$PerformClick.run(View.java:25885)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6718)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    Caused by: java.lang.ClassCastException: Bootstrap method returned null
    at com.mbientlab.metawear.android.BtleService$AndroidPlatform.connectAsync(BtleService.java:475)
    at com.mbientlab.metawear.impl.JseMetaWearBoard.connectAsync(JseMetaWearBoard.java:752)
    at com.example.pedro.metaweartest3.MainActivity.onClickTry(MainActivity.java:88)
    at java.lang.reflect.Method.invoke(Native Method)
    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
    at android.view.View.performClick(View.java:6597)
    at android.view.View.performClickInternal(View.java:6574)
    at android.view.View.access$3100(View.java:778)
    at android.view.View$PerformClick.run(View.java:25885)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6718)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

  • That is my Android app code and the error I get when I try to call onClickTry()
    Any updates on this?
    Thank you

  • Step through the connectAsync function until you get to this line in the stack trace:

    com.mbientlab.metawear.android.BtleService$AndroidPlatform.connectAsync(BtleService.java:475)

    What is the state of the variables at that point?

    I've never seen this exception message with the API so not sure what is wrong:

    Caused by: java.lang.ClassCastException: Bootstrap method returned null

    Quoting myself again:

    @Eric said:
    You can also try uisng the starter app template from the tutorial project.
    https://github.com/mbientlab/MetaWear-Tutorial-Android

  • I figured out what was wrong!
    apparently, the ConnectAsync() uses some component from material design library, because right after I implemented material design on my project, the problem disappeared!

  • @Pete0009 said:
    I figured out what was wrong!
    apparently, the ConnectAsync() uses some component from material design library, because right after I implemented material design on my project, the problem disappeared!

    what did you add?
    i have the same problem

  • @echiu said:

    @Pete0009 said:
    I figured out what was wrong!
    apparently, the ConnectAsync() uses some component from material design library, because right after I implemented material design on my project, the problem disappeared!

    what did you add?
    i have the same problem

    Follow the troubleshooting steps outlined in this thread.

  • edited October 2019

    Well i am using a windows 10 computer, and when i debug app:
    10/02 19:03:54: Launching 'app' on samsung SM-A105M. $ adb shell am start -n "com.example.pruebadeconeccion/com.example.pruebadeconeccion.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D Waiting for application to come online: com.example.pruebadeconeccion.test | com.example.pruebadeconeccion Waiting for application to come online: com.example.pruebadeconeccion.test | com.example.pruebadeconeccion Waiting for application to come online: com.example.pruebadeconeccion.test | com.example.pruebadeconeccion Connecting to com.example.pruebadeconeccion Connected to the target VM, address: 'localhost:8600', transport: 'socket' Disconnected from the target VM, address: 'localhost:8600', transport: 'socket'

    When i run the app:
    10/02 19:11:35: Launching 'app' on samsung SM-A105M. $ adb shell am start -n "com.example.pruebadeconeccion/com.example.pruebadeconeccion.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Waiting for process to come online... Connected to process 25335 on device 'samsung-sm_a105m-R28M708NNQL'. Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page. I/DecorView: createDecorCaptionView >> DecorView@492214d[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true W/uebadeconeccio: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection) W/uebadeconeccio: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection) W/uebadeconeccio: Accessing hidden method Landroid/widget/TextView;->getTextDirectionHeuristic()Landroid/text/TextDirectionHeuristic; (light greylist, linking) D/OpenGLRenderer: Skia GL Pipeline D/EmergencyMode: [EmergencyManager] android createPackageContext successful D/InputTransport: Input channel constructed: fd=60 D/ViewRootImpl@e2f550a[MainActivity]: setView = DecorView@492214d[MainActivity] TM=true MM=false D/ViewRootImpl@e2f550a[MainActivity]: stopped(true) old=false D/ViewRootImpl@e2f550a[MainActivity]: Relayout returned: old=[0,0][720,1520] new=[0,0][720,1520] result=0x1 surface={false 0} changed=false I/Euler: Servicio Conectado D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.pruebadeconeccion, PID: 25335 java.lang.BootstrapMethodError: Exception from call site #1 bootstrap method at com.mbientlab.metawear.android.BtleService$AndroidPlatform.connectAsync(BtleService.java:475) at com.mbientlab.metawear.impl.JseMetaWearBoard.connectAsync(JseMetaWearBoard.java:752) at com.example.pruebadeconeccion.MainActivity.retrieveBoard(MainActivity.java:61) at com.example.pruebadeconeccion.MainActivity.onServiceConnected(MainActivity.java:44) at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1848) at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1880) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7091) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975) Caused by: java.lang.ClassCastException: Bootstrap method returned null at com.mbientlab.metawear.android.BtleService$AndroidPlatform.connectAsync(BtleService.java:475)  at com.mbientlab.metawear.impl.JseMetaWearBoard.connectAsync(JseMetaWearBoard.java:752)  at com.example.pruebadeconeccion.MainActivity.retrieveBoard(MainActivity.java:61)  at com.example.pruebadeconeccion.MainActivity.onServiceConnected(MainActivity.java:44)  at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1848)  at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1880)  at android.os.Handler.handleCallback(Handler.java:873)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:214)  at android.app.ActivityThread.main(ActivityThread.java:7091)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)  I/Process: Sending signal. PID: 25335 SIG: 9 Process 25335 terminated

    My manifest:
    ```<?xml version="1.0" encoding="utf-8"?>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <service android:name="com.mbientlab.metawear.android.BtleService" />
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    

    ```

  • edited October 2019

    And my code is the same as the code in tutorial B freefall:

    ```package com.example.pruebadeconeccion;

    import androidx.appcompat.app.AppCompatActivity;

    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.Bundle;
    import android.os.IBinder;
    import android.util.Log;

    import com.mbientlab.metawear.MetaWearBoard;
    import com.mbientlab.metawear.android.BtleService;

    import bolts.Continuation;
    import bolts.Task;

    public class MainActivity extends AppCompatActivity implements ServiceConnection {

    private BtleService.LocalBinder serviceBinder;
    private MetaWearBoard board;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        // Bind the service when the activity is created
        getApplicationContext().bindService(new Intent(this, BtleService.class),
                this, Context.BIND_AUTO_CREATE);
    }
    
    @Override
    public void onServiceConnected(ComponentName name, IBinder service) {
    
        // Typecast the binder to the service's LocalBinder class
        serviceBinder = (BtleService.LocalBinder) service;
    
        Log.i("Euler","Servicio Conectado");
    
        retrieveBoard("EA:51:34:53:9B:1A");
    
    }
    
    @Override
    public void onServiceDisconnected(ComponentName name) {
    
    }
    
    public void retrieveBoard(final String macAddr) {
        final BluetoothManager btManager=
                (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
        final BluetoothDevice remoteDevice=
                btManager.getAdapter().getRemoteDevice(macAddr);
    
        // Create a MetaWear board object for the Bluetooth Device
        board= serviceBinder.getMetaWearBoard(remoteDevice);
        board.connectAsync().continueWith(new Continuation<Void, Void>() {
    
            @Override
    
            public Void then(Task<Void> task) throws Exception {
                if (task.isFaulted()) {
                    Log.i("Euler","Fallo la conccenión BT inicial");
                } else  {
                    Log.i("Euler","BT conectado a "+ macAddr);
                }
                return null;
            }
        });
    }
    

    ```
    i am using MMR

    PD: I'm not spamming just won't let me get everything in a comment

  • There's nothing immediately apparent with your code; looks correct.

    Again, as I've stated in this thread, import the tutorial project build your app in the starter template.

    Have you tried searching the internet about this exception? This seems like a general Bluetooth issue other people probably have encountered.

Sign In or Register to comment.