I'm trying to implement the AndroidMultiBluetoothLibrary library located at this Android Multi link, but when trying to run the code it generates an error ´oClassDefFoundError: Failed resolution of: Lde/greenrobot/event/EventBus
I have tried in several ways including accessing the EventBus website and trying to detect the reason for the error, but I can not succeed, but I believe that it is some internal configuration that does not figure out how to do it. I have implemented this library (via a jar file rather than implemented in gradle since this form generated other errors) below is the code, gradle and generated error
Code:
public class ListaConexaoAzul extends BluetoothActivity {
private TextView titulo, texto;
private Button botao;
protected AmigoModel modelA;
private ListView grid;
List<String> mListLog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.f_lista);
setMessageMode(BluetoothManager.MessageMode.String);
setTimeDiscoverable(BluetoothManager.BLUETOOTH_TIME_DICOVERY_120_SEC);
selectClientMode();
titulo = findViewById(R.id.titulo);
texto = findViewById(R.id.content);
botao = findViewById(R.id.botao);
grid = findViewById(R.id.grid);
titulo.setText("Lista de Dispositivos");
texto.setText("");
botao.setText("Conectar");
botao.setVisibility(View.INVISIBLE);
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
Set<BluetoothDevice> bt = bluetoothAdapter.getBondedDevices(); //busca todos os dispositivos pareados
String[] strings = new String[bt.size()]; // cria uma lista de Strings com o tramanho da quantidade de dispositivos pareados
BluetoothDevice[] btArray = new BluetoothDevice[bt.size()];
int index = 0;
if (bt.size() > 0) { //verifica se existe dispositivos pareados
for (BluetoothDevice device : bt) { //Adicionando os dispositivos no array
btArray[index] = device;
strings[index] = device.getName();
bluetoothAdapter.getAddress();
index++;
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, strings);
grid.setAdapter(adapter);
grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
String address = btArray[i].getAddress();
createClient(btArray[i].getAddress());
sendMessageStringToAll("Hello Word");
}
});
}
}
@Override
public String setUUIDappIdentifier() {
return "f520cf2c-6487-11e7-907b";
}
@Override
public int myNbrClientMax() {
return 10;
}
@Override
public void onBluetoothDeviceFound(BluetoothDevice bluetoothDevice) {
}
@Override
public void onClientConnectionSuccess() {
}
@Override
public void onClientConnectionFail() {
}
@Override
public void onServeurConnectionSuccess() {
}
@Override
public void onServeurConnectionFail() {
}
@Override
public void onBluetoothStartDiscovery() {
}
@Override
public void onBluetoothMsgStringReceived(String s) {
}
@Override
public void onBluetoothMsgObjectReceived(Object o) {
}
@Override
public void onBluetoothMsgBytesReceived(byte[] bytes) {
}
@Override
public void onBluetoothNotAviable() {
}
}
Gradle:
android { compileSdkVersion 28 defaultConfig { applicationId "br.com.idev.ratteando" minSdkVersion 21 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile ('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility = '1.8' targetCompatibility = '1.8' } }
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.61'
implementation 'androidx.appcompat:appcompat:1.0.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-rc01'
implementation 'com.google.android.material:material:1.0.0-rc01'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
//AndroidMultBluetoothLibary
implementation files('libs/AndroidMultiBluetoothLibrary-2.0.4-SNAPSHOT.jar')
}
repositories {
maven {
url "http://drgames.fr/maven2/"
}
mavenCentral()
}
Error:
08-30 02:08:50.993 331-804/? E/AudioALSAPlaybackHandlerBase: openPcmDriver(), pcm_start(0xa7974ae0) fail due to cannot start channel: Broken pipe
08-30 02:08:51.593 13014-13014/? E/ViewSystem: ViewRootImpl #2 Surface is not valid.
08-30 02:08:53.133 13014-13014/? E/MotionRecognitionManager: mSContextService = null
08-30 02:08:53.133 13014-13014/? E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@9f6fd2
08-30 02:08:53.163 324-1019/? E/NetlinkEvent: NetlinkEvent::decode(): buffer'change@/devices/battery/power_supply/battery' size:715,format:0
08-30 02:08:53.163 217-291/? E/NetlinkEvent: NetlinkEvent::decode(): buffer'change@/devices/battery/power_supply/battery' size:715,format:0
08-30 02:08:53.283 7759-7759/? E/SamsungIME: processWhenPickSuggestionManually : 32
08-30 02:08:54.353 7759-7759/? E/SamsungIME: <AbstractKeyboardView> - onDraw() called
08-30 02:08:54.403 7759-7759/? E/SamsungIME: <AbstractKeyboardView> - onDraw() called
08-30 02:08:54.523 1148-1148/? E/Icon: Unable to load resource 0x00000000 from pkg=com.android.systemui
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:2598)
at android.content.res.Resources.getDrawable(Resources.java:2041)
at android.content.res.Resources.getDrawable(Resources.java:2027)
at android.graphics.drawable.Icon.loadDrawableInner(Icon.java:313)
at android.graphics.drawable.Icon.loadDrawable(Icon.java:269)
at android.graphics.drawable.Icon.loadDrawableAsUser(Icon.java:377)
at com.android.systemui.statusbar.StatusBarIconView.getIcon(StatusBarIconView.java:215)
at com.android.systemui.statusbar.BaseStatusBar.inflateViews(BaseStatusBar.java:2696)
at com.android.systemui.statusbar.BaseStatusBar.createNotificationViews(BaseStatusBar.java:3583)
at com.android.systemui.statusbar.phone.PhoneStatusBar.addNotification(PhoneStatusBar.java:2323)
at com.android.systemui.statusbar.BaseStatusBar$11$2.run(BaseStatusBar.java:1393)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
08-30 02:08:56.723 7759-7759/? E/SamsungIME: <AbstractKeyboardView> - onDraw() called
08-30 02:08:56.813 7759-7759/? E/SamsungIME: <AbstractKeyboardView> - onDraw() called
clc08-30 02:09:01.313 707-720/? E/InputMethodManagerService: Perflock object null
08-30 02:09:01.333 331-804/? E/AudioALSAPlaybackHandlerBase: openPcmDriver(), pcm_start(0xa7974ae0) fail due to cannot start channel: Broken pipe
08-30 02:09:01.353 7759-7759/? E/KeyboardInfoUtils: getInstance start
08-30 02:09:01.353 7759-7759/? E/KeyboardInfoUtils: sendSIPInformation state:6 isAbstractKeyboardView : true
08-30 02:09:01.363 7759-13112/? E/KeyboardInfoUtils: sending null keyboardInfo as SIP is closed
08-30 02:09:01.393 13014-13014/? E/MotionRecognitionManager: mSContextService = null
08-30 02:09:01.393 13014-13014/? E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@51c4e8e
08-30 02:09:01.403 13014-13014/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: br.com.idev.ratteando, PID: 13014
java.lang.NoClassDefFoundError: Failed resolution of: Lde/greenrobot/event/EventBus;
at com.ramimartin.multibluetooth.activity.BluetoothActivity.onStart(BluetoothActivity.java:38)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1266)
at android.app.Activity.performStart(Activity.java:6943)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3276)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.ClassNotFoundException: Didn't find class "de.greenrobot.event.EventBus" on path: DexPathList[[zip file "/data/app/br.com.idev.ratteando-1/base.apk", zip file "/data/app/br.com.idev.ratteando-1/split_lib_dependencies_apk.apk", zip file "/data/app/br.com.idev.ratteando-1/split_lib_slice_0_apk.apk", zip file "/data/app/br.com.idev.ratteando-1/split_lib_slice_1_apk.apk", zip file "/data/app/br.com.idev.ratteando-1/split_lib_slice_2_apk.apk", zip file "/data/app/br.com.idev.ratteando-1/split_lib_slice_3_apk.apk", zip file "/data/app/br.com.idev.ratteando-1/split_lib_slice_4_apk.apk", zip file "/data/app/br.com.idev.ratteando-1/split_lib_slice_5_apk.apk", zip file "/data/app/br.com.idev.ratteando-1/split_lib_slice_6_apk.apk", zip file "/data/app/br.com.idev.ratteando-1/split_lib_slice_7_apk.apk", zip file "/data/app/br.com.idev.ratteando-1/split_lib_slice_8_apk.apk", zip file "/data/app/br.com.idev.ratteando-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/br.com.idev.ratteando-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.ramimartin.multibluetooth.activity.BluetoothActivity.onStart(BluetoothActivity.java:38)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1266)
at android.app.Activity.performStart(Activity.java:6943)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3276)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Suppressed: java.lang.ClassNotFoundException: de.greenrobot.event.EventBus
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 14 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
08-30 02:09:01.413 707-13115/? E/android.os.Debug: ro.product_ship = true
08-30 02:09:01.413 707-13115/? E/android.os.Debug: ro.debug_level = 0x4f4c
08-30 02:09:01.413 707-13115/? E/android.os.Debug: sys.mobilecare.preload = false
08-30 02:09:03.213 324-1019/? E/NetlinkEvent: NetlinkEvent::decode(): buffer'change@/devices/battery/power_supply/battery' size:715,format:0
08-30 02:09:03.213 217-291/? E/NetlinkEvent: NetlinkEvent::decode(): buffer'change@/devices/battery/power_supply/battery' size:715,format:0
08-30 02:09:04.313 217-291/? E/NetlinkEvent: NetlinkEvent::decode(): buffer'change@/devices/virtual/xt_idletimer/timers' size:194,format:0
08-30 02:09:04.313 324-1019/? E/NetlinkEvent: NetlinkEvent::decode(): buffer'change@/devices/virtual/xt_idletimer/timers' size:194,format:0
08-30 02:09:04.313 324-1019/? E/NetlinkEvent: NetlinkEvent::FindParam(): Parameter 'LABEL' not found