运行时异常:"Stub!"没有任何其他信息



我正在尝试使用这个库。我已经实现了所有回调并尝试启动服务器:

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文件。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
}

和应用程序构建.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'
}

在这种情况下,您希望将provided用于库,以便一切顺利进行。您希望在gradle文件中进行更改。

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

相关内容

最新更新