有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java运行时异常:“存根!”没有任何其他信息

我想用this library。我已经实现了所有回调,并尝试启动服务器:

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();
        }
    }
}

在这一行:

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

我得到了以下例外:

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

没有任何有用的反馈。那存根是什么意思?有没有人遇到过这样的事情,并且能够解决它

编辑:我正在添加我的gradle文件 项目建设。格雷德尔:

buildscript {

    repositories {
        google()
        jcenter()
        maven { url "http://code.newtronlabs.com:8081/artifactory/libs-release-local" }
    }
    dependencies {
        classpath 'com.安卓.tools.build:gradle:3.0.1'
        classpath "com.newtronlabs.安卓: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.安卓'
}

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

和应用程序构建。格雷德尔:

apply plugin: 'com.安卓.application'

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

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

共 (0) 个答案