serwus
serwus

Reputation: 165

RuntimeException: "Stub!" without any other information

I'm trying to use this library. I have implemented all callbacks and tried to start a server:

public class MasterActivity extends AppCompatActivity {

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

        createBluetoothServer();
    }

    void createBluetoothServer(){
        IBluetoothServer btServer = new BluetoothServer.Builder(this.getApplicationContext(),
                "EasyBtService", ParcelUuid.fromString(uuid))
                .build();

        if (btServer == null){
            Log.e(this.getClass().getCanonicalName(), "Failed to create server!");
        } else {
            // Block until a client connects.
            IBluetoothClient btClient = btServer.accept();
            // Set a data callback to receive data from the remote device.
            btClient.setDataCallback(new DataReceivedCallbackMaster());
            // Set a connection callback to be notified of connection changes.
            btClient.setConnectionCallback(new ConnectionCallbackMaster());
            // Set a data send callback to be notified when data is sent of fails to send.
            btClient.setDataSentCallback(new DataSentCallbackMaster());
            btClient.sendData("ServerGreeting", "Hello Client".getBytes());
            //We don't want to accept any other clients.
            btServer.disconnect();
        }
    }
}

In the line:

IBluetoothServer btServer = new BluetoothServer.Builder(this.getApplicationContext(),
                "EasyBtService", ParcelUuid.fromString(uuid))
                .build();

I'm getting following exception:

Process: XXX, PID: 28033
java.lang.RuntimeException: Unable to start activity ComponentInfo{XXX/XXX.Activities.MasterActivity}: java.lang.RuntimeException: Stub!

Without any usefull feedback. What that stub is supposed to mean? Has anyone already met with something like this and was able to solve it?

EDIT: I'm adding my gradle files. Project build.gradle:

buildscript {

    repositories {
        google()
        jcenter()
        maven { url "http://code.newtronlabs.com:8081/artifactory/libs-release-local" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath "com.newtronlabs.android:plugin:2.0.0.alpha"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "http://code.newtronlabs.com:8081/artifactory/libs-release-local" }
    }
}

subprojects {
    apply plugin: 'com.newtronlabs.android'
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

And app build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "XXX"
        minSdkVersion 22
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.newtronlabs.easybluetooth:easybluetooth:2.0.0'
}

Upvotes: 2

Views: 607

Answers (1)

Newtron Labs
Newtron Labs

Reputation: 819

In this case you want to use provided for the library so that everything works smoothly. You want to make the change in the gradle file.

provided 'com.newtronlabs.easybluetooth:easybluetooth:2.0.0'

Upvotes: 1

Related Questions